akhauriyash/Code-Regression huggingface dataset:
// http://photon.poly.edu/~hbr/boost/combinations.html
#include <algorithm>
using namespace std;
template <class BidirectionalIterator>
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if(( first1 == last1 ) || ( first2 == last2 ))return false;
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while(--m1 != first1 && !(* m1 < *m2 ));
	bool result = (m1 == first1 ) && !(* first1 < *m2 );
	if(!result){
		while( first2 != m2 && !(* m1 < * first2 ))++first2;
		first1 = m1;
		iter_swap(first1 , first2 );
		++ first1;
		++ first2;
	}
	if(( first1 != last1 ) && ( first2 != last2 )){
		m1 = last1 ; m2 = first2 ;
		while(( m1 != first1 ) && (m2 != last2 )){
			iter_swap (--m1 , m2 );
			++m2;
		}
		reverse(first1 , m1);
		reverse(first1 , last1);
		reverse(m2 , last2);
		reverse(first2 , last2);
	}
	return !result;
}
template <class BidirectionalIterator>
bool next_combination (BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{return next_combination(first , middle , middle , last);}

#include <vector>
#include <cstdio>
int main(){
	int i,j,n,m;
	double f,f0;
	scanf("%d%d",&n,&m);
	if(m<2){puts("0");return 0;}
	vector<vector<double> >a;
	for(i=0;i<n;i++){
		vector<double>v;
		for(j=0;j<3;j++){
			scanf("%lf",&f);
			v.push_back(f);
		}
		a.push_back(v);
	}
	vector<int>v;
	for(i=0;i<n;i++)v.push_back(i);
	f=0;
	do{
		f0=0;
		for(i=0;i<m-1;i++)for(j=i+1;j<m;j++){
			f0+=(a[v[i]][0]-a[v[j]][0])*(a[v[i]][0]-a[v[j]][0])+(a[v[i]][1]-a[v[j]][1])*(a[v[i]][1]-a[v[j]][1])+(a[v[i]][2]-a[v[j]][2])*(a[v[i]][2]-a[v[j]][2]);
		}
		if(f<f0)f=f0;
	}while(next_combination(v.begin(), v.begin()+m, v.end()));
	printf("%f\n",f);
}

Measured memory_bytes: 1116
# https://atcoder.jp/contests/abc138/tasks/abc138_c

N = gets.to_i
vs = gets.split.map(&:to_i)

ans = vs
  .sort
  .reverse
  .map.with_index(1)
  .reduce(0) { |m, (a, i)| m + a.to_f / 2**[i, N - 1].min }

puts ans


Measured memory_bytes: 1788
#include<stdio.h>
#define MAX 2000000
int H,A[MAX+1];
void maxHeapify(int);
void swap(int*,int*);
int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--) maxHeapify(i);
  printf(" ");
  for(i=1;i<=H;i++){
    printf("%d",A[i]);
    if(i==H){
      printf("\n");
    break;
  }
    printf(" ");
  }
  return 0;
}

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest]) largest=r;
  if(largest!=i){
    swap(&A[i],&A[largest]);
    maxHeapify(largest);
  }
}
void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}




Measured memory_bytes: 3648
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int n = cin.NextInt();
			Console.WriteLine(n * (n + 1) / 2);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

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

   int n;
   string s;
   cin >> n >> s;
   vector<int> a(n);
   rep(i, 0, n) {
      if (s[i] == 'R') a[i] = 0;
      if (s[i] == 'G') a[i] = 1;
      if (s[i] == 'B') a[i] = 2;
   }
   vector<ll> cnt(3);
   rep(i, 0, n) cnt[a[i]]++;
   ll ans = 1;
   rep(i, 0, 3) ans *= cnt[i];
   rep(j, 0, n) {
      rep(i, 0, j) {
         int k = 2 * j - i;
         if (k < n) {
            if (a[i] == a[j] || a[i] == a[k] || a[k] == a[j]) continue;
            ans--;
         }
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int x;
    cin>>x;
    for(int i=0;i<=1000;i++){
        for(int j=-1000;j<=1000;j++)
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout<<i<<" "<<j;
                return 0;
            }
    }
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
  int n;
  int i;
  int a=0,b=0,ans;
  char c[200001];
  scanf("%d",&n);
  scanf("%s",c);
  for(i=0;i<n;i++){
    if(c[i]=='R') a++;
  }
  for(i=0;i<a;i++){
    if(c[i]=='R') b++;
  }
  ans=a-b;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1932
n,k=map(int,input().split())
arr=list(map(int,input().split()))
cum1=[0]*n
cum1[0]=arr[0]
cum2=[0]*n
if arr[0]>=0:
  cum2[0]=arr[0]
for i in range(1,n):
  cum1[i]=arr[i]+cum1[i-1]
  cum2[i]=cum2[i-1]
  if arr[i]>=0:
    cum2[i]+=arr[i]
ans=0
for i in range(n-k+1):
  if i==0:
    tmp=max(0,cum1[i+k-1])+(cum2[n-1]-cum2[i+k-1])
  elif i==n-k:
    tmp=max(0,(cum1[i+k-1]-cum1[i-1]))+cum2[i-1]
  else:
    tmp=max(0,(cum1[i+k-1]-cum1[i-1]))+(cum2[n-1]-cum2[i+k-1]+cum2[i-1])
  ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 16832
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<int>();
            var s=ReadLine();
            var _ = 0;
            if (int.TryParse(s.Substring(0, A), out _) && int.TryParse(s.Substring(A + 1, B), out _) && s[A] == '-')
                WriteLine("Yes");
            else
                WriteLine("No");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27464
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        // 1.????????????????????????
        List<String> list = new ArrayList<>();
        for (int j = 1; j <= 4; j++) {
            for (int i = 1; i <= 13; i++) {

                String s = "";
                if (j == 1) {
                    // System.out.println("??????S " + i);
                    s = "S ";

                } else if (j == 2) {
                    s = "H ";
//                    System.out.println("??¢???H " + i);
                }
                if (j == 3) {
                    s = "C ";
//                    System.out.println("?¢???±C " + i);
                }
                if (j == 4) {
                    s = "D ";
//                    System.out.println("??????D " + i);

                } else {
                    //   System.out.println("???????????????");
                }
                s = s + i;
                list.add(s);
            }

        }
        // 2. ???????????????????????????
        int n = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            String s = scanner.nextLine();
            // 3.????????????????????????
            if (list.contains(s)) {
                list.remove(s);
            }
        }

        // 4.???????????????????????????
        for (String str : list) {
            System.out.println(str);
        }
    }

}

Measured memory_bytes: 26156
fun main(args: Array<String>) {
    val (N, M, Q) = listOfInt()
    val T = Array(N + 1) { IntArray(N + 1) }
    repeat(M) { m ->
        val (L, R) = listOfInt()
        T[L][R] += 1
    }
    for (p in 1 .. N) {
        for (q in 1 .. N) {
            T[p][q] += (T[p - 1][q] + T[p][q - 1] - T[p - 1][q - 1])
        }
    }
    repeat(Q) { n ->
        var (p, q) = listOfInt()
        println(T[q][q] - T[p - 1][q])
    }
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 82904
#include <stdio.h>
 
int main(void)
{
	int d;
	int i;
	int s;

	while (scanf("%d", &d) != EOF){
		s = 0;
		for (i = 0; i < 600; i += d){
			s += (d * i * i);
		}

		printf("%d\n", s);
	}

	return (0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main(){
    ll n; cin >> n;
    ll ans = 0;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];

    for(int i = 0; i < n-2; i ++){
        for(int j = i+1; j < n-1; j ++){
            for(int k = j+1; k < n; k ++){
                if(l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;
                if(l[i] + l[j] > l[k] && l[k] + l[j] > l[i] && l[i] + l[k] > l[j]) ans ++;
            }
        }
    }

    cout << ans;

}

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


/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/



using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	int n;
	string temp;
	cin >> n;
	set <string> x;
	while(n--)
	{
		cin >> temp;
		x.insert(temp);
	}
	cout << x.size();
    return 0;
}


Measured memory_bytes: 19160
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t n, k;
  cin >> n >> k;
  double result = 0;
  for (int dice = 1; dice <= k - 1 && dice <= n; dice++) {
    double rate   = 1 / (double)n;
    int64_t score = dice;
    while (score < k) {
      score *= 2;
      rate *= 0.5;
    }
    result += rate;
  }
  if (n >= k) {
    result += (n - k + 1) / (double)n;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <map>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 2000;
ll v[1 + nmax], part[1 + nmax];

int main() {
  ll n, x;
  std::cin >> n >> x;
  for(int i = 0;i < n; i++) {
    std::cin >> v[i];
    part[i] = v[i];
  }
  ll result = 1LL * nmax * 1000000000, sum = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++)
      part[j] = std::min(part[j], v[(j + n - i) % n]);
    sum = 0;
    for(int j = 0; j < n; j++)
      sum += part[j];
    result = std::min(result, sum + i * x);
  }
  std::cout << result;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}


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

    int N, K, T, U, V, L; cin >> N >> K >> T >> U >> V >> L;
    vi carrot(L);
    REP(i, N) {
        int d; cin >> d; carrot[d] = 1;
    }

    double ans = 0;
    int carrots = 0;
    int rem = 0;
    REP(i, L) {
        if (carrot[i]) {
            if (carrots < K) ++carrots;
            else {
                rem = T * V;
            }
        }
        if (rem == 0 and carrots > 0) {
            --carrots;
            rem = T * V;
        }

        if (rem == 0) {
            ans += 1.0 / U;
        } else {
            --rem;
            ans += 1.0 / V;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3344
const { count } = require("console");

function main(lines) {
  const S = s();

  let ans = true;
  for (let i = 0, end = S.length-1; i < end/4; i++) {
    if ( S[i] != S[end-i]
      || S[i] != S[end/2-1-i]
      || S[i] != S[end/2+1+i]
    ) {
      ans = false;
      break;
    }
  }
  
  return ans ? 'Yes' : 'No';
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 29632
s = input()
a = ""

ans = [0]*len(s)

ls = []

rflag = 0
lflag = 1

for i in range(1,len(s)):
    if s[i] == "L":
        ans[i-1] += lflag
        ans[i] += rflag
        rflag, lflag = 0, 0
    else:
        rflag, lflag = lflag, rflag
        lflag += 1

rflag = 1
lflag = 0

for i in range(1,len(s)):
    if s[len(s)-i-1] == "R":
        ans[len(s)-i-1] += lflag
        ans[len(s)-i] += rflag
        rflag, lflag = 0, 0
    else:
        rflag, lflag = lflag, rflag
        rflag += 1

for i in range(len(s)):
    a += str(ans[i]) + " "

print(a)

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

int main(){
	int N;	//整数
	cin >> N;
	vector<int> tmpVec(N, -1);
	for (int i = 0; i < N; ++i){
		cin >> tmpVec[i];
	}

	//小さい順にソート
	for (int i = 0; i < N - 1; ++i){
		for (int j = N - 1; j > i; --j){
			if (tmpVec[j-1] > tmpVec[j]) {
				int tmp = tmpVec[j-1];
				tmpVec[j-1] = tmpVec[j];
				tmpVec[j] = tmp;
			}
		}
	}

	//double型の配列を作成
	vector<double> vec(N, 0.0);
	for (int i = 0; i < N; ++i) {
		vec[i] = (double) tmpVec[i];
	}

	//処理実行
	double newValue = 0.0;
	for (int cnt = 1; cnt < N; ++cnt) {
		//新しい値を作成
		double value1 = vec[0];
		double value2 = vec[1];
		vec.erase(vec.begin());
		vec.erase(vec.begin());
		newValue = (value1 + value2) / 2.0;

		//最後のステップならループを抜ける
		if (cnt == N-1) {
			break;
		}

		//新しい値をvecの適切な位置に挿入
		bool insertFlag = false;
		for (int j = 0; j < (int) vec.size(); ++j){
			if (newValue < vec[j]){
				insertFlag = true;
				vec.insert(vec.begin() + j, newValue);
				break;
			}
		}
		if (!insertFlag){
			vec.push_back(newValue);
		}
	}

	printf("%f\n", newValue);

	return 0;
}


Measured memory_bytes: 256
M = 1000001

p = [1]*M
p[0] = p[1] = 0
for i in range(2, int(M**.5)+1):
    if p[i]:
        for j in range(i*i, M, i):
            p[j] = 0
cs = [0]*M
cur = 0
for i in range(M):
    if p[i]:
        cur += 1
    cs[i] = cur

while 1:
    N = int(input())
    if N == 0:
        break
    ans = 0
    for i in range(N):
        p, m = map(int, input().split())
        x = cs[min(p+m, M-1)] - cs[max(p-m-1, 0)]
        if x:
            ans += x-1
        else:
            ans -= 1
    print(ans)


Measured memory_bytes: 23500
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	string S;
	cin >> S;
	vector<string> v{""};
	v[0] += S[0];
	string T="";
	for(int i=1; i<S.size(); ++i){
	    T += S[i];
	    if(v.back()!=T){
	        v.push_back(T);
	        T="";
	    }
	}
	cout << v.size() << endl;
	return 0;
}


Measured memory_bytes: 10996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
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 = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int N,M;
bool sw[12];
int c[12][12];
int p[12];
int k[12];

int main(){
  cin >> N >> M;
  rep(i,M){
    cin >> k[i];
    rep(j,k[i]){
      cin >> c[i][j];
    }
  }
  rep(i,M){
    cin >> p[i];
  }
  int ans = 0;
  for(int bit = 0; bit < (1<<N); bit++){
    bool f = true;
    rep(i,N){
      sw[i] = false;
    }
    rep(i,N){
      if(bit & 1<<i) sw[i] = true;
    }
    rep(i,M){
      int num = 0;
      rep(j,k[i]){
	if(sw[c[i][j]-1]) num++;
      }
      if(num%2 != p[i]) f = false;
    }
    if(f) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
//Author: Suifeng0214
//2020.7.26 8.40
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int>arr;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >>n;
	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef debug
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, t;
    cin >> n >> t;
    vector<pair<int,int>> vec;
    for(int i = 1; i <= n; i++){
        int a, b; cin >> a>>b;
        if(b <= t){
            vec.pb({a,b});
        }
    }
    sort(vec.begin(), vec.end());
    if(vec.size() == 0)cout << "TLE" << endl;
    else cout << vec[0].f << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n,cnt=1,ans=0,odd=0;
int a[200000];
vector<int>vec,chunk;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1])vec.push_back(i);
    }
    int l=vec.size();
    rep(i,l){
        if(i==l-1)chunk.push_back(cnt);
        else{
            if(vec[i+1]==vec[i]+1)cnt++;
            else{
                chunk.push_back(cnt);
                cnt=1;
            }
        }
    }
    int le=chunk.size();
    rep(i,le){
        ans+=(chunk[i]/2)*2;
        if(chunk[i]%2)odd++;
    }
    ans+=(odd/2)*2;
    if(odd%2)ans+=2;
    cout<<n-ans<<endl;
    return 0;
}


Measured memory_bytes: 2168
import itertools
S=input()
SS=int(S)
N=len(S)
K=int(input())
def base9(n):
    res=""
    while(n>0):
        res=str((n%9)+1)+res
        n=n//9
    return "1"*(K-len(res))+res
ans=0
for seq in itertools.combinations(range(N),K):
    #print(seq,ans)
    low=0
    high=-1+9**K
    tmp=sum([9*10**(seq[i]) for i in range(K)])
    #print(tmp,SS)
    if tmp<=SS:
        ans+=9**K
        continue
    if tmp//9>SS:
        continue
    while(high-low>1):
        mid=(high+low)//2
        tmp2=base9(mid)
        tmp=sum([int(tmp2[i])*10**(seq[-i-1]) for i in range(K)])
        #print(tmp,tmp2,SS,low,mid,high)
        if tmp<=SS:
            low=mid
        else:
            high=mid
    ans+=low+1
print(ans)

Measured memory_bytes: 47708
N = int(input())
A = list(map(int,input().split()))
counter = 1 ###グループ数
sign = 0 ###増減、-1,0,1、0はグループの初回、または初回以降増減が見られないときのみ
for x in range (1,N):
	if A[x]>A[x-1] and (sign==0 or sign==1):
		sign = 1
	elif A[x]>A[x-1] and (sign==-1):
		counter += 1
		sign = 0
	elif A[x]<A[x-1] and (sign==0 or sign==-1):
		sign = -1
	elif A[x]<A[x-1] and (sign==1):
		counter += 1
		sign = 0
print(counter)

Measured memory_bytes: 62704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadLong();
            if (s % 2 == 0) WriteLine(s);
            else WriteLine(s * 2);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
N, M = map(int, input().split())
Fm = [0]*M
for n in range(N):
  KA = list(map(int, input().split()))
  for i in range(KA[0]):
    Fm[KA[i+1]-1] += 1
ans = 0
for m in range(M):
  if Fm[m] == N:
    ans += 1
print(ans)

Measured memory_bytes: 3060
s = int(input())
h = int(s/3600)
m = int(int(s-int(s/3600)*3600)/60)
d = int(s-int(s/3600)*3600)-int(int(int(s-int(s/3600)*3600)/60)*60)

print('{}:{}:{}'.format(h,m,d))


Measured memory_bytes: 5592
use proconio::input;
fn main() {
    input!{
        mut s: String,
        t: String
    }
    let ns = s.len();
    let nt = t.len();
    let mut j = -1;
    for i in 0..ns-nt+1{
        if s[i..i+nt].chars().zip(t.chars()).filter(|&(x, y)| {x == '?' || x == y} ).count() == nt{
            j = i as i32;
        }
    }
    if j == -1 {
        println!("UNRESTORABLE")
    }
    else{
        let j = j as usize;
        s.replace_range(j..j+nt, &t);
        let ans: String = s.chars().map(|x| if x=='?' {'a'} else {x}).collect();
        println!("{}", ans);
    }
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
using namespace std;
typedef int64_t ll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        vpll c(4);
        rep(i, 4) {
            c[i].se = (8 >> i);
            in >> c[i].fi;
            c[i].fi;
            c[i].fi *= c[i].se;
        }
        ll n;
        in >> n;
        n *= 4;
        sort(all(c));
        ll ans = 0;
        rep(i, 4) {
            ll id = 8 / c[i].se;
            if (id <= n) {
                ans += n / id * (c[i].fi / c[i].se);
                n %= id;
            }
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct wear{
  int a, b, c;
  void nxt(void){
    scanf("%d %d %d", &a, &b, &c);
    return;
  }
};

int t[200];
wear w[200];
int dp[200][101] = {0};

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(d, n);
    scn(d, t);

    rep(i, d)rep(j, 101)dp[i][j] = -1;
    rep(i, n){
      w[i].nxt();
      if(w[i].a <= t[0] && t[0] <= w[i].b)dp[0][w[i].c] = 0;
    }

    rep(i, d - 1)rep(j, 101)if(dp[i][j] != -1){
      int k;
      rep(k, n)if(w[k].a <= t[i + 1] && t[i + 1] <= w[k].b)
      dp[i + 1][w[k].c] = max(dp[i + 1][w[k].c], dp[i][j] + abs(w[k].c - j));
    }
    int res = 0;
    rep(i, 101)res = max(res, dp[d - 1][i]);
    pri(res);

/*/

//*/ break;
  }
  return 0;
}

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

long long gcd(long long a,long long b){
	if(a==0 || b==0){
		return max(a,b);
	}
	else if(a%b==0 || b%a==0){
		return min(a,b);
	}
	
	long long q;
	bool pro =true;
	while(pro){
		q=a%b;
		a=b;
		b=q;
		if(a%b==0){
			return q;
			pro=false;
		}
	}
}

signed main(){
	int N; cin>>N;
	int t,l; cin>>t; l=t;
	for(int i=0;i<N-1;i++){
		cin>>t;
		l=t/gcd(t,l)*l;
	}
	cout<<l<<endl;

}


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

#define MAX_S 10000
#define MAX_T 500

int main() {
  int n, q;
  int S[MAX_S], T[MAX_T];

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

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

  int cnt = 0;
  for ( int i = 0; i < q; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      if (T[i] == S[j]) {
        cnt++;
        break;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
//     S H C D
    int s[13] = {0};
    int h[13] = {0};
    int c[13] = {0};
    int d[13] = {0};
    int a,i;
    char ch;
    scanf("%d",&a);
    for(;a;a--)
    {
        scanf("\n%c %d",&ch,&i);
        i--;
        if(ch=='S')
            s[i] = 1;
        else if(ch=='H')
            h[i] = 1;
        else if(ch=='C')
            c[i] = 1;
        else if(ch=='D')
            d[i] = 1;
    }

    for(i=0;i<13;i++)
    {
        if(!s[i])
            printf("%c %d\n",'S',i+1);
    }
    for(i=0;i<13;i++)
    {
        if(!h[i])
            printf("%c %d\n",'H',i+1);
    }
    for(i=0;i<13;i++)
    {
        if(!c[i])
            printf("%c %d\n",'C',i+1);
    }
    for(i=0;i<13;i++)
    {
        if(!d[i])
            printf("%c %d\n",'D',i+1);
    }
  

    return 0;
}




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

using namespace std;

int dp[100001];
int h[100001];

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    int n;
    cin >> n;
    if (n == 1) {
        cout << 0;
        return 0;
    }

    for (int i = 0; i < n; i++){
        cin >> h[i];
    }
    if (n == 2) {
        cout << abs(h[0]-h[1]);
        return 0;
    }

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for (int i = 2; i < n; i++) {
        int a = abs(h[i] - h[i-2]) + dp[i-2];
        int b = abs(h[i] - h[i-1]) + dp[i-1];
        dp[i] = min(a, b);
    }

    cout << dp[n-1];


    return 0;
}


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

int main() {
  std::string s, t;
  std::cin >> s >> t;

  std::sort(s.begin(), s.end());
  std::sort(t.begin(), t.end(), std::greater<char>());

  for (int64_t i = 0; i < s.size() && i < t.size(); i++) {
    if (s[i] < t[i]) {
      std::cout << "Yes" << std::endl;
      return 0;
    } else if (t[i] < s[i]) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }

  if (s.size() < t.size()) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p 998244353

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int fact(int N){
	if(N == 0){
		return 1;
	}
	else{
		return MOD(N * fact(N - 1));
	}
}

signed main(){
	int N, i, j, k, f0 = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * 2 * N);
	int *L = (int *)malloc(sizeof(int) * N);
	int *R = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		A[i]--;
		if(A[i] == 0){
			f0 = 1;
		}
		A[N + i] = A[i];
		L[i] = -1;
		R[i] = -1;
	}
	if(f0 == 0){
		printf("0\n");
		return 0;
	}
	for(i = 0; i < N && A[i] == 0; i++);
	if(i == N){
		printf("%lld\n", fact(N));
		return 0;
	}
	for(i++; i < 2 * N && A[i] > 0; i++);
	for(j = 0; j < N; j++){
		A[j] = A[i + j];
	}
/*	printf("A:");
	for(i = 0; i < N; i++){
		printf("%lld ", A[i]);
	}
	printf("\n");
*/	for(i = 0; A[i] == 0; i++);
	k = i;
//	printf("k = %lld\n", k);
	for(i = i; i < N; i++){
		if(A[i] == 0){
			printf("0\n");
			return 0;
		}
		else if(L[A[i]] == -1){
			L[A[i]] = i;
			R[A[i]] = i;
		}
		else if(A[i] == A[i - 1]){
			R[A[i]]++;
		}
		else{
			printf("0\n");
			return 0;
		}
	}
	int *B = (int *)malloc(sizeof(int) * (N + 1));
	for(i = 0; i < N; i++){
		B[i] = 0;
	}
	B[N] = 1;
	for(i = 0; i < k; i++){
		B[i] = 1;
	}
	int ans = 1, lest = 0;
	for(i = 1; i < N; i++){
//		printf("(L, R)[%lld] = (%lld, %lld)\n", i, L[i], R[i]);
		if(L[i] == -1){
			if(lest == 0){
				printf("0\n");
				return 0;
			}
			else{
				ans = MOD(ans * lest);
				lest--;
			}
		}
		else if(R[i] - L[i] + 1 > k){
			printf("0\n");
			return 0;
		}
		else{
			if(B[L[i] - 1] == 0 && B[R[i] + 1] == 0){
				if(R[i] - L[i] + 1 < k){
					printf("0\n");
					return 0;
				}
			}
			else if(B[L[i] - 1] == 1 && B[R[i] + 1] == 1){
				ans = MOD(ans * (k - (R[i] - L[i])));
				lest += k + R[i] - L[i] - 1;
			}
			else{
				lest += R[i] - L[i];
			}
		}
		for(j = L[i]; j <= R[i]; j++){
			B[j] = 1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 14208
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, M, X = inpl()
A = inpl()

ans = 0
for i in range(M):
    if X < A[i]:
        break
    ans += 1

if ans > M - ans: ans = M - ans

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	long long int n,last=1;
	cin>>n;
	for(int i=1;i<=1000000000;i++){
		if(i*i>n){
			cout<<last<<endl;
			return 0;
		}
		last=i*i;
	}
	return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


// aとbの最大公約数
ll gcd(ll a, ll b) {
	if (a < b) gcd(b, a);
	ll r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

signed main(){

	int N;
	vector<int> A;
	cin >> N;
	A.resize(N);
	rep(i, N) cin >> A[i];

	sort(A.begin(), A.end());

	int m = INF;
	for (int i = 0; i*2 <= N; i++){
		// 2*i個の和
		int t = 0;
		for (int j = 0; j < 2 * i; j++)
			t += A[j];
		m = min(m, t);
	}

	int ans = 0;
	rep(i, N) ans += A[i];
	ans += abs(m) * 2;

	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;
int n,m,a[N],b[N],c[N],p[N],train[N],res=0;
signed main(){

    cin >> n >> m;
    for(int i=1;i<=m;i++){
        cin >> p[i];
    }
    for(int i=1;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    for(int i=1;i<m;i++){
        int x = min(p[i],p[i+1]);
        int y = max(p[i],p[i+1]);
        train[x]++;
        train[y]--;
    }
    for(int i=1;i<n;i++){
        train[i] += train[i-1];
    }
    
    for(int i=1;i<n;i++){
        res+= min(train[i]*a[i],train[i]*b[i]+c[i]);
    }
    cout << res << endl;
    return 0;
}

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

const ll INF = 1LL << 60;

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

    //最小値は1＝＞1を全体に広げていく
    ll count = (N-K+K-2)/(K-1) + 1;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	unsigned long long a,b,n,z;
	cin>>n;
	if(n%10==0) z=10;
	else if(n<10) z=n;
	else z=n%10+n%100/10+n%1000/100+n%10000/1000+n%100000/10000;
	cout<<z;
	return 0;
}

Measured memory_bytes: 256
mod = 10**9 + 7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range(2, 10 ** 6 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
 
 
def comb(n, r, mod=mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
R = N - K

ans = [0]*K
if R == 0:
  ans[0] = 1
elif R == 1:
  ans[0] = 2
  if K >= 2:
    ans[1] = (K-1) % mod
elif R == 2:
  ans[0] = 3
  if K >= 2:
    ans[1] = (3*K - 3) % mod
    if K >= 3:
      ans[2] = (K-1)*(K-2)//2 % mod
else:
  ans[0] = R + 1
  if K >= 2:
    if R > K:
      for i in range(2, K+1):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)+comb(R-1, i)) % mod
    else:
      for i in range(2, R):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)+comb(R-1, i)) % mod
      for i in range(R, K+1):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)) % mod

for a in ans:
  print(a)

Measured memory_bytes: 122148
n = int(input())
a = sorted([int(n) for n in input().split()])
for i in range(1, a[0]+1):
    if n == 2:
        if a[0] % i == 0 and a[1] % i == 0:
            print(i)
    else:
        if a[0] % i == 0 and a[1] % i == 0 and a[2] % i == 0:
            print(i)



Measured memory_bytes: 5600
h,n=map(int,input().split())
ab=[[] for i in range(n)]
for i in range(n):
  ab[i]=list(map(int,input().split()))
  
dp=[100000000 for i in range(h+1)]
dp[0]=0
for hi in range(h):
  for i in range(n):
    damage=min(h,hi+ab[i][0])
    dp[damage] = min(dp[damage],dp[hi]+ab[i][1])
    #print(damage,dp[damage],dp[hi]+ab[i][1])
print(dp[h])

Measured memory_bytes: 43804
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int func(int a, int b) {
    if(a < b) swap(a, b);
    if(a % b == 0) return a / b * 2 * b - b;
    else return func(a - (a / b) * b, b) + (a / b) * 2 * b;
}

signed main() {
    int N, X; cin >> N >> X;
    cout << func(X, N-X) + N << endl;
    return 0;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;

int main(){
  long long n;
  cin >> n;
  long long ans;
  ans = n*(n-1)/2;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

from itertools import permutations
s = [i for i in range(1,N+1)]

Ps = [i for i in P]
Qs = [i for i in Q]

a = 0
b = 0
for i,t in enumerate(permutations(s)):
    ts = list(t)
    if Ps == ts:
      a = i
    if Qs == ts:
      b = i
      
ans = abs(a-b)
print(ans)

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

int n, p, a[55], cnt = 0, r1 = 0, r2 = 0;
int ccc[110];
long long res;
long long solve(int n) {
	if (n == 0) return (long long)1;
	else return (long long)2 * solve(n - 1);
}
int main(void) {
	scanf("%d%d", &n, &p);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		if (a[i] % 2) r1++;
		else r2++;
	}
	if (r1)
		res = solve(r1 - 1) * solve(r2);
	else {
		if (p)
			res = 0;
		else
			res = solve(r2);
	}
	printf("%lld", res);
}

Measured memory_bytes: 128
import bisect

words = lambda t : list(map(t, input().split()))
n = int(input())
a = []
for i in range(n):
    a.append(-1 * int(input()))

b = []
b.append(a[0])

for i in range(1,n):
    x = a[i]
    x_ind = bisect.bisect_right(b,x)
    #print(x, x_ind, b)
    if x_ind >= len(b):
        b.append(x)
    else:
        b[x_ind] = x

print(len(b))


Measured memory_bytes: 55768
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
template<class T> inline bool chmax( T &a, const T &b ) {return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL n, k;
    cin >> n >> k;
    vector<LL> a(n);
    REP(i,n) cin >> a[i];
    LL x=0;
    for (int i=40; i>=0; i--) {
        if ( (x|(1LL<<i))>k ) continue;
        int cnt=0;
        REP(j,n) {
            if ( (a[j]>>i) & 1 ) cnt++;
        }
        if ( cnt*2<n ) x |= (1LL<<i);
    }
    LL ans=0;
    REP(i,n) {
        ans += ( a[i]^x );
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1024
from functools import lru_cache
import sys 
sys.setrecursionlimit(2147483647)

N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

#@lru_cache(None)
def dfs(d,pre):
    if (d,pre) in dic: return dic[(d,pre)]
    if d < 0:
        dic[(d,pre)] = 0 
        return 0
    ma = 0 
    for idx,a in enumerate(A[d]):
        if idx != pre:
            res = dfs(d - 1,idx) + a 
            ma = max(res,ma)
    dic[(d,pre)] = ma
    return dic[(d,pre)]
dic = {}
res = dfs(N-1,-1)
print(res)



Measured memory_bytes: 154708
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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



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

  int h,w;
	cin >> h >> w;

	vector<vector<char>> s( h, vector<char>(w));
	rep(i,h) rep(j,w) cin >> s[i][j];

	vector<vector<int>> t(h, vector<int>(w,INF));
	rep(k, h + w - 1) rep(i, k + 1) {
		int j = k - i;
		if (i < 0 || i >= h || j < 0 || j >= w) continue;
		if (i == 0 && j == 0)  t[0][0] = s[0][0] == '.' ? 0 : 1;
		else {
			if (i - 1 >= 0) {
				if (s[i-1][j] == '.' && s[i][j] == '#') {
					chmin(t[i][j], t[i - 1][j] + 1);
				}
				else chmin(t[i][j], t[i - 1][j]);
			}
			if (j - 1 >= 0) {
				if (s[i][j-1] == '.' && s[i][j] == '#') {
					chmin(t[i][j], t[i][j-1] + 1);
				}
				else chmin(t[i][j], t[i][j-1]);
			}
		}
	}

	cout << t[h-1][w-1] << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long ll;
const int INF=100000000;
const int MOD=1000000007;
 
vector<int> g[200010];
int bg[400000],ed[400000];
int k=0;
int x[200010]={0};
ll ans[200010]={0};
 
void dfs(int v,int p)
{
	x[v]+=x[p];
	for(int i=0;i<g[v].size();i++)
	{
		if(g[v][i]!=p){
		dfs(g[v][i],v);
		}
	}
}
 
 
int main()
{
 int n,q;
 cin >> n >> q;
 for(int i=0;i<n-1;i++){
   int a,b;
   cin >> a >> b;
   g[a].push_back(b);
   g[b].push_back(a);
 }    
 for(int i=0;i<q;i++){
   int a,b;
   cin >> a >> b;
   x[a]+=b;
 }
    
 dfs(1,0);

  for(int i=1;i<n+1;i++) cout << x[i] << " ";
  return 0;
}

Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> v(3);
  cin>>v.at(0)>>v.at(1)>>v.at(2);
  sort(v.begin(),v.end());
  if(v.at(0)==5 && v.at(1)==5 && v.at(2)==7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int D = in.nextInt();
        int N = in.nextInt();
        if (N == 100)
            ++N;

        int ans = N;
        for (int i = 0; i < D; ++i)
            ans *= 100;

        System.out.println(ans);
    }
}

Measured memory_bytes: 21972