akhauriyash/Code-Regression huggingface dataset:
using System;

public class Hello{
    public static void Main(){
        // Your code here!
        string Ns= System.Console.ReadLine();
        string[] S= System.Console.ReadLine().Split(' ');
        //System.Console.WriteLine("Hello C#");
        int A=int.Parse(S[0]);
        int B=int.Parse(S[1]);
        int N=int.Parse(Ns);
        bool fl =false; 
        
        for (int i=A;i<=B;i++)
        {
            if (i%N==0){
                System.Console.WriteLine("OK");
                fl =true;
                break;
            }
        }
        if(fl==false){
        System.Console.WriteLine("NG");
        }
    }
}


Measured memory_bytes: 27480
#include <iostream>
#include <string>
#include <math.h>

int main(){
    int n, m;
    std::cin >> n;
    int a[n];
    int i, k, count=0;
    for(i=0;i<n;i++){
        std::cin>>a[i];
        if(a[i]%2==0){
            if((a[i]%3!=0)&&(a[i]%5!=0)){
                std::cout << "DENIED"<< std::endl;
                return 0;
            }
        }
    }
    std::cout << "APPROVED"<< std::endl;
    return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = [I() for _ in range(N)]

    is_ok = True

    # A[i] > iと、2以上大きくなるところがあるとダメ
    if [A[i] for i in range(N) if A[i] > i]:
        is_ok = False
    else:
        for i in range(N - 1):
            if A[i] + 1 < A[i+1]:
                is_ok = False
                break

    if is_ok:
        # 後ろの上昇列から作っていく 上昇列の最後の数字だけ回数がかかる
        ans = 0
        if N == 1:
            ans = 0
        else:
            for i in range(N - 1):
                if A[i] >= A[i+1]:
                    ans += A[i]
            ans += A[-1]

    if is_ok:
        print(ans)
    else:
        print(-1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 19396
import sys
lines = sys.stdin.readlines()
cnt = [0 for i in range(26)]
alph = [chr(ord('a') + i) for i in range(26)]
for line in lines:
    line = line.lower()
    for idx, i in enumerate(alph):
        for k in line:
            if i == k:
                cnt[idx] += 1
for idx, i in enumerate(alph):
    print("{0} : {1}".format(i, cnt[idx]))


Measured memory_bytes: 5572
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int K = Integer.parseInt(sc.next());
      int A = Integer.parseInt(sc.next());
      int B = Integer.parseInt(sc.next());
      int count = 0;
      for(int i = A; i < B+1; i++){
        if(i%K == 0){
          count++;
        }
      }
      if(count > 0){
        System.out.println("OK");

      }else{
        System.out.println("NG");

      }

    }
}


Measured memory_bytes: 35792
s = input()
s = s[::-1]
# print(s)
key = 0
#print(s[:5])
while len(s) > 0:
    if s[:5] in ['maerd', 'esare']:
        s = s[5:]
        #print(s)
    elif s[:6] == 'resare':
        s = s[6:]
        #print(s)
    elif s[:7] == 'remaerd':
        s = s[7:]
        #print(s)
    else:
        key = 1
        break
if key == 0:
    print('YES')
else:
    print('NO')

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& e : a) cin >> e;
    int ans = 0;
    for(int i = 0;i < n;i++){
        ans = __gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
D, G = map(int,input().split())
L = []
ans = []
def ceil(i):
    if int(i) == i:
        return int(i)
    else:
        return int(i)+1


for _ in range(D):
    l = list(map(int,input().split())) +[0]
    L.append(l)
for k in range(2**D):
    value = 0
    b = format(k,'b').zfill(D)
    l = list(map(int,list(b)))
    cnt = 0
    for i in range(D):
        if l[i]:
            L[i][2] = 1
            value += L[i][1]
            value += L[i][0]*((i+1)*100)
            cnt += L[i][0]
        else:
            L[i][2] = 0
    remain = list(filter(lambda x:x[2]==0,L))[::-1]
    j = len(remain)
#    print(value,cnt,remain)
    if G - value > 0:
        while True:
            if remain==[]:
                cnt = 10**100
                break
            tmp = remain.pop(0)
            if G - value <= (j*100)*(tmp[0] - 1):
 #               print(G-value,j*100)
                cnt += ceil((G-value)/(j*100))
                break
            else:
                cnt += tmp[0]-1
                value += (j*100)*(tmp[0]-1)
                j -= 1
    ans.append(cnt)

print(min(ans))

Measured memory_bytes: 43868
N,A,B,C=[int(i) for i in input().split()]
l=[int(input()) for _ in range(N)]
INF=10**18

def dfs(cur, a, b, c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
  string a,b,c;
  cin>>a>>b;
  int d,e;
  cin>>d>>e;
  cin>>c;
  if(c==a)
    d--;
    if(c==b)
      e--;
  cout<<d<<' '<<e<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
typedef long long ll;
ll a[MAXN],b[MAXN];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i],&b[i]);
	}
	ll ans=0;
	for(int i=n;i>=1;i--)
	{
		ll mu;
		a[i]+=ans;
		mu=a[i]/b[i];
		if(a[i]%b[i]==0)
			continue;
		mu++;
		ans+=b[i]*mu-a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = inpl()

L = K+1
M = len(bin(L))-2
MM = max(M, len(bin(max(A)))-2)
best = []
ones_num = []
zeros_num = []
for m in range(MM):
    ones = sum([ (A[i]>>m)&1 for i in range(N) ])
    zeros = N - ones
    ones_num.append(ones)
    zeros_num.append(zeros)
    if ones >= zeros:
        best.append(0)
    else:
        best.append(1)
cur = sum([ (N-ones_num[m] if (best[m] and m < M-1) else ones_num[m])<<m for m in range(MM)])
ans = cur
m = M - 1
while m > 0:
    cur += (zeros_num[m]-ones_num[m])<<m
    m -= 1
    while (L >> m)&1 == 0:
        if best[m] == 1:
            cur += (ones_num[m]-zeros_num[m])<<m
        m -= 1
        if m < 0:
            break
    else:
        if best[m] == 1:
            cur += (ones_num[m]-zeros_num[m])<<m
        if cur > ans:
            ans = cur
print(ans)

Measured memory_bytes: 14620
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

bool compCards(string a, string b) {
    return a[1] > b[1];
}

vector<string> bubbleSort(vector<string> C) {
    int n = C.size();
    for (int i=0; i<n; ++i) {
        for (int j=n-1; j>i; --j) {
            if (compCards(C[j-1], C[j])) {
                swap(C[j], C[j-1]);
            }
        }
    }
    return C;
}

vector<string> selectionSort(vector<string> C) {
    int n = C.size();
    for (int i=0; i<n; ++i) {
        int mini = i;
        for (int j=i+1; j<n; ++j) {
            if (compCards(C[mini], C[j])) {
                mini = j;
            }
        }
        swap(C[i], C[mini]);
    }
    return C;
}

void print(vector<string> v) {
    for (int i=0; i<(int)v.size(); ++i) {
        cout << (i == 0 ? "" : " ") << v[i];
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);

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

    vector<string> res1 = bubbleSort(cards);
    print(res1);
    cout << "Stable" << endl;

    vector<string> res2 = selectionSort(cards);
    print(res2);
    string stable = (res1 == res2 ? "Stable" : "Not stable");
    cout << stable << endl;

    return 0;
}

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

#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define ins insert

#define f(i,n) for(int i = 0 ;  i < n ; i ++)
#define f1(i,n) for(int i = 1 ; i<= n ; i++)

#define int long long int

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() int t;cin>>t;while(t--)





int32_t main()
{
	fast();

	int n  , m ;
	cin >> n >> m;

	int a[n+1] ;

	int maxn[n+1];


	f1(i,n)
		cin >> a[i];

	memset(maxn, 0 , sizeof(maxn));

	f(i,m)
	{
		int ah,bh;
		cin >> ah >> bh;

		maxn[ah] = max(maxn[ah],a[bh]);
		maxn[bh] = max(maxn[bh],a[ah]);
	}

	int cnt = 0 ;

	f1(i,n)
	{
		cnt+= (maxn[i] < a[i]);
	}

	cout<<cnt;
	return  0 ;
	
}




Measured memory_bytes: 5116
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repnc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
using Graph = vector<vector<int> >;

/* next combination */
int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
  int n,m;cin>>n>>m;
  Graph G(n);
  rep(i,m){
    int a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> v;
  rep(i,n-1){
    v.push_back(i+1);
  }
  int ans = 0;
  do{
    bool flag = true;
    if(find(G[0].begin(),G[0].end(),v[0])==G[0].end())continue;
    rep(i,n-2){
      vector<int>temp = G[v[i]];
      if(find(temp.begin(),temp.end(),v[i+1])==temp.end()){
        flag=false;
        break;
      }
    }
    if(flag) ans++;
  }while(next_permutation(v.begin(),v.end()));
  cout << ans << '\n';
        return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<long long> L(N), R(N);
		for(int i=0;i<N;i++) cin >> L[i] >> R[i];
		sort(L.rbegin(), L.rend());
		sort(R.begin(), R.end());
		vector<long long> sumL(N+1, 0);
		vector<long long> sumR(N+1, 0);
		for(int i=0;i<N;i++){
			sumL[i+1] = sumL[i] + 2 * L[i];
			sumR[i+1] = sumR[i] - 2 * R[i];
		}
		long long res = 0;
		for(int i=0;i<=N;i++){
			res = max(res, sumL[i] + sumR[i]);
			if(i+1 <= N){
				res = max(res, sumL[i] + sumR[i+1]);
				res = max(res, sumL[i+1] + sumR[i]);
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3328
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]
m=10**9+7
a.append(N+1)
def mul(a,b):
    c=[[0]*len(b[0])for i in range(len(a))]
    for i in range(len(a)):
        for k in range(len(b)):
            for j in range(len(b[0])):
                c[i][j]=(c[i][j]+a[i][k]*b[k][j])%m
    return c
def pow(a,n):
    b=[[0]*len(a) for i in range(len(a))]
    for i in range(len(a)):
        b[i][i]=1
    while 0<n:
        if n&1==1:
            b=mul(a,b)
        a=mul(a,a)
        n=n>>1
    return b                
if M==0:
  A=[[1,1],[1,0]]
  print(pow(A,N+1)[1][0])
elif M==1:
  A=[[1,1],[1,0]]
  print((pow(A,a[0])[1][0]*pow(A,N-a[0])[1][0])%m)
else:
  ans=1
  for i in range(M+1):
    A=[[1,1],[1,0]]
    if a[i]+1==a[i-1]:
      ans=0
      break
    if i==0:
      if a[i]!=1:
        ans=ans*pow(A,a[0])[1][0]
        ans=ans%m
    elif i==M:
      ans=ans*pow(A,a[i]-a[i-1]-1)[1][0]
      ans=ans%m
    else:
      ans=ans*pow(A,a[i]-a[i-1]-1)[1][0]
      ans=ans%m
  print(ans)

Measured memory_bytes: 12920
#include <iostream>

int main(){
    int time,h,m,s;
    std::cin >> time;
    h = time/60/60;
    m = (time-h*60*60)/60;
    s = time-h*60*60-m*60;

    std::cout << h << ":" << m << ":" << s << std::endl; 
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int Factrial(const int& n){
   int ans = 1;
   for(int i = 1; i <= n; i++){
      ans *= i;
   }
   return ans;
}

int main(){
   int A, B, K;
   cin >> A >> B >> K;
   int n = 1;
   int cnt = 0;
   for(int i = GCD(A, B); i > 0; i--){
      if(A % i == 0 && B % i == 0){
         cnt++;
         if(cnt == K){
            cout << i << endl;
            return 0;
         }
      }
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;


int main() {

	int n;
	cin >> n;

	int m = n * (n - 1) / 2 - n / 2;
	cout << m << endl;

	vvb path(n, vb(n, true));
	rep(i, n / 2) {
		path[i][(n / 2) * 2 - 1 - i] = false;
		path[(n / 2) * 2 - 1 - i][i] = false;
	}

	rep(i, n)rep(j, n) {
		if (i >= j)continue;
		if (path[i][j])cout << i + 1 << " " << j + 1 << endl;
	}

}

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

int main(){
  int N,W;
  cin >> N >> W;
  vector<int> w(N),v(N);
  for (int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  long long x=w[0];
  for (int i=0;i<N;i++){
    w[i]-=x;;
  }
  vector<vector<vector<long long>>> dp(N+1,vector<vector<long long>>(310,vector<long long>(N+1,0)));
  for (int i=0;i<N;i++){
    for (long long j=0;j<310;j++){
      for (int k=0;k<i+1;k++){
        dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
        if (j>=w[i]){
          dp[i+1][j][k+1]=max(dp[i+1][j][k+1],dp[i][j-w[i]][k]+v[i]);
        }
      }
    }
  }
  long long ans=0;
  for (long long i=0;i<310;i++){
    for (long long j=0;j<N+1;j++){
      if (i+x*j<=W){
        ans=max(ans,dp[N][i][j]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 26240
class uf():
    def __init__(self,n):
        self.root = [-1] * (n+1)

    def findroot(self,x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.findroot(self.root[x])
            return self.root[x]

    def unite(self,x,y):
        rootx = self.findroot(x)
        rooty = self.findroot(y)
        if rootx == rooty:
            return
        else:
            self.root[rootx] += self.root[rooty]
            self.root[rooty] = rootx
            return

    def is_same_group(self,x,y):
        return self.findroot(x) == self.findroot(y)

N,M = map(int, input().split())
P = list(map(int, input().split()))

uf = uf(N)

for _ in range(M):
    x,y = map(int, input().split())
    uf.unite(x,y)

count = 0
for n in range(N):
    if uf.is_same_group(P[n],n+1):
        count += 1

print(count)

Measured memory_bytes: 14452
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









int main() {
    ll ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << (ab * bc) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
  
/* ループ系(全て最初から最後まで範囲に含む) */  
#define repd(i,a,b) for (int i=(a);i<=(b);i++)
#define rep(i,n) repd(i,0,n)
#define repv(i,v) for(int i=0;i < (int)(v).size();i++)
#define repvR(i,v) for(int i=(int)(v).size() - 1;i >= 0;i--)
#define REP(i,n) for(int i=0; i<=(n); i++)
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define FORR(i,a,b) for(int i=(b); i>=(a); i--)

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  ll ans=0;
  ll tmp;
  int N,M; cin >> N >> M;
  ll K; cin >> K;
  vector<ll>A(N,0);
  repv(i,A){cin >> tmp; if(i==0){A[i]=tmp;}else{A[i]=A[i-1]+tmp;}} 
  vector<ll>B(M,0);
  repv(i,B){cin >> tmp; if(i==0){B[i]=tmp;}else{B[i]=B[i-1]+tmp;}} 

  int onlyA=0, onlyB=0;
  repvR(i,A){if(A[i]<=K){onlyA=i+1;break;}}
  repvR(i,B){if(B[i]<=K){onlyB=i+1;break;}}

  ans = max(onlyA,onlyB);
  int tmpM=M-1;
  repv(i,A){
      if(K<A[i]){break;}
      FORR(j,0,tmpM){
          if(A[i]+B[j]<=K){
              ll ans_tmp=i+j+2;
              ans=max(ans,ans_tmp);tmpM=j;break;}
      }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6424
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

l = [A,B,C,D,E]
m = [i%10 for i in l if i%10!=0 ]
if len(m) == 0:
  sub = 0
else:
  sub = 10 - min(m)
M = []
for i in l:
  if i%10 == 0:
    M.append(i)
  else:
    M.append(((i//10)+1)*10)
print(sum(M)-sub)



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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), S(N + 1, 0);
    ll MOD = 1e9 + 7;
    rep(i, N) {
        cin >> A[i];
        S[i + 1] = (S[i] + A[i]) % MOD;
    }
    ll ans = 0;
    rep(i, N) {
        ans = (ans + S[i] * A[i]) % MOD;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6420
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int n, x, t;
  cin >> n >> x >> t;

  int ans = ((n + x - 1) / x) * t;
  printf("%d\n", ans);
  
}


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

int mod = 26;

char fun(int x){
    
    if (x == 1) return 'a';
    if (x == 2) return 'b';
    if (x == 3) return 'c';
    if (x == 4) return 'd';
    if (x == 5) return 'e';
    if (x == 6) return 'f';
    if (x == 7) return 'g';
    if (x == 8) return 'h';
    if (x == 9) return 'i';
    if (x == 10) return 'j';
    if (x == 11) return 'k';
    if (x == 12) return 'l';
    if (x == 13) return 'm';
    if (x == 14) return 'n';
    if (x == 15) return 'o';
    if (x == 16) return 'p';
    if (x == 17) return 'q';
    if (x == 18) return 'r';
    if (x == 19) return 's';
    if (x == 20) return 't';
    if (x == 21) return 'u';
    if (x == 22) return 'v';
    if (x == 23) return 'w';
    if (x == 24) return 'x';
    if (x == 25) return 'y';
    if (x == 26) return 'z';

    return 'E';
}

int main(){
    
    long i, N;
    cin >> N;

    int X[20] = {};
    int count = 0;
    
    while(N > 0){
        
        if (N % mod == 0){
            
            X[count] = mod;
            N = N / mod - 1;
            count++;

        } else {
            X[count] = N % mod;
            N /= mod;
            count++;
        }
    }
    
    for (i = 0; i < count; i++){
        
        cout << fun(X[count - 1 - i]);
    }
    
    cout << "\n";

    return 0;
}



Measured memory_bytes: 3132
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
  
	//文字列から10進数に変換するときはparseIntを使います
	var a = input[0].charAt(0).toUpperCase();
	var b = input[1].charAt(0).toUpperCase();
	var c = input[2].charAt(0).toUpperCase();

    //判定
  	var answer = a + b + c;

	console.log('%s',answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = list(input())
	if N[0] == "7" or N[1] == "7" or N[2] == "7":
		print("Yes")
	else:
		print("No")



if __name__ == '__main__':
	main()

Measured memory_bytes: 64692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

int main() {
  double n,d;
  cin >> n >> d;
  cout << ceil(n/(2*d+1)) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x=0;
    int n;
    cin>>n;
    char s[n];
    int max=0;
    for(int i=0;i<n;i++){
            cin>>s[i];
    }
    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            x++;
            if(max<=x){
                max=x;
            }
        }
        else if(s[i]=='D'){
            x--;
            if(max<=x){
                max=x;
            }
        }
    }
   // cout<<x;
    cout<<max;
}


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

int main() {
  string n; cin >> n;
  string ans;
  for (int i = 0; i < n.length(); i++) {
    if (n[i]=='1') {
      ans += '9';
    }
    else ans += '1';
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

int n;
lint p, q, a[100005];
lint d12[100005], d21[100005];
int lo1[100005], lo2[100005];

struct seg{
	lint tree[100010];
	void add(int x, lint v){
		while(x <= n+5){
			tree[x] += v;
			tree[x] %= mod;
			x += x & -x;
		}
	}
	lint query(int x){
		lint ret = 0;
		while(x){
			ret += tree[x];
			ret %= mod;
			x -= x & -x;
		}
		return ret;
	}
	lint query(int s, int e){
		if(s > e) return 0;
		return (query(e) - query(s-1) + mod) % mod;
	}
}bit1, bit2;

int main(){
	cin >> n >> p >> q;
	for(int i=1; i<=n; i++){
		scanf("%lld",&a[i]);
	}
	int l1 = n, l2 = n;
	if(p > q) swap(p, q);
	for(int i=n; i; i--){
		if(a[i+1] - a[i] < p) l1 = i;
		if(a[i+1] - a[i] < q) l2 = i;
		lo1[i] = l1;
		lo2[i] = l2;
	}
	lint ret = 0;
	for(int i=n; i>1; i--){
		if(lo1[i] == n) d21[i] = 1;
		if(lo2[i] == n) d12[i] = 1;
		int lb1 = lower_bound(a+1, a+n+1, a[i-1] + p) - a;
		int lb2 = lower_bound(a+1, a+n+1, a[i-1] + q) - a;
		lb1 = max(lb1, i+1);
		lb2 = max(lb2, i+1);
		d12[i] += bit2.query(lb1, lo2[i] + 1);
		d21[i] += bit1.query(lb2, lo1[i] + 1);
		d12[i] %= mod;
		d21[i] %= mod;
		bit1.add(i, d12[i]);
		bit2.add(i, d21[i]);
		if(lo1[1] >= i-1) ret += d12[i];
		if(lo2[1] >= i-1) ret += d21[i];
	}
	if(lo1[1] == n) ret += 1;
	if(lo2[1] == n) ret += 1;
	ret %= mod;
	cout << ret % mod << endl;
}


Measured memory_bytes: 4992
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
ABCDE = [A, B, C, D, E]
print(-(-N//min(ABCDE)) + 4)


Measured memory_bytes: 13092
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s[6][3];
  while(cin>>s[0][0],s[0][0]!="#"){

    for(int i=1;i<18;i++)cin>>s[i/3][i%3];

    if((s[0][2][0]=='*'||s[0][2][1]=='*'||s[0][2][2]=='*')&&(s[2][2][0]=='*'||s[2][2][1]=='*'||s[2][2][2]=='*'))cout<<0<<endl;

    else if((s[0][0][0]=='*'||s[0][1][0]=='*'||s[0][2][0]=='*')&&(s[2][0][2]=='*'||s[2][1][2]=='*'||s[2][2][2]=='*')||
            (s[0][0][2]=='*'||s[0][1][2]=='*'||s[0][2][2]=='*')&&(s[2][0][0]=='*'||s[2][1][0]=='*'||s[2][2][0]=='*')||
            (s[4][0][0]=='*'||s[4][0][1]=='*'||s[4][0][2]=='*')&&(s[5][2][0]=='*'||s[5][2][1]=='*'||s[5][2][2]=='*')||
            (s[4][2][0]=='*'||s[4][2][1]=='*'||s[4][2][2]=='*')&&(s[5][0][0]=='*'||s[5][0][1]=='*'||s[5][0][2]=='*'))cout<<1<<endl;

    else if((s[0][0][0]=='*'||s[0][0][1]=='*'||s[0][0][2]=='*')&&(s[2][0][0]=='*'||s[2][0][1]=='*'||s[2][0][2]=='*')||
            (s[1][0][0]=='*'||s[1][1][0]=='*'||s[1][2][0]=='*')&&(s[3][0][2]=='*'||s[3][1][2]=='*'||s[3][2][2]=='*')||
            (s[1][0][2]=='*'||s[1][1][2]=='*'||s[1][2][2]=='*')&&(s[3][0][0]=='*'||s[3][1][0]=='*'||s[3][2][0]=='*')||
            (s[4][0][0]=='*'||s[4][1][0]=='*'||s[4][2][0]=='*')&&(s[5][0][0]=='*'||s[5][1][0]=='*'||s[5][2][0]=='*')||
            (s[4][0][2]=='*'||s[4][1][2]=='*'||s[4][2][2]=='*')&&(s[5][0][2]=='*'||s[5][1][2]=='*'||s[5][2][2]=='*'))cout<<2<<endl;

    else cout<<3<<endl;
  }
}

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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 1000


using namespace std;

using ll =long long;
using P = pair<int,int>;


 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main() {

ios::sync_with_stdio(false);
cin.tie(0);
int k;
cin>>k;
string s;
cin>>s;

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


}

//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;

Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  int K, N, a, b = 0, s;
  cin >> K >> N;
  int max_len = 0;
  ll r = 0;

  // 最初の分
  cin >> b;
  s = b;

  rep(i, N-1){
    cin >> a;
    r += a - b;
    max_len = max(max_len, a - b);
    b = a;
  }
  // 最後の分
  max_len = max(max_len, abs(K - b) + s);
  
  cout << K - max_len << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main() {
  ll N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];
  UM<ll,ll> um; REP(i,N) um[A[i]]+=1;
  ll cnt=0;
  for(auto i:um) if(i.second%2) cnt++;
  cout<<cnt<<endl;
}


Measured memory_bytes: 5156
#include<cmath>
#include<cstdio>
#include<iostream>
#define ll long long
using namespace std;
int main() {
	ll H, cnt=0, sum=0;
	scanf("%lld",&H);
	while(H) {
		sum+=pow(2,cnt);
		H/=2;
		cnt++;
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=1000;
typedef struct P { int x,y; } P;

int n;
P s,t;
P p[MAXN]; int r[MAXN];

double best[MAXN];
priority_queue<pair<double,int> > pq;

double dst(const P &a,int ra,const P &b,int rb) {
	int dx=a.x-b.x,dy=a.y-b.y;
	double d=sqrt(1.0*dx*dx+1.0*dy*dy);
	if(d<=ra+rb) return 0;
	return d-ra-rb;
}

void run() {
	scanf("%d%d%d%d",&s.x,&s.y,&t.x,&t.y);
	scanf("%d",&n);
	REP(i,n) scanf("%d%d%d",&p[i].x,&p[i].y,&r[i]);

	REP(i,n) best[i]=dst(s,0,p[i],r[i]),pq.push(MP(-best[i],i));
	double ret=dst(s,0,t,0);
	while(!pq.empty()) {
		double cur=-pq.top().first; int at=pq.top().second; pq.pop();
		if(cur>best[at]+1e-9) continue;
		//printf("%d = %lf\n",at,best[at]);
		double now=cur+dst(p[at],r[at],t,0); if(now<ret) ret=now;
		REP(to,n) {
			double nxt=cur+dst(p[at],r[at],p[to],r[to]);
			if(nxt<best[to]) best[to]=nxt,pq.push(MP(-best[to],to));
		}
	}
	printf("%.9lf\n",ret);
}

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


Measured memory_bytes: 4464
#include<stdio.h>
#include<string.h>
#include<math.h>
long long sum(long long x){
return x*(x+1)/2;}

int main(){

long long n,k;

scanf("%lld%lld",&n,&k);

long long a,ans=0;
for(a=k;a<=n;a++){
 ans+=sum(n)-sum(n-a)-sum(a-1)+1;
}

printf("%lld\n",(ans+1)%1000000007);

return 0;}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,t; cin >> n >> t;
	vl a(n),b(n);
	rep(i,n) cin >> a[i] >> b[i];
	vvl dp(n+1,vl(t+1,0));
	vvl ep(n+1,vl(t+1,0));
	rep(i,n){
		rep(j,t+1){
			dp[i+1][j] = dp[i][j];
			if(j-a[i] >= 0) chmax(dp[i+1][j],dp[i][j-a[i]]+b[i]);
		}
	}
	ll ans = 0;
	for(ll i=n-1; i>=0; i--){
		rep(j,t){
			chmax(ans,b[i]+dp[i][j]+ep[i+1][t-1-j]);
		}
		rep(j,t+1){
			chmax(ans,dp[i][j]+ep[i+1][t-j]);
		}
		rep(j,t+1){
			ep[i][j] = ep[i+1][j];
			if(j-a[i] >= 0) chmax(ep[i][j],ep[i+1][j-a[i]]+b[i]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 141184
c1_list = list(map(int, input().split()))
c2_list = list(map(int, input().split()))
c3_list = list(map(int, input().split()))

for a1 in range(0, 101):
    for a2 in range(0, 101):
        for a3 in range(0, 101):
            b1 = c1_list[0] - a1
            b2 = c1_list[1] - a1
            b3 = c1_list[2] - a1
            if c2_list[0] == a2+b1 and c2_list[1] == a2+b2 \
                    and c2_list[2] == a2 + b3 and c3_list[0] == a3 + b1 \
                    and c3_list[1] == a3 + b2 and c3_list[2] == a3 + b3:
                print("Yes")
                exit()
print("No")

Measured memory_bytes: 3064
S = list(input())

s1 = int(S[0] + S[1])
s2 = int(S[2] + S[3])

if s1 <= 12 and s1 >= 1 and s2 <= 12 and s2 >= 1:
    print('AMBIGUOUS')
elif (s1 <= 12 and s1 >= 1) and (s2 == 0 or s2 >= 13):
    print('MMYY')
elif (s2 <= 12 and s2 >= 1) and (s1 == 0 or s1 >= 13):
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include <tuple>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};




int main()
{
    int N;
    cin >> N;
    ll a[N];
    
    REP(i,0,N){
        cin >> a[i];
    }
    ll ans = a[0];
    REP(i,1,N){
        ans ^= a[i];
    }
    if(ans==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

#define MAX 10000
#define NIL -1

struct Node{
  int parent, left, right;
};

struct Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL){
    h1 = setHeight(T[u].left) + 1;
  }
  if(T[u].right != NIL){
    h2 = setHeight(T[u].right) + 1;
  }
    return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
    return T[T[u].parent].left;
  }
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
    return T[T[u].parent].right;
  }
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }
  else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

int main(){
  int i, v, l, r, root = 0;
  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) T[i].parent = NIL;

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d",&v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(i = 0 ; i < n ; i++){
    if(T[i].parent == NIL) root = i;
  }

  setDepth(root, 0);
  setHeight(root);

  for(i = 0 ; i < n ; i++) print(i);

  return 0;
}


Measured memory_bytes: 2048
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
//#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 50+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/
int a[MAX_N];
main(){
    fast();per(0);
    //get_fact();
    int n;cin>>n;
    int minn=0,maxx=0;
    vector<int> vec[2];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]>a[maxx])
            maxx=i;
        if(a[i]<a[minn])
            minn=i;
        vec[(a[i]>0)].pb(i);
    }
    //cout<<"GOT"<<endl;
    bool ok=1;
    if(maxx==0)
        ok=0;
    vector<pii> ans;
    int nmax=a[maxx],nmin=a[minn];
    //cout<<nmax<<" "<<maxx<<"   "<<nmin<<" "<<minn<<endl;
    if(maxx!=0&&minn!=0){
        if(nmax<=abs(nmin)){
            ok=0;
            for(int x:vec[1])
                a[x]+=nmin
                ,ans.pb({minn,x})/*,cout<<minn<<" "<<x<<endl*/;
        }
        else
            for(int x:vec[0])
                a[x]+=nmax,ans.pb({maxx,x})/*,cout<<maxx<<" "<<x<<endl*/;
    }
    /*for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";
    cout<<endl;
    cout<<"OUT"<<endl;*/
    if(!ok){
        for(int i=n;i>=2;i--)
            if(a[i-1]>a[i])
                a[i-1]+=a[i],
                ans.pb({i,i-1});
    }
    else{
        for(int i=2;i<=n;i++)
            if(a[i-1]>a[i])
                a[i]+=a[i-1],
                ans.pb({i-1,i});
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x.F<<" "<<x.S<<endl;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e3+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
}
int n,k;
void input()
{
	n=read<int>(),k=read<int>();
}
const int mo=1e9+7;
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
int dp[N][N][2];
void work()
{
	dp[n+1][0][0]=1;
	Fordown(i,n+1,2)
	{
		Fordown(j,n,0)add(dp[i][j][0],dp[i][j+1][0]);
		For(j,0,n)For(o,0,1)
		{
			add(dp[i-1][j+1][1],dp[i][j][o]);
			add(dp[i-1][j][0],dp[i][j][o]);
		}
	}
	int ans=dp[1][n-k][0];
	For(i,1,n-k-1)ans=(ans*2)%mo;
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}

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

int main()
{
    string word1,word2;
    cin >> word1;
    cin >> word2;
    int L[1100][1100];
    int flag=1;
    for(int i=0;i<=word1.size();i++)
       L[i][0]=i;
    for(int j=0;j<=word2.size();j++)
       L[0][j]=j;
    for(int i=1;i<=word1.size();i++)
       for(int j=1;j<=word2.size();j++)
       {
           int min;
           if(word1[i-1]==word2[j-1])
             flag=0;
           min=L[i-1][j]+1;
           if(L[i][j-1]+1<min)
             min=L[i][j-1]+1;
           if(L[i-1][j-1]+flag<min)
             min=L[i-1][j-1]+flag;
           flag=1;
           L[i][j]=min;
       }
       cout << L[word1.size()][word2.size()] << endl;
}


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

using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n][3];
	int dp[n][3];
	for(int i=0;i<n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	dp[0][0]=a[0][0]; dp[0][1]=a[0][1];  dp[0][2]=a[0][2];
	for(int i=1;i<n;i++){
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
	}
	int ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	cout<<ans<<endl;
}
	

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	map<ll,ll> cnt;
	for (ll x: a) cnt[x]++;

	ll total = 0;
	for (auto pr: cnt) total += pr.yy*(pr.yy-1) / 2;

	for (ll x: a) {
		ll cur = total - cnt[x] + 1;
		cout << cur << endl;
	}
}



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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    vector<int> b(m);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin>>b[i];
    }
    vector<int> ans(n,0);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            if(a[j]<=b[i]) {
                ++ans[j];
                break;
            }
        }
    }
    int mx=-1;
    int as;
    for (int i = 0; i < n; ++i) {
        if(mx<ans[i]){
            mx=ans[i];
            as=i;
        }
    }
    cout<<as+1<<endl;
    return 0;
}


Measured memory_bytes: 3104
from math import gcd
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    K = int(readline())

    ans = 0
    for i in range(1,K+1):
        for j in range(1,K+1):
            for k in range(1,K+1):
                ans += gcd(gcd(i, j), k)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
import copy
def mise(times, temp, time, n):
    mise_time = 1000
    n += 1
    time1 = time
    for i in range(len(temp)):
        temp1 = copy.copy(temp)
        time1 = time
        time1 += temp1.pop(i)
        if n == len(times):
            return time1
        while True:
            if time1 % 10 == 0:
                break
            time1 += 1
        temp_time = mise(times, temp1, time1, n)
        if temp_time < mise_time:
            mise_time = temp_time
    return mise_time

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

times = [a, b, c, d, e]
timess = 1000
for i in range(len(times)):
    time = 0
    temp = copy.copy(times)    
    temp_time = mise(times, temp, time, 0)
    if temp_time < timess:
        timess = temp_time
print(timess)




Measured memory_bytes: 3444
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    //ll ans = 0;
    //ll C, D;
    //C = A[0];
    //D = B[0];
    //REP(i, 1, N) {
    //    C = (A[i] + C) / 2;
    //    D = (B[i] + D) / 2;
    //}
    ll ans;
    if (N % 2 == 1) {
        ans = (B[B.size() / 2] - A[A.size() / 2] + 1);
    }
    else {
        int add = 0;
        int Amed = (A[N / 2] + A[N / 2 - 1]);
        int Bmed = (B[N / 2] + B[N / 2 - 1]);
        //if ((A[N / 2] + A[N / 2 - 1]) % 2 == 1&&(B[N / 2] + B[N / 2 - 1]) % 2 == 1) add++;
        ans = ((Bmed - Amed)  + 1);

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

Measured memory_bytes: 6300
function bomb(x){
   var L=0;
   while(L!=x.length){
      L=x.length;
      x=x.replace(/1111+|2222+|3333+/,"");
   }
   if(min>x.length)min=x.length;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var N=Arr.shift()-0;
   if(N==0)break;
   var arr=[];
   for(var i=0;i<N;i++){
      var v=Arr.shift()-0;
      arr.push(v);
   }
   var min=Infinity;
   var str=arr.join("");
   for(var i=0;i<N;i++){
      if(i<N)bomb(str.slice(0,i)+arr[i+1]+str.slice(i+1,str.length));
      if(i>0)bomb(str.slice(0,i)+arr[i-1]+str.slice(i+1,str.length));
   }
   console.log(min);
}

Measured memory_bytes: 17436