akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_V 100000
using namespace std;

typedef long long ll;
typedef pair<int, int> P;   // first: 最短距離, second: 頂点のindex

struct edge { int to, cost; };

int main() {
    int V, E, r;
    vector<edge> G[MAX_V];
    cin >> V >> E >> r;
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back(edge{t, d});
    }
    
    int d[MAX_V];
    fill(d, d + MAX_V, INF);
    d[r] = 0;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push(P(0, r));
    
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        
        if (d[v] < p.first) continue;
        
        for (int i = 0; i < G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[v] + e.cost < d[e.to]) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    
    for (int i = 0; i < V; ++i) {
        if (d[i] == INF)
            cout << "INF";
        else
            cout << d[i];
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 13060
#include <cstdio>
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
typedef long long LL;
inline LL gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main() {
	LL n, k, g, a, mx = 0;
	scanf("%lld%lld", &n, &k);
	for (int i = 1; i <= n; i ++) {
		scanf("%lld", &a);
		if (i == 1) g = a;
		else g = gcd(g, a);
		if (a == k) {
			puts("POSSIBLE");
			return 0;
		}
		mx = max(mx, a);
	}
	if (k % g != 0 || mx < k) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,a[100],min,ans=0;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++){
    min=i;
    for(int j=i;j<n;j++){
      if(a[j]<a[min]){
	min=j;
      }
    }
    if(i!=min)
      ans++;
    swap(a[i],a[min]);
  }
  for(int i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl;
  cout<<ans<<endl;
}

Measured memory_bytes: 3120
def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v
        print(str(A).replace(",",'').replace("[",'').replace("]",''))


N=int(input())
sl=input()
print(sl)
lis=list(map(int,sl.split()))
insertionSort(lis,N)

Measured memory_bytes: 7736
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC__

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

    int A, B;
    std::cin >> A >> B;
    std::cout << (A + B) % 24 << std::endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mk make_pair
#define pb push_back
#define vi vector<int>
#define x first
#define y second
#define ms(a,b)  memset(a, b, sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define M 1000005
vector<int> graph[M];
int ind[M],vis[M];

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,u,v;
    queue<int> q;
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>u>>v,u--,v--,graph[u].pb(v),ind[v]++;
    for(int i=0;i<n;i++)if(ind[i]==0)q.push(i),vis[i]=1;
    int sz,t,lev=-1;
    while(!q.empty()){
        sz=q.size();
        while(sz--){
            t=q.front(),q.pop();
            for(int i=0;i<graph[t].size();i++){
                u=graph[t][i];
                if(!vis[u] && (--ind[u] == 0))
                    q.push(u),vis[u]=1;
            }
        }
        lev++;
    }
    cout<<lev<<endl;
    return 0;
}
  

Measured memory_bytes: 33024
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;

int main(){
	string sen,p,com;
	cin >> sen;
	int n, a, b;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> com >> a >> b;
		if (com == "replace"){
			cin >> p;
			sen.replace(a, b-a+1, p);
		}
		else if (com == "reverse"){
			string sen2 = sen;
			for (int j = 0; j <= b - a; j++){
				sen[a + j] = sen2[b - j];
			}
		}
		else if (com == "print"){
			cout << sen.substr(a, b-a+1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3228
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i
count = 0

0.upto(a) do |i|
  0.upto(b) do |s|
    0.upto(c) do |m|
      if (500*i)+(100*s)+(50*m) == x
        count += 1
      end
    end
  end
end
puts count



Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;

long long fac(int k){long long sum = 1;for(int i=1;i<=k;++i)sum *= i;return sum;}
long long per(int n,int r){long long nn,rr;nn=fac(n);rr=fac(r)*fac(n-r);return nn/rr;}

int main(){
    int A[3],K;
    cin >> A[0] >> A[1] >> A[2];
    cin >> K;
    int max=A[0],max_i=0;
    for(int i=1;i<3;i++){
        if(A[i]>max){
            max=A[i];
            max_i=i;
        }
    }
    for(int i=0;i<K;i++){
        A[max_i] += A[max_i];
    }
    cout << A[0]+A[1]+A[2] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


	// Backtracking or bitmasks
	// end here trick!

	public static void main(String[]args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong(), y = sc.nextLong();
		int ans = 1;
		while (x <= y) {
			if (Long.MAX_VALUE / 2 < x) {
				break;
			}
			x *= 2;
			if (x <= y) {
				++ans;
			}
		}
		System.out.println(ans);
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


Measured memory_bytes: 21204
import fractions
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))

Measured memory_bytes: 5048
n = int(input())
c = 0
isthere = 0
for i in range(n):
    nums = [int(prefix_sum) for prefix_sum in input().split()]
    if nums[0] == nums[1]:
        c = c + 1
    else:
        c = 0

    if c >= 3:
        isthere = 1

if isthere == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main() {
 int A[4];
 char s[4];
 cin>>s;
 for(int i=0;i<4;i++){
     A[i]=s[i]-'0';
 }
 char op[3];

 for(int s=0;s<(1<<3);s++){
     int sum=A[0];
     for(int i=0;i<3;i++){
         if(s>>i&1){op[i]='+';sum+=A[i+1];}
         else{op[i]='-';sum-=A[i+1];}
     }
     if(sum==7){break;}
 }
 for(int i=0;i<3;i++){
     cout<<A[i]<<op[i];
 }
 cout<<A[3]<<"=7"<<endl;
 
 return 0;}

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

int main() {
  string S;
  cin >> S;
  if(S=="SUN"){
    cout << 7 << endl;
  }
  if(S=="MON"){
    cout << 6 << endl;
  }
  if(S=="TUE"){
    cout << 5 << endl;
  }
  if(S=="WED"){
    cout << 4 << endl;
  }
  if(S=="THU"){
    cout << 3 << endl;
  }
  if(S=="FRI"){
    cout << 2 << endl;
  }
  if(S=="SAT"){
    cout << 1 << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n;
    cin>>n;
    int a[n+1],b[n];
    int sum = 0;
    for(i=1;i<n;i++) cin>>b[i];
    a[1] = a[2] = b[1];
    for(i=2;i<n;i++)
    {
        if(b[i]>=b[i-1])
        {
            a[i+1] = b[i];
        }
        else
        {
            a[i] = a[i+1] = b[i];
        }
    }
    for(i=1;i<=n;i++) sum+=a[i];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

S = list(input())
K = iin()
s = copy.deepcopy(S)
last_update = False
count1 = 0
for si in range(1, len(s)):
    if s[si-1] == s[si]:
        s[si] = '?'
        count1 += 1
        if si == len(s)-1:
            last_update = True
count2 = 0
last_update2 = False
if not last_update and S[0] == S[-1]:
    count2 = 1
    S2 = list('?')
    S2.extend(S[1:])
    for i in range(2, len(S2)):
        if S2[i-1] == S2[i]:
            S2[i] = '?'
            count2 += 1
            if i == len(S2)-1:
                last_update2 = True
if len(S) ==1:
    print(len(S)*K//2)
elif K == 1:
    print(count1)
elif count2 == 0:
    print(K*count1)
else:
    if last_update2:
        count12 = count1+count2
        ans = count12*(K//2)
        if K % 2 == 1: 
            ans+= count1
        print(ans)
    else:
        print(count1 + count2*(K-1))

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

public class Main {


    private static void solver(InputReader sc, PrintWriter out) throws Exception {
        int x = sc.nextInt();
        if(x >= 400 && x<=599){
            out.println(8);
        }else if(x >= 600 && x <= 799){
            out.println(7);
        }else if(x >= 800 && x <= 999){
            out.println(6);
        }else if(x >= 1000 && x <= 1199){
            out.println(5);
        } else if(x >=1200 && x <= 1399){
            out.println(4);
        }else if(x >= 1400 && x <= 1599){
            out.println(3);
        }else if(x >= 1600 && x <= 1799){
            out.println(2);
        }else if(x>=1800 && x<=1999){
            out.println(1);
        }
    }

    private static int lcm(int a, int b) {

        return (a * b) / gcd(a, b);
    }

    private static int gcd(int a, int b) {

        if (b == 0)
            return a;

        return gcd(b, a % b);
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

class Pair {
    int x, y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

class Tuple implements Comparable<Tuple> {
    int x, y, z;

    public Tuple(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public int compareTo(Tuple t) {
        if (this.z == t.z) {
            if (this.y == t.y) {
                return t.x - this.x;
            } else return t.y - this.y;
        } else
            return this.z - t.z;
    }


}

Measured memory_bytes: 32796
def main():
	n = int(input())
	sl=[]
	sl=["".join(sorted(input())) for _ in range(n)]
	sl.sort()
	b=""
	l=1
	ans=0
	for i, s in enumerate(sl):
		if s==b:
			l+=1
			if i==n-1 and l >1:
				ans+=l*(l-1)/2
		else:
			if l>1:
				ans+=l*(l-1)/2
			b=s
			l=1
	print (int(ans))

main()


Measured memory_bytes: 10640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

int S(ll X) {
  int A = 0;
  while (X > 0) {
    X /= 10;
    A++;
  }
  return A;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  ll N, M;
  cin >> N >> M;
  if (2 * N >= M) {
    cout << M / 2 << endl;
  }
  else {
    cout << N + (M - 2 * N) / 4 << endl;
  }
}
  
  

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = 0;
        int b = 0;
        for (int i = 0; i < 3; i++) {
            int value = input.nextInt();
            if (value == 5)
                a++;
            else if (value == 7)
                b++;
        }

        if (a == 2 && b == 1)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

ll n;

void dfs(ll i, ll cnt, string s) {
  rep(j, cnt) {
    char c = 'a'+j;
    if (i != n) dfs(i+1, cnt + (j == cnt-1) , s+c);
    else cout << s+c << endl;
  }
}

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

  cin >> n;
  dfs(1, 1, "");
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n, h;
    cin >> n >> h;
    priority_queue<P> que;
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        que.emplace(a, INF);
        que.emplace(b, 1);
    }
    int ans = 0;
    while(h > 0){
        P p = que.top();
        que.pop();
        if(p.second == 1){
            ++ans;
            h -= p.first;
        }
        else{
            ans += (h + p.first - 1) / p.first;
            h = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5312
public class Main {

	public static void main(String[] args) {

		java.util.Scanner scan = new java.util.Scanner(System.in);

		int s = scan.nextInt();
		int w = scan.nextInt();
		
		if (w >= s ) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}

}


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

int main(void){
    string s;
    cin>>s;
    int n = s.size();
    int k = n;
    rep(i,n-1){
        if(s[i]!=s[i+1]) k = min(k,max(n-i-1,i+1));
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int m=Integer.parseInt(value[0]);
int d=Integer.parseInt(value[1]);
System.out.println(dayOfdate(m,d));
}
}
static String dayOfdate(int m,int d){
int[] md={31,29,31,30,31,30,31,31,30,31,30,31};
if(m!=1){
for(int i=0;i<m-1;i++){
d+=md[i];
}
}
if(d%7==1){return "Thursday";}
else if(d%7==2){return "Friday";}
else if(d%7==3){return "Saturday";}
else if(d%7==4){return "Sunday";}
else if(d%7==5){return "Monday";}
else if(d%7==6){return "Tuesday";}
else{return "Wednesday";}
}
}

Measured memory_bytes: 16984
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int NIL = -1;
const int MAX = 20001;

int G[101][101];

int main(void)
{
	int n, k, v, u;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int i = 0; i < k; i++) {
			cin >> v;
			G[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << G[i][j];
			if (j != n)
				cout << " ";
		}
		cout << endl;
	}
	return 0;
}


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

int main()
{
  int N, K; cin >> N >> K;
  int A[N]; rep(i,N) cin >> A[i];
  int MAX = 200000;
  //集計
  int map[MAX] = {0};
  rep(i,N) map[A[i]]++;
  //K種以下か判定→最小のものを返す
  int count = 0;
  int ans = 0;
  rep(i,MAX)
  {
    if(map[i] != 0) count++;
  }
  
  sort(map, map+MAX, greater<int>());
  
  if(count > K)
  {
    for(int i = K; i < MAX; i++)
    {
      ans += map[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
#define F first 
#define S second 
#define MAX 10000003 
int prime[MAX]; 
unordered_map<int, int> maxx_map; 
  
// Function to return a^n 
int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
  
// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
// Function to return the LCM modulo M 
ll lcmModuloM(const ll* ar, ll n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        ll num = ar[i]; 
        unordered_map<ll, ll> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            ll factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            maxx_map[it.first] = max((ll)maxx_map[it.first], (ll)it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : maxx_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
} 


int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  sieve();
  ll L=lcmModuloM(a, n);
  ll ans=0;
  rep(i,n){
    ans+=modinv(a[i],mod);
    ans%=mod;
  }
  ans*=L;
  ans%=mod;
  cout << ans << endl;
return 0;}

Measured memory_bytes: 39808
from collections import Counter
s = input()
n = len(s)
ans = True
if n > 2:
    for i in range(n - 2):
        if max(list(Counter(s[i:i+3]).values())) > 1:
            print(i + 1, i + 3)
            ans = False
            exit()
    if ans:
        print(-1, -1)
else:
    if max(list(Counter(s).values())) > 1:
        print(1, 2)
    else:
        print(-1, -1)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define F first
#define S second
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)   //test cases
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define error(x) fixed<<setprecision(x) //cout<<error(5)<<someDouble    -> example - 3.14159
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll i = 0; i < n; i++)    cin>>a[i];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
	boost;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

int main(){
	init();
	string s;
	cin>>s;
	ll curr = 0, ans = 0;
	for(auto x : s){
		if(x == 'R')	curr++;
		else	curr = 0;
		ans = max(ans, curr);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3648
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto x = RD;
	auto a = RD;
	auto b = RD;

	writeln(abs(x - a) < abs(x - b) ? "A" : "B");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
# すぬけ君は、1 から 12 までの整数を下図のようにグループ分けしました。 
# 整数 x, y (1≤x<y≤12) が与えられるので、x, y が同一のグループに属しているか判定してください。

input = gets.chomp.split
x = input[0].to_i
y = input[1].to_i

groups = [
    [1, 3, 5, 7, 8, 10, 12],
    [4, 6, 9, 11],
    [2]
]

3.times do |i|
    if groups[i].include?(x) && groups[i].include?(y)
        puts "Yes"
        break
    end
    if i == 2
        puts "No"
    end
end

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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
double pi=acos(-1);


int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        int n;
        cin>>n;
        n=n%10;
        switch(n)
        {
            case 2:case 4:case 5:case 7:case 9:
                cout<<"hon";
                break;

            case 0: case 1: case 6: case 8:
                cout<<"pon";
                break;
            case 3:
                cout<<"bon";
                break;
        }
    }
}


Measured memory_bytes: 3632
l, r = map(int, input().split())
m = 2019
for i in range(l, r+1):
  for j in range(i+1, r+1):
    mod1 = i % 2019
    mod2 = j % 2019
    if mod1 == 0 or mod2 == 0:
      print(0)
      exit()
    mod = (mod1 * mod2) % 2019
    if mod < m:
      m = mod

print(m)


Measured memory_bytes: 40428
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if(s=="Sunny")cout<<"Cloudy\n";
	else if(s=="Cloudy")cout<<"Rainy\n";
	else cout<<"Sunny\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
string s[N];
char ans[N];
int n;
void dfs(int i,int a,int b,int c){
    if(a<0 || b<0 || c<0){
        return;
    }
    if(i==n){
        printf("Yes\n");
        for(int i=0;i<n;i++) cout<<ans[i]<<endl;
        exit(0);
    }
    if(s[i]=="AB"){
        ans[i]='A';
        dfs(i+1,a+1,b-1,c);
        ans[i]='B';
        dfs(i+1,a-1,b+1,c);
    }
    else if(s[i]=="AC"){
        ans[i]='A';
        dfs(i+1,a+1,b,c-1);
        ans[i]='C';
        dfs(i+1,a-1,b,c+1);
    }
    else if(s[i]=="BC"){
        ans[i]='C';
        dfs(i+1,a,b-1,c+1);
        ans[i]='B';
        dfs(i+1,a,b+1,c-1);
    }
}
int main() {
	int a,b,c;
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++) cin>>s[i];
	dfs(0,a,b,c);
	printf("No\n");
	return 0;
}

Measured memory_bytes: 14672
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll oddsum = 0;
  for (ll i = 0; i < N; i++) {
    if (i % 2 == 0) {
      oddsum += A[i];
    } else {
      oddsum -= A[i];
    }
  }

  // 最初の答え=oddsum +A[N-1] * 2
  vector<ll> dp(N);
  for (ll i = 0; i < N; i++) {
    if (i == 0) {
      dp[i] = oddsum;
    } else {
      dp[i] = (A[i - 1] - (dp[i - 1] / 2)) * 2;
    }
    if (i < N - 1) {
      cout << dp[i] << " ";
    } else {
      cout << dp[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <queue>
#define INF 1500000000
using namespace std;

struct edge{ int from,to,cost; };

int main(){
	int V,E,r;
	cin >> V >> E >> r;
	vector<edge> es;
	int d[V];
	for(int i = 0;i < V;i++) d[i] = INF;
	for(int i = 0;i < E;i++){
		int a,b,c;
		cin >> a >> b >> c;
		es.push_back({a,b,c});
	}
	d[r] = 0;
	for(int i = 0;i < V;i++){
		bool update = false;
		for(int j = 0;j < E;j++){
			edge e = es[j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if(i == V - 1) {
					cout << "NEGATIVE CYCLE" << endl;
					return 0;
				}
			}
		}
		if(!update) break;
	}
	for(int i = 0;i < V;i++) {
		if(d[i] == INF) cout << "INF" << endl;
		else cout << d[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
const int MAXN=15;
const int MAXS=(1<<MAXN);
const int MOD=1000000007;
int n,m,S,tot=1;
int f[MAXS+5]={1},cnt[MAXS+5],to[MAXN+10];
int main()
{
	scanf("%d%d",&n,&m);S=(1<<n)-1;
	for(int i=0,u,v;i<m;++i)
	{
		scanf("%d%d",&u,&v);
		to[--u]^=(1<<(--v));
		tot=tot+tot;if(tot>=MOD)tot-=MOD;
	}
	for(int i=S;~i;--i)for(int t=i;t;t^=t&(-t))++cnt[i];
	for(int i=0,la,x,y,w;i<S;++i)
	{
		la=S^i;if((i&3)&&(i&3)!=3)continue;
		for(int j=la;j;j=(j-1)&la)
		{
			x=i^j;if((x&3)&&(x&3)!=3)continue;
			y=S^x;w=f[i];
			for(int o=0;o<n;++o)
				if((y>>o)&1)w=(ll)w*((1<<cnt[j&to[o]])-1)%MOD;
				else if((j>>o)&1)w=((ll)w<<cnt[y&to[o]])%MOD;
			f[x]=f[x]+w;if(f[x]>=MOD)f[x]-=MOD;
		}
	}
	tot=tot+MOD-f[S];
	printf("%d",(tot>=MOD)?(tot-MOD):tot);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int start=0;
		int end=0;
		for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='A'){
				start=i;
				break;
			}
		}
		for(int i=s.length()-1;i>=0;i--){
			if(s.charAt(i)=='Z'){
				end=i;
				break;
			}
		}
		System.out.println(end-start+1);
	}
}


Measured memory_bytes: 14444
n = input()
a = [int(i) for i in input().split()]
alice = []
bob = []
for i in range(int(n)):
    try:
        alice.append(max(a))
        a.remove(max(a))
        bob.append(max(a))
        a.remove(max(a))
    except:
        pass
print(sum(alice) - sum(bob))


Measured memory_bytes: 2940
/*
* @Author: wxyww
* @Date:   2019-03-16 20:09:11
* @Last Modified time: 2019-03-16 20:13:41
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
using namespace std;
typedef long long ll;

ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
const int N = 30;
int a[N];
int ans;
int n;
const int mod = 1e9 + 7;
void dfs(int now,int ret) {
	if(now == 27) {
		ans += ret;
		ans %= mod;
		return;
	}
	dfs(now + 1,ret);
	if(a[now]) dfs(now + 1,1ll * ret * a[now] % mod);
}
char s[100004];
int main() {
	n = read();
	scanf("%s",s + 1);
	for(int i = 1;i <= n;++i) a[s[i] - 'a' + 1]++;
	dfs(1,1);
	cout<<ans - 1;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
    int H, W, i, j;
    while (1)
    {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
        {
            break;
        }
        for (i = 0; i < H; i++)
        {
            for (j = 0; j < W; j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include<iostream>
using namespace std;
 
int main()
{
     long long int n,total=1;
     cin>>n;
     
     for(int i=1;i<=n;i++)
     {
         total*=i;
         total=total%1000000007;
     }
     cout<<total<<endl;
   
    return 0;
}

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

int main() {
    const char CardInitial[]{ 'S', 'H', 'C', 'D' };
    std::array<bool,13> cards[4]{};
    int num{};
    std::cin >> num;
    for(auto i=0; i<num; i++) {
        char c;
        int n;
        std::cin >> c >> n;
        for(auto ci=0; ci<4; ci++) {
            if(CardInitial[ci] != c) continue;
            cards[ci][n-1] = true;
        }
    }
    for(auto i=0; i<4; i++) {
        for(auto j=0; j<13; j++) {
            if(!cards[i][j]) {
                std::cout << CardInitial[i] << " " << (j+1) << std::endl;
            }
        }
    }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e1, M = 1<<N;

int main() {
	string s, t;
	cin>>s>>t;
	int n = s.length();
	int ans = 0;
	rep(i, 0, n) {
		if(s[i] != t[i]) ans++;
	}
	cout<<ans; 
	return 0;
}

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

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

  vector<int> v(N);

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

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += v[i];
  }

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=c && c<=a+b){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  long n;
  cin>>n;
  long a[n];
  long ans = 0;
  long minus = 0;
  long syou = 10000000000;
  for(int i = 0;i<n;i++){
    cin >> a[i];
    ans += abs(a[i]);
    if(a[i] < 0){
      minus++;
    }
    syou = min(syou,abs(a[i]));
  }
  if(minus%2 ==0){
    cout<<ans<<endl;
  }
  else{
    cout<<ans-2*syou<<endl;
  }
  return 0;
}


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

struct Point {
  int x, y;
  Point() {}
  Point(int x, int y) : x(x), y(y) {}
  
  Point operator + (const Point &a) {
	return Point(x - a.x, y - a.y);
  }
  Point operator - (const Point &a) {
	return Point(x - a.x, y - a.y);
  }
  
  bool operator < (const Point &a) const {
	if( x == a.x ) {
	  if( y < a.y ) return true;
	}
	else {
	  if( x < a.x ) return true;
	}
	return false;
  }
  
  bool operator == (const Point &a) const {
	return x==a.x && y==a.y;
  }
  
  double norm() {
	return x*x+y*y;
  }
};

typedef Point Vector;

Vector rotate90R(Vector V) {
  return Vector(V.y, -V.x);
}

bool isIn(int x, int y) {
  return 0<=x && x<=5000 && 0<=y && y<=5000;
}

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

  	vector<Point> vec;
	map<Point, int> exist;

	for(int i=0; i<n; i++) {
	  cin >> x >> y;
	  Point p(x, y);
	  vec.push_back(p);
	  exist[p] ++;
 	}
	
	int ans = 0;
	
	for(int i=0; i<n-1; i++) {
	  for(int j=i+1; j<n; j++) {
		Vector V1 = vec[i] - vec[j];
		Vector V2 = rotate90R(V1);
		int area = V1.norm();
		
		Vector VV1 = vec[j]+V2;
		Vector VV2 = vec[i]+V2;
		if(isIn(VV1.x, VV1.y) && isIn(VV2.x, VV2.y))
		  if(exist.count(VV1) && exist.count(VV2))
			ans = max(ans, area);
		
		VV1 = vec[j]-V2;
		VV2 = vec[i]-V2;
		if(isIn(VV1.x, VV1.y) && isIn(VV2.x, VV2.y))
		  if(exist.count(VV1) && exist.count(VV2))
			ans = max(ans, area);
	  }
	}
	cout << ans << endl;
  }
  
  return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		




int main() {

	int n;
	cin >> n;
	VI a(n);
	REP(i, n)cin >> a[i];

	int ma = -INF, mi = INF, itma, itmi;

	REP(i, n) {
		if (ma < a[i]) {
			itma = i;
			ma = a[i];
		}
		if (mi > a[i]) {
			itmi = i;
			mi = a[i];
		}
	}

	cout << 2 * n - 1 << endl;

	if (abs(ma) > abs(mi)) {
		REP(i, n) {
			cout << itma + 1 << ' ' << i+1 << endl;
			a[i] += a[itma];
		}
		REP(i, n - 1) {
			cout << i+1 << ' ' << i+2 << endl;
			a[i + 1] += a[i];
		}
	}
	else {
		REP(i, n) {
			cout << itmi + 1 << ' ' << i+1 << endl;
			a[i] += a[itmi];
		}
		for (int i = n - 1; i >= 1; i--) {
			cout << i + 1 << ' ' << i << endl;
			a[i - 1] += a[i];
		}
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main()
{
	double x1,y1,x2,y2,x3,y3,xp,yp;
	double s,s1,s2,s3;
	double ab,bc,ca,ap,bp,cp;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
	ab=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	bc=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
	ca=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
	ap=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
	bp=sqrt((x2-xp)*(x2-xp)+(y2-yp)*(y2-yp));
	cp=sqrt((x3-xp)*(x3-xp)+(y3-yp)*(y3-yp));
	s=sqrt(((ab+bc+ca)*(-ab+bc+ca)*(ab-bc+ca)*(ab+bc-ca))/16);
	s1=sqrt(((ap+ab+bp)*(-ap+ab+bp)*(ap-ab+bp)*(ap+ab-bp))/16);
	s2=sqrt(((bp+bc+cp)*(-bp+bc+cp)*(bp-bc+cp)*(bp+bc-cp))/16);
	s3=sqrt(((cp+ca+ap)*(-cp+ca+ap)*(cp-ca+ap)*(cp+ca-ap))/16);
	if(fabs(s1+s2+s3-s)<0.0000001)puts("YES");
	else puts("NO");
	}
	return 0;
}

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

int main(){
	int n;
	int l[3];
	int ma, sum, rest, ma2;
	cin >> n;

	for(int i=0; i<n; ++i){
		cin >> l[0] >> l[1] >> l[2];
		ma = max(l[0], max(l[1],l[2]));
		ma2 = ma*ma;
		sum = l[0]*l[0] + l[1]*l[1] + l[2]*l[2];
		rest = sum - ma2;

		if(ma2 == rest){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

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

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll dis = B - A;
  if(dis % 2 == 0){
    cout << dis / 2 << endl;
  }else{
    ll l = (A + B - 1) / 2 ;
    ll r = (N - B + 1 + N - A) / 2;
    cout << min(l, r) << endl;
  }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string t;
    cin >> t;
    int n = 0, w = 0, s = 0, e = 0;
    rep (i, t.size()) {
        if (t[i] == 'N') n++;
        else if (t[i] == 'S') s++;
        else if (t[i] == 'W') w++;
        else e++;
    }
    if (((n > 0 && s > 0) || (n == 0 && s == 0)) && ((w > 0 && e > 0) || (w == 0 && e == 0))) cout << "Yes" << endl;
    else cout << "No" << endl; 
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    bool is_ok = false;
    rep(i, 0, N) {
        if (A[i] == 1) {
            is_ok = true;
            break;
        }
    }
    if (!is_ok) {
        cout << -1 << endl;
        return 0;
    }
    int now = 1;
    rep(i, 0, N) {
        if (A[i] == now) ++now;
    }
    cout << N - now + 1 << endl;
    return 0;
}

Measured memory_bytes: 1024
// 2011/07/31 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int s[5][2];
		cin >> s[0][0] >> s[0][1];
		if(s[0][0]==0&&s[0][1]==0)
			break;

		for(int i=1; i<5; i++)
			cin >> s[i][0] >> s[i][1];

		int max_i = 0;
		int max_s = s[0][0]+s[0][1];
		for(int i=1; i<5; i++)
			if(s[i][0]+s[i][1]>max_s){
				max_i = i;
				max_s = s[i][0]+s[i][1];
			}

		cout << (char)('A'+max_i) << ' ' << max_s << endl;
	}

	return 0;
}

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

int n;
string a;
int main()
{
	int i;
	cin >> a;
	n = a.size();
	if (n % 2) {
		cout << "No";
		return 0;
	}
	for (i = 0; i < n; i += 2) {
		if (a[i] != 'h' || a[i + 1] != 'i') {
		cout << "No";
		return 0;

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


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    
    if A[i+1] < A[i]:
        cnt += A[i] - A[i+1]
        A[i+1] = A[i]
    # print(A)
    # print(cnt)
print(cnt)

Measured memory_bytes: 32168
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

Pii search(vector<vector<int> > is){
    rep(i,12)rep(j,12){
        if (is[i+1][j+1]==1)
        {
            return make_pair(i+1,j+1);
        }
    }
    return make_pair(-1,-1);
}

void unionIsland(vector<vector<int> > &ismap,int num,Pii base){
    stack<Pii> st;
    st.push(base);
        while(!st.empty()){
            Pii f = st.top();st.pop();
            ismap[f.first][f.second]=num;
            if(ismap[f.first-1][f.second]==1){
                st.push(make_pair(f.first-1,f.second));
            }
            if(ismap[f.first+1][f.second]==1){
                st.push(make_pair(f.first+1,f.second));
            }
            if(ismap[f.first][f.second-1]==1){
                st.push(make_pair(f.first,f.second-1));
            }
            if(ismap[f.first][f.second+1]==1){
                st.push(make_pair(f.first,f.second+1));
            }
        }
}

int solve(){
    vector<vector<int> > ismap(14,vector<int> (14,0));
    int num = 1;
    rep(i,12){
        string tmp;
        if(!(cin>>tmp))return -1;
        rep(j,12){
            if(tmp[j]=='1') ismap[i+1][j+1]=1;
        }
    }

    Pii base = search(ismap);
    while (base.first != -1)
    {
        // cout<<base.first<<" "<<base.second<<endl; 
        num++;
        unionIsland(ismap,num,base);
        base = search(ismap);
    }
    

    return num-1;
}

int main(){
    rep(i,20){
        int tmp = solve();
        if (tmp ==-1) return 0;
        cout << tmp <<endl;
        
    }
    return 0;
}


Measured memory_bytes: 3148