akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define int ll

typedef pair<int, int> pii;
typedef pair<ll, ll> pll; 

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;  
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it )\
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(aint(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 
#define all(c) c.begin(), c.end() 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int gcd(int a, int b){
    if (b==0) return a;
    return gcd(b, a%b);
} 

int lcm(int fir, int sec){
    return (fir*sec)/(gcd(fir, sec));
}

const int MOD = 1988;
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(26) << f << '\n';

// sort(arr, arr+n, greater<int>());

const int maxN = 1e6 + 12;
// const int maxVal = pow(2, 11);

signed main(){
	int n, k;
	cin>>n>>k;
	if(n<=8 && k<=8){
		cout<<"Yay!"<<endl;
	}else{
		cout<<":("<<endl;
	}
}

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



int main(){
    string s,t,u;
    cin>>s;
    int n=s.length();
    bool ok=true;
    t=s;
    reverse(t.begin(),t.end());
    if(t!=s) ok=false;
    t=s.substr(0,(n-1)/2);
    u=t;
    reverse(u.begin(),u.end());
    if(t!=u) ok=false;
    t=s.substr((n+3)/2-1,(n-3)/2+1);
    u=t;
    reverse(u.begin(),u.end());
    if(t!=u) ok=false;
    cout<<(ok? "Yes": "No")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if(a * b > c * d){
	    printf("%d", a * b);
	}else{
	    printf("%d", c * d);
	}
    
}


Measured memory_bytes: 1708
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;

const int nax=52;
int M,N;
char A[52][52],B[52][52];
bool b=false,a=false;

int main(){
    scanf("%d %d",&N,&M);
    for(int i=0;i<N;i++){
                scanf("%s",&A[i]);
    }
    for(int i=0;i<M;i++){
                scanf("%s",&B[i]);
    }
    //printf("%s %s %d %d\n",A[0],B[0],N,M);
//--------------------------------------
    for(int i=0;i<N-M+1;i++){
        for(int j=0;j<N-M+1;j++){
                                b=false;
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(A[i+k][j+l]!=B[k][l]){
                        b=true;
                        break;
                    }
                }
                if(b){
                    break;
                }
            }

        if(!b){
            printf("Yes");
            return 0;
        }
        }

    }
    printf("No" );
        return 0;
}


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

int main() {
	int x, y;

	cin >> x >> y;

	if (x == 2 || y == 2) {
		cout << "No" << endl;
		return 0;
	}

	if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
		if (y == 4 || y == 6 || y == 9 || y == 11)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define pb push_back
#define all(a) (a).begin(),(a).end()
using namespace std;
int main()
{
    int a, l;
    while(cin >> a >> l, a | l) {
        vector<int> seq = {a};
        
        while(1) {
            a = seq.back();
            ostringstream oss;
            oss << setw(l) << setfill('0') << a;
            
            string maxi = oss.str();
            string mini = oss.str();
            
            sort(all(maxi), greater<char>());
            sort(all(mini));
            
            int na = stoi(maxi) - stoi(mini);
            
            auto it = find(all(seq), na);
            if (it != seq.end()) {
                int j = distance(seq.begin(), it);
                int i = seq.size();
                cout << j << " " << na << " " << (i - j) << endl;
                break;
            }
            seq.pb(na);
        }
    }
}

Measured memory_bytes: 3148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
  int key;
  struct Node *right, *left, *parent;
};
void insert(int f);
void inorder(struct Node *v);
void preorder(struct Node *w);
struct Node *root, *NIL;
int main(){
  char C[10];
  int n, i, x;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", C);
    if(strcmp(C, "insert") == 0){
      scanf("%d", &x);
      insert(x);
    } else if (strcmp(C, "print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } }
  return 0; }
void insert(int f){
  struct Node *x = root;
  struct Node *y = NIL;
  struct Node *z;
  z = ((struct Node *)malloc(sizeof(struct Node)));
  z->key = f;
  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(struct Node *v){
  if(v == NIL) return;
  inorder(v->left);
  printf(" %d", v->key);
  inorder(v->right);
}
void preorder(struct Node *w){
  if(w == NIL) return;
  printf(" %d", w->key);
  preorder(w->left);
  preorder(w->right);
}



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

int main(){

    int X;
    cin >> X;

    if (400 <= X, X < 600) cout << 8 << endl;
    else if (600 <= X, X < 800) cout << 7 << endl;
    else if (800 <= X, X < 1000) cout << 6 << endl;
    else if (1000 <= X, X < 1200) cout << 5 << endl;
    else if (1200 <= X, X < 1400) cout << 4 << endl;
    else if (1400 <= X, X < 1600) cout << 3 << endl;
    else if (1600 <= X, X < 1800) cout << 2 << endl;
    else if (1800 <= X, X < 2000) cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <queue>
using namespace std;
char field[114][514] = { {'#'} };
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
int white = 0;
int h, w;

struct kenusu {
	int step;
	int x;
	int y;
};

queue<struct kenusu> q;

int solve() {
	q.push({ 0, 1, 1 });
	while (!q.empty()) {
		const struct kenusu tmp = q.front();
		q.pop();

		if (field[tmp.y][tmp.x] != '.')
			continue;

		//cout << "現在" << '(' << tmp.x << ',' << tmp.y << ')' << endl;

		if (tmp.y == h && tmp.x == w) {//最短経路に関係するマス目の個数は最短経路長+1
			cout << white - tmp.step-1 << endl;
			return 0;
		}

		field[tmp.y][tmp.x] = '#';

		for (int d = 0; d < 4; ++d) {
			const struct kenusu a = { tmp.step + 1,tmp.x + dx[d],tmp.y + dy[d] };
			//cout << "追加:" << a.x << "," << a.y << "ステップ数:" << a.step << endl;;
			q.push(a);
		}
	}
	return 1;
}

int main() {
	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> field[i][j];
			white += field[i][j] == '.';
		}
	}
	if (solve()) {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	string s;
	cin >> s;

	if (s[0] == '9' or s[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def bubble_sort(array):
    isEnd = False
    count_swap = 0
    while isEnd is False:
        isEnd = True
        for j in reversed(range(1,len(array))):
            if array[j - 1] > array[j]:
                tmp = array[j - 1]
                array[j - 1] = array[j]
                array[j] = tmp
                count_swap += 1
                isEnd = False
    return count_swap

def print_array(array):
     print(str(array)[1:-1].replace(', ', ' '))

def main():
    N = int(input())
    array = [int(s) for s in input().split(' ')]
    count = bubble_sort(array)
    print_array(array)
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7748
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  sort(a,a+n);
ll  c=0;
  for(int i=0;i<n-2;i++)
  {
      int as=a[i];
      for(int j=i+1;j<n-1;j++)
      {
          int bs=a[j];
          for(int k=j+1;k<n;k++)
          {

            if(a[k]<as+bs)
            {
                if(a[k]+as>bs)
                {
                    if(a[k]+bs>as)
                        {
                            if(as!=bs && bs!=a[k] && a[k]!=as)
                            c++;
                        }
                }
            }
          }

      }

  }
  cout<<c;
  }


Measured memory_bytes: 3640
#  Copyright: this code was written at Dec 30th, 2019. for AtCoder, by Silviase
a, b, k = map(int, input().split())
if a + b < k:
    print("0 0")
elif a < k:
    print("0 " + str(a + b - k))
else:
    print(str(a-k) + " " + str(b))

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

using namespace std;
typedef long long ll;




int main()
{
    int a = 0;
    rep(i,4){
        char s;
        cin >> s;
        if(s=='+') a++;
        else a--;
        
    }
    cout << a << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N, H;
	scanf("%d%d", &N, &H);

	int32_t a_max = 0, b[100000];
	for (int32_t i = 0; i < N; i++) {
		int32_t a;
		scanf("%d%d", &a, &b[i]);
		a_max = max(a_max, a);
	}
	sort(b, b + N, greater<int32_t>());

	int64_t sum[100001];
	sum[0] = 0;
	for (int32_t i = 1; i <= N; i++)
		sum[i] = sum[i - 1] + b[i - 1];

	int64_t res = numeric_limits<int64_t>::max();
	for (int32_t k = 0; k <= N; k++) {
		int64_t hit_point = H - sum[k];
		int64_t attacks = k;
		if (hit_point > 0) {
			attacks += hit_point / a_max;
			if (hit_point % a_max > 0)
				attacks++;
		}
		res = min(res, attacks);
	}

	printf("%" PRId64 "\n", res);

	return 0;
}


Measured memory_bytes: 1408
import java.util.*;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      long A = sc.nextLong(); //1
      long B = sc.nextLong(); //2
      long C = sc.nextLong(); //3
      long K = sc.nextLong(); //4
      long max = 0;
      
      if(K >= A){ //K=4,A=1
        max += A; //max=1
        K -= A; //K=3
      }else if(A > K){
        max += K;
        K = 0;
      }

      if(K >= B){ //K=3,B=2
        K -= B; //K=1
      }
      
        max -= K; //K=1,max=0
        System.out.println(max);
   }
}


Measured memory_bytes: 35748
const inf = Number.MAX_SAFE_INTEGER;
function Main(input){
	input = input.split("\n")
	var mem = input[0].split(" ").map(Number);
	var n = mem[1];
	var arrsum = 0;
	var min = inf;
	for(var i=1;i<input.length;i++){
		input[i] -= 0;
		arrsum += input[i];
		if(min>input[i]) min = input[i];
	}
	console.log(Math.floor((n-arrsum)/min)+input.length-1)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

int main(){
    int N, M, R;
    std::cin >> N >> M >> R;

    std::vector<int> r(R);
    for(int i = 0; i < R; i++){
        std::cin >> r[i];
        r[i]--;
    }
    std::sort(r.begin(), r.end());

    int v[200][200]; 
    for(int i = 0; i < 200; i++){
        for(int j = 0; j < 200; j++){
            if(i == j)v[i][j] = 0;
            else v[i][j] = 1e9;
        }
    }

    int a, b, c;
    for(int i = 0; i < M; i++){
        std::cin >> a >> b >> c;
        a--;
        b--;
        v[a][b] = c;
        v[b][a] = c;
    }

    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                v[i][j] = std::min(v[i][j], v[i][k] + v[k][j]);
            }
        }
    }

    int ans = 1e9;
    int tmp;
    do{
        tmp = 0;
        for(int i = 0; i < R - 1; i++) tmp += v[r[i]][r[i + 1]];
        ans = std::min(ans, tmp);
    }while(next_permutation(r.begin(), r.end()));

    std::cout << ans << std::endl;
}


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

using namespace std;

typedef long long ll;

const int maxn = 2e3 + 10, maxl = 4e3 + 10, mod = 998244353;
int n, k, dp[maxn][maxn], par[maxn][maxn], c[maxl][maxl];
ll ans;

template <typename T> void add(T &a, ll b) { a = (a + b) % mod; }

int main(){
	for (int i = 0; i < maxl; ++i) {
		c[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			add(c[i][j], c[i - 1][j] + c[i - 1][j - 1]);
	}
	for (int i = 0; i < maxn; ++i)
		dp[0][i] = 1, par[0][i] = 1, par[i][0] = 1;
	for (int i = 1; i < maxn; ++i)
		for (int j = 1; j < maxn; ++j) {
			add(dp[i][j], dp[i][j - 1] + 2ll * par[i - 1][j - 1]);
			add(par[i][j], par[i - 1][j] + dp[i][j]);
		}
	cin >> k >> n;
	for (int i = 2, lim = k << 1; i <= lim; ++i) {
		int p = 0;
		for (int j = 1; (j << 1) < i; ++j)
			if (i - j <= k)
				++p;
		ans = 0;
		if (i & 1)
			if (k - (p << 1))
				for (int j = 0, num = k - (p << 1); j <= n; ++j)
					add(ans, 1ll * c[num + j - 1][j] * dp[n - j][p]);
			else
				ans = dp[n][p];
		else if (k - 1 > (p << 1))
			for (int j = 0, num = k - (p << 1) - 1; j <= n; ++j)
				add(ans, 1ll * c[num + j - 1][j] * (dp[n - j][p] + (j < n? dp[n - j - 1][p]: 0)));
		else
			add(ans, dp[n - 1][p] + dp[n][p]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 93184
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) { cout << "Yay!" << endl; }
	else { cout << ":(" << endl; }
	return 0;
}

Measured memory_bytes: 384
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int N,M,n,m,a[505][505];
int main(){
    scanf("%d%d%d%d",&N,&M,&n,&m);
    if(N%n==0&&M%m==0){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    if(N%n){
        for(int i=1;i<=N;++i){
            if(i%n)a[i][1]=2000000;
            else a[i][1]=-2000000*(n-1)-1;
            for(int j=2;j<=M;++j)a[i][j]=a[i][1];
        }
    }
    else{
        for(int i=1;i<=M;++i){
            if(i%m)a[1][i]=2000000;
            else a[1][i]=-2000000*(m-1)-1;
            for(int j=2;j<=N;++j)a[j][i]=a[1][i];
        }
    }
    for(int i=1;i<=N;++i){
        for(int j=1;j<M;++j)printf("%d ",a[i][j]);
        printf("%d\n",a[i][M]);
    }
   // system("pause");
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }



int main(){
  string s;
  ll K;
  ll num1 = 0;
  cin >> s >> K;
  rep(i,min(ll(s.size()),K)){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}
  




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//constant
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9;
//Macro
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
//Debuging tools
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
///library
//@brief x^n
//@detail if MOD==0 then not modulo. 
template <typename T>
T power(T x,T n,long long MOD = MOD){
    T ret = 1;
    while(n>0){
        if(n%2==1) ret*=x;
        n/=2,x*=x;
        if(MOD!=0) x%=MOD,ret%=MOD;
    }
    return ret;
}

//@brief a^-1 (mod=MOD)
template <typename T>
T modinv(T a,long long MOD = MOD){
    return power(a,MOD-2,MOD);
}
//@brief nCk (O(k))
template <typename T>
T combi_simple(T n,T k,long long MOD = MOD){
    k = min(n-k,k);
    T ret = 1;
    for(T i = n;i>n-k;i--) ret*=i,ret%=MOD;
    for(T i=1;i<=k;i++) ret*=modinv(i,MOD),ret%=MOD;
    return ret;
}
//DataStructure
int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    long long ans = power(2LL,n) - combi_simple(n,a) - combi_simple(n,b) - 1;
    ans%=MOD;
    if(ans<0) ans+=MOD;
    cout << ans << endl;
}


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

int main() {
	int A, B;
	string S;
	cin >> A >> B >> S;
	for (int i = 0;i < A + B + 1;i ++) {
		if (S[i] == '-' && i != A) { // これはアウト
			cout << "No";
			return 0;
		} else if (i == A && S[i] != '-') {
			cout << "No";
			return 0;
		}
	} // 最後まで見たが形式を満たしていた
	cout << "Yes";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

順に見ていく
まず、最初のA文字に-が含まれていればそれはNo
次の1文字は-でなければNo
その次のB文字に-が含まれていればそれはNo
ここまででNoで無ければ、それはYesを返せば良い
*/

Measured memory_bytes: 256
n = gets.to_i
t,a=gets.chomp.split(" ").map(&:to_i);
h=gets.split(" ").map(&:to_i);

temp = h.map.with_index{|x,i| {abs: (a - (t - x * 0.006)).abs, idx: i+1}}
ans = temp.sort_by{|x| x[:abs]}.first[:idx]
print("#{ans}\n")

Measured memory_bytes: 2044
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        boolean q = true;
        for(int i = a ; i <= b ; i++ ){
            if(i % k == 0){
                q = false;
            }
        }
        if(q == false){
            System.out.println("OK");
        }else{
            System.out.println("NG");
        }
        sc.close();
    }
}

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

signed main(){
	int n, l, i, pi = 0, j = 114514, k;
	cin >> n >> l;
	vector<int> aji(n, 0);

	for (i = 0; i < n; i++){
		aji[i] += l + i;
		pi += aji[i];
		j = min(j, abs(aji[i]));
		if (j == abs(aji[i])) k = aji[i];
	}
	cout << pi - k << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    string s=to_string(n);
    
    int sum=0;
    for(int i=0;i<s.size();i++) sum+=s.at(i)-'0';
    
    if(n%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
#define fi first
#define se second
#define pb push_back
int n;
LL a[N],m;
LL ans,sum[N];
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    LL l=a[1]+a[1],r=a[n]+a[n],res=l;
    LL ne=m;
    m=1ll*n*n-m+1;
    while(l<=r){
        LL mid=l+r>>1;
        LL tot=0;
        for(int i=1;i<=n;i++){
            if(a[i]>=mid)break;
            LL x=mid-a[i];
            tot+=upper_bound(a+1,a+1+n,x)-a-1;
        }
        if(tot>=m)r=mid-1,res=mid;
        else l=mid+1;
    }
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    for(int i=1;i<=n;i++)ans+=a[i]*n+sum[n];
    LL pa=0;
    for(int i=1;i<=n;i++){
        int l=1,r=n,d=0;
        while(l<=r){
            int mid=l+r>>1;
            if(a[mid]<res-a[i])d=mid,l=mid+1;
            else r=mid-1;
        }
        ans-=d*a[i]+sum[d];
        pa+=d;
    }
    cout<<ans-(m-1-pa)*res<<'\n';
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#define max(a,b) ((a)>(b) ? (a):(b))
int dp[1001][1001];
int lcs(char *s,char *t){
    int i,j,ls,lt;

    ls=strlen(s);
    lt=strlen(t);
    for(i=0;i<ls;i++){
	for(j=0;j<lt;j++){
	    if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
	    else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
	}
    }
    return dp[ls][lt];
}
int main(){
    char s[1001],t[1001];
    int k;

    scanf("%d", &k);
    while(k--){
	scanf("%s%s", s, t);
	printf("%d\n",lcs(s,t));
    }

    return 0;
}



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

#define rep(i,n) for(i=0;i<(n);i++)
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define ROF(i,a,b) for(i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector< vi > vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

main(){
  int x,y,z;
  cin >> x >> y >> z;
  x=x-z;
  cout << x/(y+z) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a%2==0){
        if(b%2==0){
            cout<<b+((b-a)/2)%2<<endl;
        }
        else if(b%2==1){
            cout<<(b/2-a/2 +1)%2<<endl;
        }
    }
    else if(a%2==1){
        if(b%2==1){
            cout<<2*(a/2) + (b/2- a/2 +1)%2<<endl;
        }
        else if(b%2==0){
            long long ans =(b/2)^(a/2);
            cout<<2 *ans + (b/2 - a/2 )%2 <<endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	long long count = 0;
	for (long long i = 0; i < N; i++) {
		long long x, y;
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= D) {
			count++;
		}
	}

	cout << count << endl;


}






Measured memory_bytes: 3672
#include<iostream>
#include <vector>
#include <utility>
using namespace std;
typedef vector<vector<int> > Field;
typedef pair<int,int> P;

const int INF = 1000;
int w, h;
P goal;
Field f;
vector<P> broken;

P move(P pos, int dx, int dy) {
  int x = pos.first, y = pos.second;
  while (0 <= x+dx and x+dx < w and 
         0 <= y+dy and y+dy < h and f[y+dy][x+dx] == 0) {
    x += dx; y += dy;
  }
  if (x+dx < 0 or w <= x+dx or y+dy < 0 or h <= y+dy) {
    return P(-1,-1);
  } else if (f[y+dy][x+dx] == 3) {
    return P(x+dx, y+dy);
  } else if (x == pos.first and y == pos.second) {
    return P(-1,-1);
  } else {
    f[y+dy][x+dx] = 0;
    broken.push_back(P(x+dx, y+dy));
    return P(x, y);
  }
}

int solve(P pos, int remain) {
  if (remain < 0) {
    for (P p : broken) {
      int x = p.first, y = p.second;
      f[y][x] = 1;
    }
    broken.clear();
    return INF;
  } else if (pos == goal) {
    for (P p : broken) {
      int x = p.first, y = p.second;
      f[y][x] = 1;
    }
    broken.clear();
    return 10 - remain;
  } else {
    int ans[4];
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    for (int i = 0; i < 4; i++) {
      auto current = broken;
      broken.clear();
      auto next = move(pos, dx[i], dy[i]);
      if (next.first == -1) {
        ans[i] = INF;
        for (P p : broken) {
          int x = p.first, y = p.second;
          f[y][x] = 1;
        }
        broken.clear();
        broken = current;
      } else {
        ans[i] = solve(next, remain - 1);
        for (P p : broken) {
          int x = p.first, y = p.second;
          f[y][x] = 1;
        }
        broken.clear();
        broken = current;
      }
    }
    return min(ans[0],min(ans[1],min(ans[2],ans[3])));
  }
}

int main() {
 while (cin >> w >> h and w) {
   f.clear();
   f.resize(h);
   for (int y = 0; y < h; y++) { f[y].resize(w); }
   for (int y = 0; y < f.size(); y++) 
     for (int x = 0; x < f[y].size(); x++) 
       cin >> f[y][x];
   
   P start;
   for (int y = 0; y < f.size(); y++) {
     for (int x = 0; x < w; x++) {
       if (f[y][x] == 2) {
         start.first = x, start.second = y;
         f[y][x] = 0;
       } else if (f[y][x] == 3) {
         goal.first = x, goal.second = y;
       }
     }
   }
     
   int ans = solve(start, 10);
   cout << (ans < INF ? ans:-1) << endl;
 }
 return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void) {

	int n, x=1;	scanf("%d", &n);

	int num[n];

	for (int i=0; i<n; ++i) scanf("%d", &num[i]);

	for (int i=0; i<n; ++i) {

		if (num[i]%2==0){

			if(num[i]%3!=0 && num[i]%5!=0) {

				x=0;

				break;

			}		

		}

	}

	if (x) puts("APPROVED\n");

	else puts("DENIED\n");

	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;

signed main() {
  int q, x; cin >> q;
  char cmd[11];
  list<int> v;

  for(int i = 0; i < q; i++) {
    cin >> cmd;
    if(cmd[0] == 'i') {         // insert
      cin >> x;
      v.push_front(x);
    } else if(cmd[6] == 'L') {  // deleteLast
      v.pop_back();
    } else if(cmd[6] == 'F') {  // deleteFirst
      v.pop_front();
    } else if(cmd[0] == 'd') {  // delete
      cin >> x;
      for(list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if(*it == x) {
          v.erase(it);
          break;
        }
      }
    }
  }

  int i = 0;
  for(list<int>::iterator it = v.begin(); it != v.end(); it++) {
    if(i++) cout << " ";
    cout << *it;
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 34300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  mat a(n,vec(n));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      cin >> a[i][j];
    }
  }
  mat dp(n+1,vec(1<<n));
  dp[0][0]=1;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<(1<<n);j++) {
      bitset<25> bit(j);
      if(bit.count()!=i) continue;
      for(ll k=0;k<n;k++) {
        if(!a[i][k]) continue;
        if(bit.test(k)) continue;
        (dp[i+1][j+(1<<k)]+=dp[i][j])%=mod;
      }
    }
  }
  cout << dp[n][(1<<n)-1] << endl;
}

Measured memory_bytes: 380228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

int gcd(int a, int b) {
  while (b != 0) {
    a = a % b;
    swap(a, b);
  }
  return a;
}


int gcd_vector(const vector<int> &a) {
  int ans = a[0];
  for (int i = 1; i < a.size(); ++i) {
    ans = gcd(ans, a[i]);
  }
  return ans;
}


void print(const vector<int> &a) {
  for (auto e: a) {cout << e << " ";}
  cout << endl;
}


vector<int> get_primes(int maxa) {

  vector<bool> prime (maxa + 1);
  for (int i = 0; i < prime.size(); ++i) prime[i] = true;
  prime[0] = false;
  int start = 1;
  prime[start] = false;
  
  while (start < int(sqrt(maxa))) {
    while (start < int(sqrt(maxa)) && !prime[start]) start++;
    for (int i = 2*start; i < prime.size(); i += start) prime[i] = false;
    ++start;
  }

  vector<int> primes {};
  for (int i = 0; i < prime.size(); ++i) {
    if (prime[i]) primes.push_back(i);
  }

  return primes;
}

  
vector<int> factors(int x, const vector<int>& primes) {
  vector<int> res {};
  for (auto p: primes) {
    if (x % p == 0) {
      res.push_back(p);
    }
    while (x % p == 0) x /= p;
  }

  if (x != 1) res.push_back(x);
  return res;
}




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

  vector<int> a(n);
  
  for (int i = 0; i < n; ++i) cin >> a[i];
  int gcdv = gcd_vector(a);

  auto primes = get_primes(1000);

  set<int> total_factors {};

  bool exist_cf = false;
  for (int i = 0; i < n; ++i) {
    auto fs = factors(a[i], primes);
    for (auto f: fs) {
      if (total_factors.find(f) != total_factors.end()) {
	exist_cf = true;
	break;
      } else {
	total_factors.insert(f);
      }
      if (exist_cf) break;
    }
  }

  if (!exist_cf) {
    cout << "pairwise coprime" << endl;
  } else if (gcdv == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }

}




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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    double ans,min(100000);
    rep(i,n){
        double h;  cin >> h;

        h = t - (h*0.006);
        if(min>abs(a-h)){
            min = abs(a-h);
            ans = i;
        }
    }

    cout << ans+1 << endl;

    return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string s;
    string ans = "";
    cin >> s;
    for (int i = 0; i < (int)s.size(); i += 2) {
        ans += s[i];
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 576
#include <bits/stdc++.h>
#define MOD  1000000007

using namespace std;
typedef long long int lli;
typedef long double ld;
lli ar[3001];
lli dp[3001][3001];

lli power(lli a, lli b){
    if(b==0){
        return 1;
    }
    if(b&1){
        return a*power(a*a,b/2);
    }
    return power(a*a,b/2);
}

lli recu(int i, int j){
    if(i>j){
        return 0;
    }
    if(dp[i][j] != -1){
        //cout<<i<<" "<<j<<endl;
        return dp[i][j];
    }
    lli x=((i+2)<=j)?recu(i+2,j):0;
    lli y=((i+1)<=(j-1))?recu(i+1, j-1):0;
    lli z=(i<=(j-2))?recu(i, j-2):0;
    dp[i][j]=max(ar[i]+min(x, y), ar[j]+min(y, z));
    //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    return dp[i][j];
}

void solve(){
    lli n;
    cin>>n;
    lli sum=0;
    memset(dp, -1, sizeof(dp));
    for(int i=0; i<n; i++){
        cin>>ar[i];
        sum+=ar[i];
    }
    lli x;
    x=recu(0, n-1);
    lli y=sum-x;
    //cout<<x<<" "<<y<<endl;
    cout<<x-y<<endl;
}

signed main(){
    /*#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


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

int n;
int fact[10];
vector<int> v;
vector<int> num = {1,2,3,4,5,6,7,8,9};

int main(){
	cin >> n;
	int used[10] = {0};
	for(int i=0;i<=n;i++){
		if(i==0) fact[i] = 1;
		else fact[i] = fact[i-1]*i;
	}
	for(int i=0;i<fact[n];i++){
		int c = n,t = i;
		for(int j=0;j<n;j++){
			if(c>0){
				v.push_back(num[t/fact[c-1]]);
				num.erase(num.begin()+t/fact[c-1]);
				t -= (t/fact[c-1])*fact[c-1];
				c--;
			}else{
				v.push_back(num[0]);
			}
		}
		num.clear();
		for(int j=0;j<n;j++){
			if(j!=n-1) cout << v[j] << " ";
			else cout << v[j] << endl;
			used[j] = 0;
			num.push_back(j+1);
		}
		v.clear();
	}
}


Measured memory_bytes: 3152
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
Mod = 1000000007




def main(): #startline--------------------------------------------
    N = int(input())
    A = list(map(int,input().split()))
    r = 0
    pinf = 0
    ans = 0
    for l in range(N):
        while (r < N) and ((pinf ^ A[r]) == (pinf + A[r])):
            pinf += A[r]
            r += 1
        ans += r-l
        if l == r:
            r += 1
        else:
            pinf -= A[l]

    print(ans)
if __name__ == "__main__":
    main() #endline===============================================





def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

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

Measured memory_bytes: 27136
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]

max_l = float("-inf")
min_r = float("inf")

for l, r in lr:
    max_l = max(max_l, l)
    min_r = min(min_r, r + 1)

ans = min_r-max_l
print("0" if ans <= 0 else ans if ans < n else n)


Measured memory_bytes: 27376
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class UnionFindTree{
private:
  int* mParent;
  int* mRank;
  int mSize;

public:
  UnionFindTree(int n){
    mSize = n;
    mParent = new int[n];
    mRank = new int[n];

    for(int i=0; i < n; i++){
      mParent[i] = i;
      mRank[i] = 0;
    }
  }

  ~UnionFindTree(){
    delete[] mParent;
    delete[] mRank;
  }

  bool same(int lhs,int rhs){
    return (find(lhs) == find(rhs) ? true : false);
  }

  int find(int pos){
    if(pos == mParent[pos]) return pos;
    return find(mParent[pos]);
  }
  
  void unite(int lhs,int rhs){
    lhs = find(lhs);
    rhs = find(rhs);
    
    if(lhs == rhs) return;
    
    if(mRank[lhs] > mRank[rhs]){
      mParent[lhs] = rhs;
      mRank[rhs] += mRank[lhs];
      mRank[lhs] = 0;
    }
    else{
      mParent[rhs] = lhs;
      mRank[lhs] += mRank[rhs];
      mRank[rhs] = 0;
    }
  }

  int size() const{
    return mSize;
  }
};

class State{
public:
  int from;
  int to;
  int cost;
  State(int _f,int _t,int _c) :
    from(_f), to(_t), cost(_c) {}
  bool operator<(const State& s) const{
    return cost < s.cost;
  }
  bool operator>(const State& s) const{
    return cost > s.cost;
  }
};

int main(){
  int num_of_nodes;
  int num_of_edges;
  while(~scanf("%d %d",&num_of_nodes,&num_of_edges)){
    if(num_of_nodes == 0 && num_of_edges == 0) break;

    priority_queue<State,vector<State>,greater<State> > que;
    for(int edge_idx = 0; edge_idx < num_of_edges; edge_idx++){
      int from,to,cost;
      scanf("%d %d %d",&from,&to,&cost);
      from--; to--;
      que.push(State(from,to,cost));
    }

    UnionFindTree uft(num_of_nodes);

    vector<int> log;
    while(!que.empty()){
      State s = que.top();
      que.pop();
      if(!uft.same(s.from,s.to)){
        uft.unite(s.from,s.to);
        log.push_back(s.cost);
      }
    }

    printf("%d\n",log[log.size()/2]);
  }
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main()
{
    ll n,a,b;scanf("%lld%lld%lld",&n,&a,&b);
    if((b-a)%2==0){
        printf("%lld",(b-a)/2);
    }
    else {
        ll ans=(b-a)/2;
        ans+=min(a-1,n-b);
        printf("%lld",++ans);
    }
    return 0;
}

Measured memory_bytes: 256
using System;
class hogehoge
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] s = Console.ReadLine().Split(' ');
		int t = int.Parse(s[0]);
		int a = int.Parse(s[1]);
		string[] u = Console.ReadLine().Split(' ');
		int[] h = new int[n];
		for (int i = 0; i < n; i++)
		{
			h[i] = int.Parse(u[i]);
		}
		int r = 0;
		for (int i = 1; i < n; i++)
		{
			if (Math.Abs((a * 1000) - ((t * 1000) - (h[i] * 6))) < Math.Abs((a * 1000) - ((t * 1000) - (h[r] * 6)))) r = i;
		}
		Console.WriteLine(r + 1);
	}
}

Measured memory_bytes: 13212
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    vector<int> a(100005, 0);
    int N, M;
    cin >> N >> M;
    rep(i, 0, M)
    {
        int L, R;
        cin >> L >> R;
        ++a[L];
        --a[R + 1];
    }
    rep(i, 1, 100005)
    {
        a[i] += a[i - 1];
    }
    int ans = 0;
    rep(i, 0, 100005)
    {
        if (a[i] == M)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

ll n,m;
string s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>n>>m;
    ll ans=1;
    ll now=n;
    while(1){
    	//cerr<<now<<endl;
    	if(now*2<=m){
    		now*=2;
    		ans++;
    	}else{
    		break;
    	}
    }
    cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}



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

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

    bool res = false;
    for(int i=0; i<=25; i++) {
        for(int j=0; j<=15; j++) {
            if(4*i + 7*j == N) {
                res = true;
                break;
            }
        }
    }

    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
def cross(x, y):
    return (x.conjugate() * y).imag

def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
    
    
import sys

p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(complex(x, y))

print(area_polygon(p))

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

int N, X, Y;

int distance(int i, int j){
  
  int d_a = j - i;
  
  int d_b_a = i - X;
  if(d_b_a < 0) d_b_a *= -1;
  int d_b_b = j - Y;
  if(d_b_b < 0) d_b_b *= -1;
  int d_b = d_b_a + d_b_b + 1;
  
  return min(d_a, d_b);
  
}

int main() {
  
  cin >> N >> X >> Y;
  vector<int> data(0);
  
  for(int i=1; i<N; i++){
    for(int j=i+1; j<N+1; j++){
      data.push_back(distance(i, j));
    }
  }
  
  vector<int> ans(N-1, 0);
  for(int j: data){
    ans.at(j-1)++;
  }
  for(int l: ans){
    cout << l << endl;
  }
  
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> p;


int main(void)
{
  int n, m;
  cin >> n >> m;
  vector<p> student(n, {0, 0});
  vector<p> check(m, {0,0});
  for (int i = 0; i < n; i++){
    cin >> student[i].first >> student[i].second;
  }
  for (int i = 0; i < m; i++){
    cin >> check[i].first >> check[i].second;
  }


  for (int i = 0; i < n; i++){
    int minv = INT_MAX;
    int res = 0;
    for (int j = 0; j < m; j++){
      if (minv > abs(student[i].first - check[j].first) + abs(student[i].second - check[j].second)) {
        minv = abs(student[i].first - check[j].first) + abs(student[i].second - check[j].second);
        res = j + 1;
      }
    }
    // cout << minv << endl;
    cout << res << endl;
  }
  return 0;
}


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

int main() {

    int n; cin >> n;
    int sum = 0;
    while(n >= 5){
        if(n >= 500){
            n -= 500;
            sum += 1000;
        }else{
            n -= 5;
            sum += 5;
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
n = int(input())

a = [int(input()) for i in range(n)]

a = sorted(a)


temp = a[0]
c = 0

cnts = [0]*n

for i in a:
    if temp == i:
        cnts[c] += 1
    
    else:
        temp = i
        c += 1
        cnts[c] += 1

ans = 0

for i in cnts:
    if i == 0:
        break

    if i%2 == 1:
        ans += 1

print(ans)
        

Measured memory_bytes: 8280
#include <stdio.h>
#include <ctype.h>

int stack[100];
int n;

void init(){
	n = 0;
}

void push(int x){
	stack[n++] = x;
}

int pop(void){
	return stack[--n];
}

int main(void){
	int n, a, b;
	init();

	while((n = getchar()) != '\n'){
		if(isdigit(n)){
			ungetc(n, stdin);
			scanf("%d", &n);
			push(n);
		}else{
			if(isspace(n)){
				continue;
			}else{
				switch(n){
					case'+':
						b = pop(); a = pop();
						push(a + b);
						break;
					case'-':
						b = pop(); a = pop();
						push(a - b);
						break;
					case'*':
						b = pop(); a = pop();
						push(a * b);
						break;
					default:
						break;
				}
			}
		}
	}

	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 10000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search
#define N 1000005

void solve()
{
  int a,b;cin>>a>>b;
  cout<<a*b;
}
 
int32_t main()
{
	IOS;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
   	int tc=1;
   	//cin>>tc;
   	while(tc--){
   		solve();
   	}
}

Measured memory_bytes: 3588
n,A,B = map(int, input().split())
s = input()
a_count = 0
b_count = 0
for i in s:
  if i == 'a':
    if a_count + b_count < A + B:
      print('Yes')
      a_count += 1
    else:
      print('No')
  elif i == 'b':
    if a_count + b_count < A + B and b_count < B:
      print('Yes')
      b_count += 1
    else:
      print('No')
  else:
    print('No')

Measured memory_bytes: 9304
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

/****************************************************************/

const int mod = 1000000007;

//power_mod
inline int Pow_mod(int x, int pow){
    if(pow==0) return 1;
    int a=Pow_mod(x, pow/2);
    a=a*a%mod;
    if(pow%2==1) a*=x;
    return a%mod;
}

//factorial_mod
int* fact_mod;
inline void init_fact_mod(int x){
    fact_mod = new int[x];
    fact_mod[0]=1;
    rep(i,x-1)fact_mod[i+1]=fact_mod[i]*(i+1)%mod;
}

//permutation_mod
inline int nPr_mod(int n, int r){
    return fact_mod[n]*Pow_mod(fact_mod[n-r]%mod, mod-2)%mod;
}

//combination_mod
inline int nCr_mod(int n, int r){
    return fact_mod[n]*Pow_mod(fact_mod[n-r]*fact_mod[r]%mod, mod-2)%mod;
}

/****************************************************************/

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int n,k; cin>>n>>k;
    init_fact_mod(2020);
    rep(i,k){
      	if(i+1>n-k+1)cout<<0<<endl;
        else cout<<nCr_mod(n-k+1,i+1)*nCr_mod(k-1,i)%mod<<endl;
    }

}

Measured memory_bytes: 256