akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long M = 1e9+7;
long long power(long long a, long long p)
    {
        if(p==0) return 1;
        long long ans= power(a,p/2);
        ans =(ans * ans) % M;
        if(p%2) ans = (ans*a) % M;
        return ans;
    }

    bool isPrime(long long n)
    {
        if (n <= 1)
            return false;
        for (long long i = 2; i < n; i++)
            if (n % i == 0)
                return false;
        return true;
    }
    long long SieveOfEratosthenes(long long n, long long a)
    {
        bool prime[n+1];
        memset(prime, true, sizeof(prime));
        for (long long p=2; p*p<=n; p++)
        {
            if (prime[p] == true)
            {
                for (long long i=p*p; i<=n; i += p)
                    prime[i] = false;
            }
        }
        for (long long p=2; p<=n; p++)
           if (prime[p])
           {
               if(a%p==0)
               {
                   return (a-p);
               }
           }
    }
    long long nCr(int n, int r)
    {
        if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
        long long ans = 1;
        int i;
        for(i = 1; i <= r; i++) {
            ans *= n - r + i;
            ans /= i;
        }
        return ans;
    }
int main()
{
    IOS;
    long long a,b,c,d,e,h,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
    // vector<string>vs;
    // vector<string>vs1;
    vector<char>vc;
    //map<long long,long long>mp;
    map<char,int>mp1;
    //set<long long>s;
    set<long long>s1;
    queue<long long> q;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
    // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    int x[]={1,1,1,0,0,-1,-1,-1};
    int y[]={0,1,-1,1,-1,1,-1,0};
    cin>>n;
    a=n%500;
    b=n/500;
    c=a/5;
    cout<<(b*1000)+(c*5)<<endl;
    return 0;
}


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

int main(){
   int N;
   std::cin >> N;
   std::vector<int> d(N);
   for(int i=0; i<N; ++i)
      std::cin >> d[i];

   std::sort(d.begin(),d.end());

   std::cout << d[N/2] - d[N/2-1] << std::endl;
   return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if (a == b && b == c && c == d) cout << "yes" << endl;  
  else if (a == b && c == d) cout << "yes" << endl;
  else if (a == c && b == d) cout << "yes" << endl;
  else if (a == d && b == c) cout << "yes" << endl;
  else cout << "no" << endl;

 return 0;
}



Measured memory_bytes: 3120
n,k=map(int, input().split())
a=list(map(int, input().split()))
b=[False]*n
pos=0
for i in range(min(n,k)):
    if b[pos]!=False:
        loop=i-b[pos]+1
        break
    b[pos]=i+1
    pos=a[pos]-1
    k-=1
if k>0:
    for i in range(k%loop):
        pos=a[pos]-1
print(pos+1)

Measured memory_bytes: 32348
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<int32_t, int32_t>;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int32_t seconds;
  cin >> seconds;
  int32_t minutes = seconds / 60;
  seconds %= 60;
  int32_t hour = minutes / 60;
  minutes %= 60;
  cout << hour << ":" << minutes << ":" << seconds << endl;

  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int MOD;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
const int MAXN = 6005;
Mint fac[MAXN];
int main() {
	int n;
	scanf("%d%d", &n, &MOD);
	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = fac[i - 1] * i;
	Mint ans = 0;
	for (int n3 = 0; n3 <= n; ++n3) {
		for (int n2 = 0; n2 <= n - n3; ++n2) {
			int n1 = 3 * n - 3 * n3 - 2 * n2;
			Mint add = fac[3 * n];
			add /= modex(Mint(3), n3);
			add /= modex(Mint(2), n2);
			add /= fac[n3] * fac[n2] * fac[n1];
			ans += add;
		}
	}
	printf("%d\n", ans.val);
}

Measured memory_bytes: 384
n = int(input())
h = list(map(int, input().split()))

Max = 0
start = 0
# cnt = 0
while start < n-1:
    # print(f"start = {start}")
    # cnt += 1
    count = 0
    for i in range(start+1, n):
        if h[i] <= h[i-1]:
            count += 1
        else:
            break
    Max = max(Max ,count)
    start = i
    # if cnt > 10:
    #     break
print(Max)


Measured memory_bytes: 14252
from itertools import permutations

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

a,b = 0, 0

for i,x in enumerate(permutations(range(1,N+1))):
    if P == x: a=i
    if Q == x: b=i

print(abs(a-b))

Measured memory_bytes: 3188
n,k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
ans = 0
p = a.index(1)+1
i,j = (n-p+k-2)/(k-1),(p+k-2)/(k-1)
if n-(i+j-2)*(k-1)-1 <= k
  ans -= 1
end
ans += i+j
puts ans

Measured memory_bytes: 8708
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    map<int, int> m;
    REP(i, N){
        int a;
        cin >> a;
        m[a/400]++;
    }
    int ans = 0;
    REP(i, 8){
        if(m[i]>0)ans++;
    }
    int over = 0;
    Rep(i, 8, 20){
        over += m[i];
    }
    pr((ans?:1), ans + over);
}


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

int main (void)
{
    char a[1000] = {0};
    char b[1000] = {0};
    int i;
    int na,nb;
    scanf("%s %s",a,b);

    na = strlen(a);
    nb = strlen(b);

    if(na < nb ){
        printf("LESS\n");
    }else if(na > nb){
        printf("GREATER\n");
    }else{
        for(i=0;i<na;i++){
            if(a[i] > b[i]){
                printf("GREATER\n");
                break;
            }else if(a[i] < b[i]){
                printf("LESS\n");
                break;
            }
            if((i == na-1) && (a[i] == b[i]) ){
                printf("EQUAL\n");
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
Bs = list(mapint())

ap = 0
bp = 0
for a, b in zip(As, Bs):
    if a>b:
        ap += a-b
    else:
        bp += (b-a)//2
if ap>bp:
    print('No')
else:
    print('Yes')

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

// B - Golden Coins
int main() {
    long long X;
    cin >> X;
    long long sum = 0;
    long long tmp;
    tmp = (X / 500);
    sum += tmp * 1000;
    tmp = (X % 500) / 5;
    sum += tmp * 5;
    cout << sum;
}


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

// 数値を逆順に並び替える
int reverse(int num)
{
    int rev = 0;
    while (num > 0) {
        rev = rev * 10 + num % 10;
        num /= 10;
    }
    return rev;
}

int main(){
    int A, B;
    cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; i++) {
        if (i == reverse(i)) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w, n;
ll ans[10];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> h >> w >> n;
    map<P, int> p;
    rep(i, 0, n) {
        int x, y;
        cin >> x >> y;
        rep(j, 0, 3) rep(k, 0, 3) {
            int va = x-j, vb = y-k;
            if (va <= 0 || h < va + 2 || vb <= 0 || w < vb + 2) continue;
            p[mp(va, vb)]++;
        }
    }
    fill(ans, ans+10, 0);
    ans[0] = (ll)(h-2)*(w-2);
    for (auto itr = p.begin(); itr != p.end(); itr++) {
       ans[itr->second]++;
       ans[0]--;
    }
    rep(i, 0, 10) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 56576
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;

int main(){
    int n,a[101];
    cin>>n;
    rep(i,0,n)cin>>a[i];
    
    int cnt=0,ans=0;
    rep(i,1,n){
        if(a[i]==a[i-1]){
            cnt++;
            if(i==n-1)ans+=(cnt+1)/2;
        }
        else {
            ans+=(cnt+1)/2;
            cnt=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
  string w;
  cin >> w;
  if(w.size()%2 ==1){
   cout << "No" <<endl;
    return 0;
  }
  vector<char> E = {'q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m'};
 vector<pair<char,int>> M(26);
  for(int i=0;i<26;i++)M[i] =  make_pair (E[i],0);
  for(int i=0;i<w.size();i++){
   for(int j=0;j<26;j++){
    if(M[j].first == w[i]) M[j].second++; 
   }
  }
  bool f = true;
  for(int i=0;i<26;i++){
   if(M[i].second%2 ==1) f = false; 
  }
  if(f) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 //動画解答例写し
int main(){
  int x,n;
  cin>>x>>n;
  vector<int>d(102);
  for(int i=0;i<n;i++){
    int p;
    cin>>p;
    d[p]=1;
  }
  pair<int,int>ans(99999,-1);
  for(int i=0;i<=101;++i){
    if(d[i]==1)continue;
    int dif=abs(x-i);
    ans=min(ans,pair<int,int>(dif,i));
  }
  cout<<ans.second<<endl;
  return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int kinds, people;
  cin >> kinds >> people;
  map<int, int> all;
  for(int i = 0; i < people; i++){
    int get;
    cin >> get;
    while(get--){
      int get2;
      cin >> get2;
      all[get2]++;
    }
  }
  cout << kinds - all.size();
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


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;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	VE b(n);
	rep(i, n) {
		b[i] = a[i] - (i + 1);
	}
	sort(ALL(b));
	int tmp = b[n / 2];
	int ans = 0;
	rep(i, n) {
		ans += abs(a[i] - (tmp + i+1));
	}
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder.Contests.ABC170
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var xs = ReadIntArray();
            for (int i = 0; i < xs.Length; i++)
            {
                if (xs[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    return;
                }
            }

        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 27996
N = int(input())
B = list(map(int, input().split()))

count = 0
out = 0
for i in range(N-1):
  if count == 0:
    count += 1
    out += B[i]
  else:  
    out += min(B[i-1],B[i])

out += B[N-2]
    
print(out)
    

Measured memory_bytes: 3060
from sys import exit
def muri():
    print(-1)
    exit()

L = list(map(int, input()))
N = len(L)
if L.pop():
    muri()
if not L[0]:
    muri()
if L != L[::-1]:
    muri()
if N == 2:
    print(1, 2)
    exit()

Ans = []
M = [i for i, l in enumerate(L, 1) if l] 
K = [0] + [m2 - m1 - 1 for m1, m2 in zip(M, M[1:])] + [0]
p = 1
for _ in range(len(M)):
    Ans.append((p, p+1))
    p += 1
p += 1
for j, k in enumerate(K, 1):
    for _ in range(k):
        Ans.append((j, p))
        p += 1

for a in Ans:
    print(*a)


Measured memory_bytes: 56284
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

bool solve(int start, int n, int m, int a[]);

int main()
{
    int n;
    cin >> n;
    int A[20];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    sort(A, A + n);
    int q;
    cin >> q;
    int m;
    for(int i = 0; i < q; i++){
        cin >> m;
        if(solve(0, n, m, A)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

bool solve(int start, int n, int m, int a[])
{
    bool ans = false;
    for(int i = start; i < n; i++){
        if(a[i] == m) ans = true;
        else if(a[i] < m) ans = solve(i + 1, n, m - a[i], a);
        if(ans == true) break;
    }
    return ans;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> tmp(h+2, vi(w+2));

    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#'){
                for(int k = -1; k <= 1; k++){
                    if(i == 0 && k == -1) continue;
                    for(int l = -1; l <= 1; l++){
                        if(j == 0 && l == -1) continue;
                        tmp[i+k][j+l]++;
                    }
                }
            }
        }
    }

    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#'){
                cout << '#';
            }else{
                cout << tmp[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
//DP, map<26bit, sorted_vector>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

string s;
unordered_map<int, vector<int> > poses;
int keys[200001];

void setPoses() {
	int cnt[26] = {0};
	int i, j;
	
	for (i = 0; i <= s.length(); i++) {
		int key = 0;
		for (j = 0; j < 26; j++) {
			if (cnt[j]) {
				key += (1 << j);
			}
		}
		
		if (poses.find(key) == poses.end()) {
			poses[key] = vector<int>();
		}
		poses[key].push_back(i);
		keys[i] = key;
		
		cnt[s[i] - 'a']++;
		cnt[s[i] - 'a'] %= 2;
	}
}

int hantenBit(int a, int pos) {
	if ((a >> pos) & 1) {
		return a - (1 << pos);
	}
	return a + (1 << pos);
}

int dp[200001];	//dp[文字数] = 最小分割数

int main() {
	cin >> s;
	setPoses();
	
	int i, j, k;
	
	for (i = 0; i <= s.length(); i++) dp[i] = 11451419;
	dp[0] = 0;
	
	for (i = 0; i < s.length(); i++) {
		int id = lower_bound(poses[keys[i]].begin(), poses[keys[i]].end(), i) - poses[keys[i]].begin();
		if (!(id == 0 || id == (int)poses[keys[i]].size() - 1)) continue;
		
		//偶分割
		if (poses.find(keys[i]) != poses.end()) {
			vector<int> &tmp = poses[keys[i]];
			int offset = upper_bound(tmp.begin(), tmp.end(), i) - tmp.begin();
			for (k = offset; k < tmp.size(); k++) {
				dp[tmp[k]] = min(dp[tmp[k]], dp[i] + 1);
			}
		}
		
		//奇分割
		for (j = 0; j < 26; j++) {
			//keys[i]のjビット目を反転
			int key = hantenBit(keys[i], j);
			if (poses.find(key) != poses.end()) {
				vector<int> &tmp = poses[key];
				int offset = upper_bound(tmp.begin(), tmp.end(), i) - tmp.begin();
				for (k = offset; k < tmp.size(); k++) {
					dp[tmp[k]] = min(dp[tmp[k]], dp[i] + 1);
				}
			}
		}
	}
	
	cout << dp[s.length()] << endl;
	return 0;
}


Measured memory_bytes: 22392
N = int(input())
a = [int(i) for i in input().split()]
ls = [0 for i in range(N+1)]
for i, x in enumerate(a[::-1]):
    num = N - i
    s = 0
    for j in range(num, N+1, num):
        if ls[j] == 1:
            s += 1
    if s%2 == x:
        ls[num] = 0
    else:
        ls[num] = 1
print(sum(ls))
b = []
for i in range(N+1):
    if ls[i] == 1:
        b.append(i)
print(*b)


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

#define l_ength size

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

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

int d[100100];
ll v[100100];

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

int main(void){
	int n,i;
	ll ans=1ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> d[i];
		++v[d[i]];
	}
	if(d[0] != 0){
		cout << "0" << endl;
		return 0;
	}
	for(i=1; i<n; ++i){
		if(!d[i]){
			cout << "0" << endl;
			return 0;
		}
		mul_mod(ans,v[d[i]-1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
package main

import (
    "bufio"
    "fmt"
    "os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
  var s string
  if sc.Scan() {
    s = sc.Text()
  }
  
  if s == "ABC"{
    fmt.Println("ARC")
  }else{
    fmt.Println("ABC")
  }
}

Measured memory_bytes: 1752
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d)cout<<"Left"<<endl;
	else if(a+b<c+d)cout<<"Right"<<endl;
	else cout<<"Balanced"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int main(){
	int n; cin>>n;
	int b[100002]={};
	int m=INF;
	FOR(i,0,n){
		int a; cin>>a;
		b[a]++;
		m=min(a,m);
	}
	int c[2];
	c[0]=b[m];
	c[1]=b[m+1];
	if(c[0]+c[1]!=n){
		Yes(0);
	}else if(c[1]){
		Yes(c[0]<=m&&c[0]+c[1]/2>=m+1);
	}else{
		Yes(m==n-1||m<=n/2);
	}
}


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

int main() {
    int n, r;
    cin >> n >> r;

    if (n < 10) cout << 100 * (10 - n) + r << endl;
    else cout << r << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
using ld = long double;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    ll a, b;
    cin >> a >> b;
    cout << (a*b) << '\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


Measured memory_bytes: 3636
object Main {
  def main(args:Array[String]){
    val sc=new java.util.Scanner(System.in)
    try{
      while(true){
        val x=sc.nextInt;val kigo=sc.next;val y=sc.nextInt
        kigo match{
          case "+"=>println(x+y)
          case "-"=>println(x-y)
          case "*"=>println(x*y)
          case "/"=>println(x/y)
          case _=>throw new Exception
        }
      }
    }
    catch{
      case _:Exception=>()
    }
  }
}

Measured memory_bytes: 45108
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,ok;

string s,l,r;

signed main()
{
    cin>>s;
    cin>>n;
    int op,x;char ch;
    int fz = 0;
    for(int i = 1; i <= n; i++) 
    {
        cin>>op;
        if(op == 1)
        {
            fz ^= 1;
        }
        else
        {
            cin>>x>>ch;
            if(x == 1)      //前面
            {
                if(fz)
                {
                    r += ch;
                }
                else
                {
                    l = ch + l;
                }
            }
            else
            {
                if(fz)
                {
                    l = ch+l;
                }
                else
                {
                    r += ch;
                }
            }
        }
    }
    if(fz)
    {
        reverse(r.begin(),r.end());
        reverse(s.begin(),s.end());
        reverse(l.begin(),l.end());
        cout<<r<<s<<l<<endl;
    }
    else
    {
        cout<<l<<s<<r<<endl;
    }
    return 0;
}

Measured memory_bytes: 1104
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>

using namespace std;

int main() {
	char op;
	int a, b;
	while (true) {
		cin >> a >> op >> b;
		if (op == '?')break;
		switch (op) {
		case '+':cout << a + b << endl; break;
		case '-':cout << a - b << endl; break;
		case '*':cout << a * b << endl; break;
		case '/':cout << a / b << endl; break;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <typeinfo>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

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

int main()
{
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<vector<double>> dist(N, vector<double>(N));

  for (int i = 0; i < N; i++)
  {
    double X, Y;
    cin >> X >> Y;
    x[i] = X;
    y[i] = Y;
  }

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      double d = pow(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2), 0.5);
      dist[i][j] = d;
      dist[j][i] = d;
    }
  }

  double sum = 0;

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

  do
  {
    double d = 0;
    for (int i = 0; i < N - 1; i++)
    {
      d += dist[order[i]][order[i + 1]];
    }
    sum += d;
  } while (next_permutation(order.begin(), order.end()));

  cout << setprecision(10) << sum / fact(N) << endl;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();

		long cnt=0;
		for (int i=0;i<N+1;i++) {
			for (int j=0;j<N+1;j++) {
				if ((N-R*i-G*j)>=0 && (N-R*i-G*j)%B==0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    
    int ans = 0;
    int mn = min(x, y);
    if(2*c < a) a = 2*c;
    if(2*c < b) b = 2*c;
    
    if(2*c < a + b) cout << mn * 2*c + (x - mn) * a + (y - mn) * b << endl;
    else cout << mn * (a + b) + (x - mn) * a + (y - mn) * b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n/100==7)
	{
		cout<<"Yes";
		return 0;
	}
	if((n%100)/10==7)
	{
		cout<<"Yes";
		return 0;
	}
	if(n%10==7)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
} 

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

int main(){
  int n,ansx,ansy,ansh,cnt=0;
  cin >> n;
  int x[n],y[n],h[n],m=0;
  for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> h[i];
  for(int i=0;i<n;i++){
    if(h[i]!=0){
      m = i;
      cnt++;
    }
  }
  if(cnt==1){
    cout << x[m] <<' '<< y[m] <<' '<< h[m] << endl;
    return 0;
  }
  for(int j=0;j<=100;j++){
    for(int k=0;k<=100;k++){
        int H = abs(x[m]-j)+abs(y[m]-k)+h[m];
        bool a=1;
    	for(int i=0;i<n;i++){
          if(h[i]==0) continue;
          else{
            if(H!=abs(x[i]-j)+abs(y[i]-k)+h[i]) a = 0;
          }
    	}
        if(a&&1<=H){
          ansh=H;
          ansx=j;
          ansy=k;
        }
  	}
  }
  cout << ansx <<' '<< ansy <<' '<< ansh << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[]) 
{
	int N, Q;
	int p[200005], x[200005];
	int par[200005] = {0};
	ll val[200005] = {0};

	cin >> N >> Q;

	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		par[b] = a;
	}
	for (int i = 0; i < Q; i++) {
		cin >> p[i] >> x[i];
		p[i]--;
	}

	for (int i = 0; i < Q; i++) {
		val[p[i]] += x[i];
	}

	for (int i = 1; i < N; i++) {
		val[i] += val[par[i]];
	}

	for (int i = 0; i < N; i++) {
		printf("%lld ", val[i]);
	}

	puts("");

	return 0;
}

Measured memory_bytes: 6272
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val r = sc.nextInt()

    var i = 0
    if( n >= 10) {
        i = r
    }
    else {
        i = r + 100 * ( 10 - n)
    }
    println(i)
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 29476
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 0<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct Node { int from, to, cost; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	int n;
	string s;
	cin >> n >> s;
	if(n>= 3200){
		cout << s << endl;
	} else{
		cout << "red" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
/**
 *      ABC 47 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-22 13:44:45
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int W, H, N; cin >> W >> H >> N;
    int x[N] = {}; int y[N] = {}; int a[N] = {};
    for (auto i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> a[i];
    }
    int s[W][H] = {};
    for (auto i = 0; i < W; ++i) {
        for (auto j = 0; j < H; ++j) {
            s[i][j] = 1;
        }
    }

    for (auto i = 0; i < N; ++i) {
        if (a[i] == 1){
            for (auto j = 0; j < x[i]; ++j) {
                for (auto k = 0; k < H; ++k) {
                    s[j][k] = 0;
                }
            }
        }
        else if (a[i] == 2){
            for (auto j = x[i]; j < W; ++j) {
                for (auto k = 0; k < H; ++k) {
                    s[j][k] = 0;
                }
            }            
        }
        else if (a[i] == 3){
            for (auto j = 0; j < W; ++j) {
                for (auto k = 0; k < y[i]; ++k) {
                    s[j][k] = 0;
                }
            }
        }
        else if (a[i] == 4){
            for (auto j = 0; j < W; ++j) {
                for (auto k = y[i]; k < H; ++k) {
                    s[j][k] = 0;
                }
            }
        }
    }

    int answer = 0;

    for (auto i = 0; i < W; ++i) {
        for (auto j = 0; j < H; ++j) {
            answer += s[i][j];
        }
    }
    cout << answer << endl;

    return 0;
}



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

int main(){
  int a,b;
  cin >> a >> b;
  if (a >= 13) cout << b << endl;
  if (a >= 6 && a <= 12) cout << 0.5*b << endl;
  if (a <= 5) cout << 0 << endl;

  return 0;
  
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct unionfind{
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int main()
{
    int n, m, k;
	cin>>n>>m>>k;
	int a[100010], b[100010], c[100010], d[100010];
	unionfind uf(n);
	for(int i=0; i<m; i++){
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
		if(a[i]>b[i]) swap(a[i], b[i]);
		uf.unite(a[i], b[i]);
	}
	for(int i=0; i<k; i++){
		cin>>c[i]>>d[i];
		c[i]--; d[i]--;
		if(c[i]>d[i]) swap(c[i], d[i]);
	}
	vector<int> v;
	for(int i=0; i<n; i++){
		v.push_back(uf.find(i));
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	int ans[100010]={};
	for(auto x:v){
		ll cnt=uf.size(x);
		ans[x]+=cnt;
	}
	int myon[100010]={};
	for(int i=0; i<k; i++){
		if(uf.same(c[i], d[i])){
			myon[c[i]]++; myon[d[i]]++;
		}
	}
	for(int i=0; i<m; i++){
		myon[a[i]]++; myon[b[i]]++;
	}
	for(int i=0; i<n; i++) cout<<ans[uf.find(i)]-myon[i]-1<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 4472
N=int(input()) 
e = [[int(i) for i in input().split()] for i in range(N)] 
import itertools
seq = list(itertools.permutations(e))


def diff(x1,y1,x2,y2):
  return ((x1-x2)**2+(y1-y2)**2)**0.5

l = 0
for i in seq:
  for j in range(1,N):
    l += diff(i[j][0],i[j][1],i[j-1][0],i[j-1][1])
print(l/len(seq))
  

Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>;


using namespace std;



int main() {
    string str;
    getline(cin, str);
    for (int i = 0; i < str.size(); i++) {
        if (str[i] >= 'a' && 'z' >= str[i]) {
            printf("%c", str[i] - 32);
        }
        else if (str[i] >= 'A' && 'Z' >= str[i]) {
            printf("%c", str[i] + 32);
        }
        else {
            cout << str[i];
        }
    }
    cout << endl;

}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

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

    bool ok = true;
    for (int i = 1; i < n; i++) {
        if (a[i - 1] > a[i]) ok = false;
    }
    if (ok) {
        cout << 0 << endl;
        return 0;
    }

    vector<P> res;
    int idx = 0, mx = 0;
    for (int i = 0; i < n; i++) {
        if (mx < abs(a[i])) {
            idx = i;
            mx = abs(a[i]);
        }
    }

    for (int i = 0; i < n; i++) {
        res.pb(mp(idx, i));
    }
    if (a[idx] > 0) {
        for (int i = 0; i < n - 1; i++) {
            res.pb(mp(i, i + 1));
        }
    } else {
        for (int i = n - 1; i >= 1; i--) {
            res.pb(mp(i, i - 1));
        }
    }

    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) {
        cout << res[i].first + 1 << " " << res[i].second + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 99999999

using namespace std;


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





ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
ll m = 10000007;
ll p[10], c[10];
int main() {
	int D, G;
	cin >> D >> G;
	REP(i, D) {
		cin >> p[i] >> c[i];
	}
	ll ans = INF;
	bool used[10];
	REP(i, 10)used[i] = false;
	for (int x = 0; x < myPow(2,D,m); x++) {
		int sum = 0;
		ll cnt = 0;
		for (int i = 0; i < D; i++) {
			if (x&(1 << i)) {
				used[i] = true;
				sum += 100 * (i + 1)*p[i] + c[i];
				cnt += p[i];
			}
		}
		if (sum >= G) {
			ans = min(ans, cnt);
		}
		else {
			REPR(i, D-1) {
				if (!used[i]) {
					REP(j, p[i]+1) {
						sum += 100 * (i + 1);
						cnt++;
						if (sum >= G) {
							ans = min(ans, cnt);
							break;
						}
					}
				}
			}
		}
		REP(i, 10)used[i] = false;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# coding utf-8
import math

N, K = map(int, input().rstrip().split())

H = list(map(int, input().rstrip().split()))
H.sort()

if N > K:
    if K == 0:
        ans = sum(H)
    else:
        ans = sum(H[:-K])
else:
    ans = 0

print(ans)


Measured memory_bytes: 27300
#include "bits/stdc++.h"
using namespace std;
const int INF = 1 << 30;

int main() {
	int Q;
	cin >> Q;
	priority_queue<long long> zen;
	long long zensum = 0;
	priority_queue<long long, vector<long long>, greater<long long> > kou;
	long long kousum = 0;
	long long B = 0;
	for (int i = 0; i < Q; ++i) {
		int num;
		cin >> num;
		if (1 == num) {
			long long x, y;
			cin >> x >> y;
			B += y;
			if (0 == (zen.size() + kou.size())) {
				zen.push(x);
				zensum += x;
				continue;
			}
			if (1 == (zen.size() + kou.size())) {
				long long z = zen.top();
				zen.pop();
				zensum -= z;
				vector<long long>X = { z,x };
				sort(X.begin(), X.end());
				zen.push(X[0]);
				zensum += X[0];
				kou.push(X[1]);
				kousum += X[1];
				continue;
			}
			if (zen.size() == kou.size()) {
				long long z = zen.top();
				zen.pop();
				zensum -= z;
				long long w = kou.top();
				kou.pop();
				kousum -= w;
				vector<long long>X = { z,x,w };
				sort(X.begin(), X.end());
				zen.push(X[0]);
				zensum += X[0];
				zen.push(X[1]);
				zensum += X[1];
				kou.push(X[2]);
				kousum += X[2];
			}
			else {
				long long z = zen.top();
				zen.pop();
				zensum -= z;
				long long w = kou.top();
				kou.pop();
				kousum -= w;
				vector<long long>X = { z,x,w };
				sort(X.begin(), X.end());
				zen.push(X[0]);
				zensum += X[0];
				kou.push(X[1]);
				kousum += X[1];
				kou.push(X[2]);
				kousum += X[2];
			}
		}
		else {
			long long x = zen.top();
			long long y = B + x * zen.size() - zensum + kousum - x * kou.size();
			cout << x << " " << y << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5064
import sys
import math
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

N = SORO_INT()
A = MULT_INT_LIST()
X = sorted(A)
if A == X:
    print('YES')
    sys.exit()


i = 0
count=0
for i in range(N):
    if count>2:
        print('NO')
        sys.exit()
    
    if A[i]==i+1:
        count = count
    else:
        count+=1

print('YES')

Measured memory_bytes: 3064
list_str = [str(e) for e in input().split()]
list_num = [int(e) for e in input().split()]
drop = [str(e) for e in input().split()]
if drop[0] == list_str[0]:
    list_num[0] = list_num[0]-1
elif drop[0] == list_str[1]:
    list_num[1] = list_num[1]-1
print('{} {}'.format(list_num[0], list_num[1]))

Measured memory_bytes: 3064
k = int(input())
s = list(map(int,'1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(',')))
print(s[k-1])


Measured memory_bytes: 2940
A,B = (int(x) for x in input().split())

sum = 0
if(A < B):
	sum += B
	B-=1
else:
	sum += A
	A-=1
    
if(A < B):
	sum += B
	B-=1
else:
	sum += A
	A-=1

print (sum)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int n,i;
	int p,d1,d2;
	int sum;
	int max,m;
	scanf("%d",&n);
	while(n!=0){
		max=0;
		m=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&p,&d1,&d2);
			sum=d1+d2;
			if(max<sum){
				max=sum;
				m=p;
			}
		}
		printf("%d %d\n",m,max);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"
using namespace std;
void solve(){
    int n;
    cin >> n;
    bool d = false;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == n){
                d = true;
                break;
            }
        }
        if(d)
        break;
    }
    if(d)
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256