akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 1050;
const int mod = (int) 1e9 + 7;

int n;
int a, b, c, d;
int f[MAXN];
int dp[MAXN][MAXN];
int g[MAXN][MAXN];

int addMod(int a, int b) {
  int sum = a + b;
  return sum >= mod ? sum - mod : sum;
}

int subMod(int a, int b) {
  int res = a - b;
  return res < 0 ? res + mod : res;
}

long long binpow(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res = (res * x) % mod;
      p--;
    } else {
      x = (x * x) % mod;
      p /= 2;
    }
  }
  return res % mod;
}

long long inv(long long x) {
  return binpow(x, mod - 2) % mod;
}

long long getC(int n, int k) {
  long long res = 1ll * f[n] * inv(f[n - k]) % mod;
  res = 1ll * res * inv(f[k]) % mod;
  return res;
}

int main() { 

  cin >> n >> a >> b >> c >> d;

  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = 1ll * f[i - 1] * i % mod;
  }
  
  dp[a - 1][0] = 1;
  for (int i = a; i <= b; i++) {
    dp[i][0] = 1;

     g[i][0] = 1;
    for (int j = 1; j <= n; j++) {
      if (j < i) {
        g[i][j] = 1;
      } else {
        g[i][j] = 1ll * g[i][j - i] * getC(j - 1, i - 1) % mod;
      }
    }

    for (int j = 1; j <= n; j++) {
      dp[i][j] = dp[i - 1][j];

       for (int k = j - c * i; k >= 0 && k >= j - d * i; k -= i) {
        long long x = 1ll * dp[i - 1][k] * g[i][j - k] % mod;
        x = x * getC(j, j - k) % mod;
        dp[i][j] = (dp[i][j] + x) % mod;
      }

      // cerr << i << " " << j << " " << dp[i][j] << endl;
    } 
  }

  cout << dp[b][n] << endl;

  return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  ll a, b;
  std::cin >> a >> b;
  ll aa = a, bb = b;
  ll sqa = sqrt(a) + 1, sqb = sqrt(b) + 1;
  set<ll> ans;
  for (ll i = 2; i <= sqa; i++) {
    if (aa % i == 0 && b % i == 0)
      ans.insert(i);
    while (aa % i == 0)
      aa /= i;
  }
	if (aa > 1 && b % aa == 0)
		ans.insert(aa);
  for (ll i = 2; i <= sqb; i++) {
    if (a % i == 0 && bb % i == 0)
      ans.insert(i);
    while (bb % i == 0)
      bb /= i;
  }
	if (bb > 1 && a % bb == 0)
		ans.insert(bb);
  std::cout << ans.size() + 1 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  bool ok = true;
  if (S[A] != '-') ok = false;
  for (int i = 0; i < A; i++) {
    if(S[i]!='1'&&S[i]!='2'&&S[i]!='3'&&S[i]!='4'&&S[i]!='5'&&S[i]!='6'&&S[i]!='7'&&S[i]!='8'&&S[i]!='9'&&S[i]!='0') ok = false;
  }
  for (int i = A+1; i < A+B+1; i++) {
    if(S[i]!='1'&&S[i]!='2'&&S[i]!='3'&&S[i]!='4'&&S[i]!='5'&&S[i]!='6'&&S[i]!='7'&&S[i]!='8'&&S[i]!='9'&&S[i]!='0') ok = false;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
A, B, C, K = map(int, input().split())
max_ans = 0
if K <= A:
    max_ans = K
    print(max_ans)
else:
    max_ans = A
    L = K-A #Aを除いた残りの枚数
    if L <= B:
        max_ans += L*0
        print(max_ans)
    else:
        max_ans += B*0
        M = L-B
        max_ans -= M
        print(max_ans)    

Measured memory_bytes: 61668
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

int main()
{
    int n, l;
    cin >> n >> l;
    int sum = (n * (2 * l + n - 1)) / 2;
    //cout << sum << endl;
    if (l >= 0)
    {
        sum -= l;
    }
    else
    {
        if (l + n - 1 < 0)
            sum -= l + n - 1;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

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

    vi L(N);
    int sum = 0;
    rep(i, N) {
        cin >> L[i];
        sum += L[i];
    }

    sort(all(L));
    int max = L[L.size() - 1];
    if (max < sum-max) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main(){
   ll N;
   cin >> N;

   for(ll h = 1; h <= 3500; h++) {
       for(ll n = 1; n <= 3500; n++) {
           if(4*h*n - N*n - N*h > 0 && N*h*n%(4*h*n - N*n - N*h) == 0) {
               cout << h << " " << n << " " << N*h*n/(4*h*n-N*n-N*h) << endl;
               return 0;
           }
       }
   }

}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    #include <numeric>
    #include <utility>
    #include <cmath>
    #include <vector>
    #include <queue>
    #include <string>
    #include <map>
    #define MAX_U   10
    #define MIN_U   0
    #define rep(i,n) for(int i=0;i<n;i++)
    #define sz(x) ((int)(x).size())
    using namespace std;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<char> vc;
    typedef vector<string> vs;
    typedef queue<int> qi;
    const int INF=numeric_limits<int>::infinity();
    void printa(){cout<<"\n";}
    template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
    template<class... A>void printa(const A&... rest){printa(rest...);}
    void prints(){cout<<" ";}
    template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
    template<class... A>void prints(const A&... rest){prints(rest...);}
    int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
    int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
    int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
    double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
    double trapezium(int a,int b,int h){return (a+b)*h/2;}
    double triangle(int a,int h){return a*h/2;}
    int main(void){
        cin.tie(0);
        ios::sync_with_stdio(false);
        int x,a,b;
        cin >>x>>a>>b;
        if(b-a<=0)printa("delicious");
        else if(b-a<=x)printa("safe");
        else printa("dangerous");
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ullong = unsigned long long;

int main()
{
    int N; cin >> N;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    ullong ans;
    ullong M = N - 1;
    ans = (M * (M + 1)) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
var n,i,d,dem:longint;
a,dau:array [00..1000] of longint;
begin
        readln(n);
        for i:=1 to n do
                begin
                read(a[i]);
                inc(dau[(a[i]) div 400 +1]);
                if a[i]>3199 then inc(d);
                end;
        for i:=1 to 8 do
                if dau[i]<>0 then inc(dem);
        if dem=0 then write(1,' ',dem+d)
        else
        write(dem,' ',dem+d);

end.


Measured memory_bytes: 128
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

s = S()
ans = "x"*len(s)
print(ans)


Measured memory_bytes: 63852
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<pair<int, int>>vs;
		for (int i = 0; i < N; ++i) {
			int x, y; cin >> x >> y;
			vs.emplace_back(x, y);
		}
		sort(vs.begin(), vs.end());
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				int dx = vs[j].first - vs[i].first;
				int dy = vs[j].second - vs[i].second;
				bool ok = true;
				{
					pair<int, int>p(vs[i].first - dy, vs[i].second + dx);
					if (!binary_search(vs.begin(), vs.end(), p))ok = false;
				}
				{
					pair<int, int>p(vs[j].first - dy, vs[j].second + dx);
					if (!binary_search(vs.begin(), vs.end(), p))ok = false;
				}
				if (ok)ans = max(ans, dx*dx + dy*dy);
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
//typedef long double ld;
//#define for(i,s,e) for(lli i=s;i<=e;i++)
//#define forr(i,e,s) for(lli i=e;i>=s;i--)
#define pb push_back
#define eq push
#define dq pop
#define f front
#define inf 100000000
int main()
{
lli k,x;
cin>>k>>x;
for(lli i=x-(k-1);i<=x+(k-1);i++)
	cout<<i<<" ";
 return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
  
    ll ans = 0;
    Rep(i,N) ans += (i+1)*(N-i);
  
    ll a,b;
    Rep(i,N-1){
      Scll2(a,b);
      if( a>b ) swap(a,b);
      ans -= a*(N-b+1);
    }
  
    printf("%lld\n", ans );

    return 0;
}



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

void dfs(vector<int> &digit, vector<bool> &op_buf, vector<bool> &op, int pos, int sum){

    if((pos == 4) && (sum == 7)){
        op = op_buf;
        return;
    }
    if(pos == 4) return;

    op_buf.at(pos-1) = true;
    dfs(digit, op_buf, op, pos+1, sum+digit.at(pos));
    op_buf.at(pos-1) = false;
    dfs(digit, op_buf, op, pos+1, sum-digit.at(pos));
}

int main(){

    int num;
    cin >> num;

    vector<int> digit(4); 
    vector<bool> op(4); 
    vector<bool> op_buf(4); 
    for(int i=3; i>=0; i--){
        int temp = num%10;
        digit.at(i) = temp;
        num /= 10;
    }

    int sum = digit.at(0), pos = 1;
    dfs(digit, op_buf, op, pos, sum);
    
    for(int i=0; i<3; i++){
        cout << digit.at(i);
        if(op.at(i)==true) cout << '+';
        if(op.at(i)==false) cout << '-';
    }
    cout << digit.at(3) << "=7" << endl;;

    return 0;
}

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

string FMT_F = "%.10f";

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

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

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

void main()
{
	auto N = RD;
	
	writeln((N+1) * N / 2);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h> 
int main()
{double jiao,jiao1,jiao2,Pi,L;
int A,B,H,M;
	Pi=acos(-1);
	scanf("%d%d%d%d",&A,&B,&H,&M);
	jiao1=(H+M/60.0)/12.0*2*Pi;
	jiao2=M/60.0*2*Pi;
	jiao=fabs(jiao1-jiao2);
	L=sqrt(A*A+B*B-2*A*B*cos(jiao));
	printf("%.20f",L);
	return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;

}

Node treeMaximum(Node x){
  while(x->right!=NIL) x=x->right;
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;

  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);
  
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
    return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right == NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent = y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y!=z) z->key=y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL) root =z;
  else if(z->key<y->key) y->left=z;
  else (y->right = z);
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19360
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string s;
  	cin >> s;
  	int counter = 0;
  	if(s[0]=='1') counter++;
	if(s[1]=='1') counter++;
	if(s[2]=='1') counter++;
	cout << counter << endl;
}

Measured memory_bytes: 256
$N=<>;
@P=grep{(1x$_)!~/^(11+)\1+$/}2..$N;
for$i(1..$N){
	for$p(@P){
		$c=0;
		while($i%$p==0){
			$i/=$p;
			++$c
		}
		$c[$p]+=$c
	}
}
$z=0;
for$a(2..$N){
	$z+=$c[$a]>=74;
	for$b(2..$N){
		if($a!=$b){
			$z+=$c[$a]>=4&&$c[$b]>=14;
			$z+=$c[$a]>=2&&$c[$b]>=24;
			for$c($b+1..$N){
				if($a!=$c){
					$z+=$c[$a]>=2&&$c[$b]>=4&&$c[$c]>=4;
				}
			}
		}
	}
}
print$z


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<ll> v(n);
    ll mn = 1LL << 60;
    ll mx = (1LL << 60) * -1;
    int mni,mxi;

    auto ifmax = [&](int i) {
            if (mx < v[i]) {
            mx = v[i];
            mxi = i;
            }
        };
    auto ifmin = [&](int i) {
            if (mn > v[i]) {
                mn = v[i];
                mni = i;
            }
        };

    REP(i,n) {
        cin >> v[i];
        ifmax(i);
        ifmin(i);
    }

    vector<pair<int,int>> p;
    
    if (mx < 0 || (abs(mx) < abs(mn))) {
        for (auto i = n-1; i >= 0 ; i--) {
            p.emplace_back(make_pair(mni+1,i+1));
        }
        for (auto i = n-1; i > 0 ; i--) {
            p.emplace_back(make_pair(i+1,i));
        }
    } else {
        for (auto i = 0; i < n ; i++) {
            p.emplace_back(make_pair(mxi+1,i+1));
        }
        for (auto i = 0; i < n-1 ; i++) {
            p.emplace_back(make_pair(i+1,i+2));
        }
    }

    cout << p.size() << endl;
    for(auto x:p) {
        cout << x.first << " " << x.second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main(){
    long long int x;
    cin >> x;
    long long int ans = 1000 * (x / 500) + 5 * ((x % 500) / 5);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	char fie[h][w];
	REP(i, 0, h){
		getchar();
		REP(j, 0, w) fie[i][j] = getchar();
	}

	
	bool used[h][w] = {};
	std::queue<PP> que;

	ll ans = 0;
	REP(i, 0, h) REP(j, 0, w) if(!used[i][j] and fie[i][j]=='#') {
		ll bla = 0, whi = 0;
		que.emplace(0, P(i, j));
		while(!que.empty()){
			auto [d, p] = que.front();
			que.pop();
			if(used[p.fi][p.se]) continue;
			used[p.fi][p.se] = true;
			if(fie[p.fi][p.se]=='#') bla++;
			else whi++;
			REP(I, 0, 4){
				ll nx = p.fi+dx[I], ny = p.se+dy[I];
				if(nx<0 or h<=nx or ny<0 or w<=ny) continue;
				if(used[nx][ny] or fie[p.fi][p.se]==fie[nx][ny]) continue;
				que.emplace(d+1, P(nx, ny));
			}
		}
		ans += bla * whi;
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 4072
#include<iostream>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main() {
	char s[1145];
	cin >> s;
	int cnt = 0;
	int hantei = 0;
	if (s[0] == 'A') {
		for (int i = 2; i < strlen(s)-1; i++) {
			if (s[i] == 'C') cnt++;
		}
		if (cnt == 1) {
			for (int i = 0; i < strlen(s); i++) {
				if (s[i] >= 'A'&&s[i] <= 'Z') cnt++;
			}
			if (cnt == 3) {
				hantei = 1;
			}
		}
	}
	if (hantei) cout << "AC" << endl;
	else cout << "WA" << endl;
}

Measured memory_bytes: 256
N = int(input())
L = [list(map(int, input().split())) for k in range(N)]
L = [[0,0,0]] + L
for k in range(1,N+1):
    if (L[k][0]-L[k-1][0])%2 != (abs(L[k][1]-L[k-1][1])+abs(L[k][2]-L[k-1][2]))%2 or L[k][0]-L[k-1][0] < abs(L[k][1]-L[k-1][1])+abs(L[k][2]-L[k-1][2]):
        print("No")
        exit(0)
print("Yes")


Measured memory_bytes: 28092
n=int(input())
l=list(map(int,input().split()))

ans=0

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
                if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]:
                    ans+=1

print(ans)

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

int main(){
	char n[1000]; cin>>n; int len=strlen(n);
	for(int i=0;i<len;i++)
		if(n[i]=='9'){
			cout<<"Yes"<<endl;
			return 0;
		}
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define INF 2e9
#define LLINF 11e16
 
using namespace std;
 
typedef long long ll;

int main(){
	int n;
	cin >> n;
	
	vector<ll> v(n);
	
	rep(i ,n) cin >> v[i];
	rep_r(i , n-1){
		if(v[i] - 1 == v[i + 1]){
			v[i]--;
		}
		else if(v[i] > v[i + 1]){
			cout << "No" << endl;
			return 0;
		}
	}
	
		
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


vector<vector<int>> v(4444);
bool used[777];
int c[777];
int cnt1,cnt2;

bool dfs(int p, int x){
    if(used[p]){
        if(c[p]!=x) return false;
        else return true;
    }
    c[p] = x;
    used[p] = 1;
    if(x) cnt1++;
    else cnt2++;
    bool ret = true;
    for(auto i:v[p]){
        ret &= dfs(i,x^1);
    }
    return ret;
}

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

    int n,m;
    cin>>n>>m;
    bool e[n][n]={};
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        e[a][b] = 1;
        e[b][a] = 1;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(e[i][j] == false){
                v[i].push_back(j);
                v[j].push_back(i);
            }
        }
    }
    vector<array<int,2>> ans;
    bool pos = 1;
    for(int i=0;i<n;i++){
        if(!used[i]){
            cnt1=0,cnt2=0;
            pos &= dfs(i,0);
            ans.push_back({cnt1,cnt2});
        }
    }
    if(!pos){
        cout << -1 << endl;
        return 0;
    }
    int h = ans.size();
    bool dp[h+1][n+1][2]={};
    dp[0][0][0]=1,dp[0][0][1]=1;
    for(int i=0;i<h;i++){
        for(int j=n;j>=0;j--){
            if(j+ans[i][0]<=n) dp[i+1][j+ans[i][0]][0] |= (dp[i][j][0] | dp[i][j][1]);
            if(j+ans[i][1]<=n) dp[i+1][j+ans[i][1]][1] |= (dp[i][j][0] | dp[i][j][1]);
        }
    }
    int totori = 1e9;
    for(int i=1;i<=n;i++){
        int ret = i*(i-1)/2 + (n-i)*(n-i-1)/2;
        if(dp[h][i][0] or dp[h][i][1]) chmin(totori,ret);
    }
    cout << totori << endl;
    

}

Measured memory_bytes: 3712
#include<iostream>
#include<string>

using namespace std;

int main(void){
    
    string A;

    cin >> A;
    string B;

    if (A=="Sunny")
    {
        B="Cloudy";
    }
    else if (A=="Cloudy")
    {
        B="Rainy";
    }
    else
    {
        B="Sunny";
    }

    cout << B <<endl;

    return 0;
}

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

int main(void)
{
    int A[3];  // A1, A2, A3
    int S[3];  // S12, S13, S23
    int MAX, SUM;
    int i;
        
    
    scanf("%d %d %d", &A[0], &A[1], &A[2]);
    
    
    S[0] = abs(A[0]-A[1]);
    S[1] = abs(A[0]-A[2]);
    S[2] = abs(A[1]-A[2]);
    
    MAX = SUM = S[0];
    
    for(i=1; i<3; i++)
    {
        SUM += S[i];
        
        if(MAX < S[i])
            MAX = S[i];
    }

    
    printf("%d\n", SUM-MAX);

    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> vec(q);
    for(int i=0;i<q;i++){
        cin>>vec.at(i);
    }
    int first=k-q;
    vector<int> ans(n,first);
    for(int i=0;i<q;i++){
        ans.at(vec.at(i)-1)++;
    }
    for(int i=0;i<n;i++){
        if(ans.at(i)>0){
            cout <<"Yes"<<endl;
        }
        else{
            cout <<"No"<<endl;
        }
    }
}


Measured memory_bytes: 1408
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<int,int>

vector<vector<int>> g;
vector<vector<int>> d;

int main()
{
    int n;
    cin >> n;
    g.resize(n);
    d.resize(2);
    d[0].assign(n, -1);
    d[1].assign(n, -1);
    for(int i = 0;i < n-1;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int from[] = {0,n-1};
    for(int i = 0;i < 2;i++)
    {
        queue<pii> q;
        q.push(make_pair(from[i],0));
        d[i][from[i]] = 0;
        while(!q.empty())
        {
            auto p = q.front();
            q.pop();
            auto t = p.first;
            auto dist = p.second + 1;
            for(auto e:g[t])
            {
                if(d[i][e] >= 0)
                {
                    continue;
                }
                q.push(make_pair(e, dist));
                d[i][e] = dist;
            }
        }
    }
    ll fc = 0;
    ll sc = 0;
    for(int i = 0;i < n;i++)
    {
        if(d[0][i] <= d[1][i])
        {
            fc++;
        }
        else
        {
            sc++;
        }
    }
    const string f = "Fennec";
    const string s = "Snuke";
    if(fc > sc)
    {
        cout << f << endl;
        return 0;
    }
    cout << s << endl;
    return 0;
    
}

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

inline void upmax(short &x,const short &y){if(y>x) x=y;}

const int N=105;
short f[N][N][N][N];
short sum1[N][N],sum2[N][N];
int n,m,tx,ty;

void gao()
{
	int limu=tx-1,limd=n-tx,liml=ty-1,limr=m-ty;
	for(int u=0;u<=limu;u++)
		for(int d=0;d<=limd;d++)
			for(int l=0;l<=liml;l++)
				for(int r=0;r<=limr;r++)
				{
					int L=max(ty-l,r+1),R=min(ty+r,m-l);
					if(L<=R)
					{
						upmax(f[u+1][d][l][r],f[u][d][l][r]+(tx-u-1>=d+1?sum1[tx-u-1][R]-sum1[tx-u-1][L-1]:0));
						upmax(f[u][d+1][l][r],f[u][d][l][r]+(tx+d+1<=n-u?sum1[tx+d+1][R]-sum1[tx+d+1][L-1]:0));
					}
					L=max(tx-u,d+1),R=min(tx+d,n-u);
					if(L<=R)
					{
						upmax(f[u][d][l+1][r],f[u][d][l][r]+(ty-l-1>=r+1?sum2[R][ty-l-1]-sum2[L-1][ty-l-1]:0));
						upmax(f[u][d][l][r+1],f[u][d][l][r]+(ty+r+1<=m-l?sum2[R][ty+r+1]-sum2[L-1][ty+r+1]:0));
					}
				}
	printf("%d\n",f[limu][limd][liml][limr]);
}

int main()
{
	static char s[105];
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
		{
			if(s[j]=='E') tx=i,ty=j;
			sum1[i][j]=sum1[i][j-1]+(s[j]=='o');
			sum2[i][j]=sum2[i-1][j]+(s[j]=='o');
		}
	}
	gao();
	return 0;
}

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

using namespace std;
typedef long long int ll;


int main()
{
   ll n,i,j,k,l,maxx=0;
   cin>>n;
   ll a[n+1];
   for(i=1;i<=n;i++)
   {
       cin>>a[i];
       if(a[i]>maxx)
       {
           maxx=a[i];
       }
   }
   i=-maxx;
   j=maxx;
   ll ans=0;
   while(i<=j)
   {
       ll mid=(i+j)/2;
       //cout<<mid<<endl;
       ll sum1=0,sum2=0,sum3=0;
       for(ll p=1;p<=n;p++)
       {
           sum1+=abs(a[p]-(mid+p));
           sum2+=abs(a[p]-(mid+1+p));
           sum3+=abs(a[p]-(mid-1+p));
       }
       //cout<<sum1<<" "<<sum2<<" "<<sum3<<endl;
       if(sum2>=sum1 && sum3>=sum1)
       {
           ans=sum1;
           break;
       }
       else if(sum2>sum1 && sum3<sum1)
       {
           j=mid-1;
       }
       else
       {
           i=mid+1;
       }
   }
   cout<<ans<<endl;


    return 0;
}

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

int main(){
  int l,r,d;
  cin >> l >> r >> d;
  int c = 0;
  for(int i=l;i<=r;i++){
    if(i%d==0) ++c;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

vector<int> split(string &s) {
  vector<int> a(4);
  for (int i = 0; i < 4; i++) {
    a[i] = atoi(s.substr(i,1).c_str());
  }
  return a;
}

int main () {
  string s;
  cin >> s;
  vector<int> a(4);
  a = split(s);
  
  for (int bit = 0; bit < (1<<3); bit++) {
    vector<int> v;
    for (int i = 0; i < 4; i++) {
      if (bit & (1<<i)) {
        v.push_back(i);
      }
    }
    
    vector<int> cv;
    cv = split(s);
    
    for (int i = 0; i < (int)v.size(); i++) {
      cv[v[i]+1] *= -1;
    }
    
    if (cv[0] + cv[1] + cv[2] + cv[3] == 7) {
      printf("%d%+d%+d%+d=7\n", cv[0], cv[1], cv[2], cv[3]);
      return 0;
    }

  }
  
}

Measured memory_bytes: 256
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

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


int main(){
	IOS;
	int x,y;
	cin>>x>>y;
	cout<<max({x+y,x-y,x*y});
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[101][1<<16];
int s[16];
int t[16];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<=a;i++)
			for(int j=0;j<(1<<16);j++)
				dp[i][j]=-1999999999;
		dp[0][0]=0;
		for(int i=0;i<a;i++){
			int b,c;
			scanf("%d%d",&b,&c);
			for(int j=0;j<b;j++)scanf("%d%d",s+j,t+j);
			for(int j=0;j<(1<<16);j++){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				bool ok=true;
				int to=j;
				for(int k=0;k<b;k++){
					for(int l=s[k];l<t[k];l++){
						if(j&(1<<(l-6)))ok=false;
						to|=(1<<(l-6));
					}
				}
				if(!ok)continue;
				dp[i+1][to]=max(dp[i+1][to],dp[i][j]+c);
			}
		}
		int ret=0;
		for(int i=0;i<(1<<16);i++)
			ret=max(ret,dp[a][i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 26884
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int x;
  cin >> x;
  int use = x / 100;
  int rem = x % 100;
  if (rem <= use * 5)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 3624
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)

	for i := range a {
		fmt.Scan(&a[i])
	}

	var c int
	for _, e := range a {
		if isPrime(e) {
			c++
		}
	}

	fmt.Println(c)
}

func isPrime(n int) bool {
	for i := 2; i <= int(math.Sqrt(float64(n))); i++ {
		if n % i == 0 {
			return false
		}
	}

	return true
}



Measured memory_bytes: 1760
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>
#include <fstream>
#include<list>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)


#define nl cout<<"\n";
#define ll long long int
#define mod  1000000007


using namespace std;

int main()
{

	ios :: sync_with_stdio(false);
	cin.tie(nullptr);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	string s;
	cin >> s;

	int l = 0, r = n - 1;
	while (s[l] == 'R')
	{
		l++;
	}
	while (s[r] == 'W')
	{
		r--;
	}

	int count = 0;

	while (l <= r)
	{
		if (s[l] == 'W' && s[r] == 'R')
		{
			count++;
			s[r] = 'W';
			s[l] = 'R';
			l++;
			r--;
		}
		else if (s[r] == 'W')
		{
			r--;
		}
		else if (s[l] == 'R')
		{
			l++;
		}
	}

	cout << count;

	return 0;
}


Measured memory_bytes: 3772
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            String s=scan.next();
            Map<String,Integer> map=new HashMap<>();
            map.put("SSS",0);
            map.put("SSR",1);
            map.put("SRS",1);
            map.put("SRR",2);
            map.put("RSS",1);
            map.put("RSR",1);
            map.put("RRS",2);
            map.put("RRR",3);
            out.println(map.get(s));
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 32348
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; 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 ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    ll a,b,k; cin >> a >> b >> k;
    REP(i,k) {
        if(i%2==0) {
            a = (a%2==1 ? a-1 : a);
            a /= 2;
            b += a;
        }
        else {
            b = (b%2==1 ? b-1 : b);
            b /= 2;
            a += b;
        }
    }
    cout << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 256
N,Y=map(int,input().split())
x=-1
y=-1
z=-1
for i in range(N+1):
        for j in range(N-i+1):
            if i*10000+j*5000+(N-(i+j))*1000==Y:
                x=i
                y=j
                z=N-i-j
                break
            
print(str(x)+" "+str(y)+" "+str(z))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/
void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}
int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;cin >> N;

    vector<int> P(N),Q(N);

    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];

    vector<int> a(N);
    rep(i,N) a[i] = i+1;


    int A = -1,B = -1,ct = 0;
    bool flag1,flag2;
    do{
        flag1 = true;
        flag2 = true;
        rep(i,N){
            if(a[i] != P[i]) flag1 = false;
            if(a[i] != Q[i]) flag2 = false;
        }

        if(flag1 && A == -1)A = ct;
        if(flag2 && B == -1)B = ct;
        ct++;
    }while(next_permutation(ALL(a)));

    cout << abs(A - B) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int A, B;
	cin >> A >> B;
	if (A + B >= 10) cout << "error" << endl;
	else cout << A + B << endl;
	return 0;
}



Measured memory_bytes: 256
S = input()
T = input()


def check(S,T):
    dic1 = {}
    dic2 = {}
    for s,t in zip(S,T):
        if s not in dic1:
            dic1[s] = t
            # dic2[s] = False
        elif dic1[s] != t:
            return False
    for k in dic1.keys():
        if list(dic1.values()).count(k) > 1:
            return False
        # if dic2[k]==False:
        #     mark = False
        #     first = k #最初の文字を記録する
        #     while True:
        #         dic2[k] = True
        #         k = dic1[k]
        #         if k not in dic1 or k == first: #辞書にない文字or最初の文字
        #             mark = True #OK
        #             break
        #         elif dic2[k] == True:
        #             break
        #     if mark == False:
        #         return False
    return True
            

if check(S,T):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n;
cin >> n;
vector<pair<ll,ll> > G[n+1];

rep(i, n-1)
{
    ll a,b,c;
    cin >> a>>b>>c;
    G[a].push_back(pair<ll,ll>(b, c));
    G[b].push_back(pair<ll,ll>(a, c));
}
ll cost[n+1];
rep(i,n+1){
    cost[i]=INF;
}
ll q,k;
cin >> q>>k;
queue<ll> qq;
qq.push(k);
cost[k]=0;

while(!qq.empty()){
    ll p = qq.front();
    qq.pop();
    rep(i,G[p].size()){
        if(cost[G[p][i].first]==INF){
            cost[G[p][i].first]=G[p][i].second+cost[p];
            qq.push(G[p][i].first);
        }
    }
}


rep(i,q){
    ll x,y;
    cin >> x>>y;
    cout << cost[x]+cost[y] << endl;
}
return 0;
}




Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc173/abc173_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }
  sort(c.begin(), c.end(), greater<ll>());

  ll ans = 0;
  int cnt = 1;
  int j = 0;
  repi(i, 1, N) {
    ans += c[j];
    cnt++;
    if (cnt == 2) {
      cnt = 0;
      j++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4776
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N,K;
	cin >> N>>K;
	//出力
	cout << N-K+1 << endl;
}


Measured memory_bytes: 256