akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	double a, b, c;
	double d, e, f;
	double x, y;
	
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		
		y = (c * d - a * f) / (b * d - a * e) + 0.0001;
		x = (c - b * y) / a + 0.0001;
		
		
		printf("%.3lf %.3lf\n", x, y);
	}
	
	return (0);
}

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

int main()
{
    int a,ac=0,wa=0,tle=0,re=0;
    string b;
    cin>>a;
    for(int i = 1;i<=a;i++){
        cin>>b;
        if(b == "AC"){
            ac++;
        }
        else if(b == "WA"){
            wa++;
        }
        else if(b == "TLE"){
            tle++;
        }
        else {
            re++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;

    return 0;
}

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

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

  int H; cin >> H;
  int W; cin >> W;
  int K; cin >> K;

  int c = 0;
  vector<vector<int>> cells(H, vector<int>(W, 0));
  for (int i = 0; i < H; i++) {
    string s; cin >> s;
    for (int j = 0; j < W; j++) {
      if (s[j] == '#') {
        c++;
        cells[i][j] = c;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 1; j < W; j++) {
      if (cells[i][j] == 0) {
        cells[i][j] = cells[i][j - 1];
      }
    }
    for (int j = W - 2; j >= 0; j--) {
      if (cells[i][j] == 0) {
        cells[i][j] = cells[i][j + 1];
      }
    }
  }

  for (int j = 0; j < W; j++) {
    for (int i = 1; i < H; i++) {
      if (cells[i][j] == 0) {
        cells[i][j] = cells[i - 1][j];
      }
    }
    for (int i = H - 2; i >= 0; i--) {
      if (cells[i][j] == 0) {
        cells[i][j] = cells[i + 1][j];
      }
    }
  }

  for (int i = 0; i < H; i++) {
    cout << cells[i][0];
    for (int j = 1; j < W; j++) {
      cout << " " << cells[i][j];
    }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
long int dp[11][11][11];
long int n,m,q;
long int ans=0;
void fun(long int ind,long int val,long int sum,vector<int> a)
{
    if(ind==n)
    {
        ans=max(ans,sum);
        return ;
    }
    if(val>m)
    return ;
    vector<int> b=a;
    for(long int i=val;i<=m;i++)
    {
        long int ss=sum;
         b.push_back(i);
         for(long int j=0;j<ind;j++)
         {
            ss+=dp[ind][j][i-b[j]];
         }
         fun(ind+1,i,ss,b);
         b.pop_back();
    }
}
int main()
{
  long int n,k;
  cin>>n>>k;
  long int d;
  long int b[n+1]={0};
  long int aa;
    for(long int i=0;i<k;i++)
    {
          cin>>d;
        for(long int j=0;j<d;j++)
        {
        cin>>aa;
        b[aa]++;
        }
    }
    long int ans=0;
    for(long int i=1;i<=n;i++)
    if(!b[i]) ans++;
    cout<<ans;
}


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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var N = ReadInt();
            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                var lr = ReadSplitInt();
                ans += lr[1] - lr[0] + 1;
            }
            Console.WriteLine(ans);
        }

        public static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        public static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        public static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        public static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(Read());
        }

        public static long ReadLong()
        {
            return long.Parse(Read());
        }

        public static IList<string> ReadSplit()
        {
            return Read().Split().ToList();
        }

        public static IList<int> ReadSplitInt()
        {
            return Read().Split().Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 11220
tmp = require("fs").readFileSync("/dev/stdin","utf8").trim();
let m = tmp.split(" ")[0];
let d = tmp.split(" ")[1];
cnt = 0;
for (i=1;i<=m;i++){
  for (j=1;j<=d;j++){
    if (parseInt(j/10)*(j%10)==i && j%10>=2 && parseInt(j/10)>=2){
      cnt+=1;
    }
  }
}
console.log(cnt);

Measured memory_bytes: 32760
#include<iostream>

using namespace std;
int main(){
	int S,h,m,s;
	cin >> S;
	h=S/3600;
	m=(S-(h*3600))/60;
	s=S-(h*3600+m*60);
	cout<<h<<":"<<m<<":"<<s<<endl;
	

	return 0;
}

Measured memory_bytes: 1164
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }

inline ll Msq(ll x){ return (x*x) %MOD; }
inline ll Mpot(ll x, ll e){
	if(!e) return 1;
	return Msq(Mpot(x, e>>1)) * (e & 1 ? x : 1)%MOD;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////


int main(){
	int X; scan(X);
	int cur = X, ans = 1;
	while(cur != 0){
		cur = (cur+X)%360;
		ans++;
	}
	printf("%d\n", ans);

}


Measured memory_bytes: 3808
N = int(input())
A = list(map(int, input().split()))

while len(A) > 1:
    m = min(A)
    m_i = A.index(m)
    for i in range(len(A)):
        if i != m_i:
            A[i] = A[i] % m

    A = [a for a in A if a != 0]

print(A[0])

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
vector<int> hako;
vector<int> shako;
int main(){
  int n;
  cin >> n;
  rep(i,0,n){
    int a;
    cin >> a;
    shako.push_back(a);
    hako.push_back(a);
  }
  sort(shako.begin(),shako.end());
  int count = 0;
  rep(i,0,hako.size()){
    if(hako[i] != shako[i])count++;
  }
  if(count == 2 or count == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
//#include<bits/stdc++.h>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, string> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+10;
void FAST(){ios::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr);}
const ll mod =  1e9+7;

int n, m, k, x;
int c[20];
int a[20][20];

void solve()
{
   scanf("%d%d%d", &n, &m, &x);
   for(int i = 1; i <= n; ++i) {
        scanf("%d", &c[i]);
        for(int j = 1; j <= m; ++j)
            scanf("%d", &a[i][j]);
   }
   int ans = inf;
   for(int i = 0; i < (1<<n); ++i) {
    int t = i;
    int sum = 0;
    int num[13] = {0};
    for(int j = 1; j <= n; ++j) {
        if(t&1) {
            sum += c[j];
            for(int q = 1; q <= m; ++q)
                num[q] += a[j][q];
        }
        t>>=1;
    }
    int flag = 0;
    for(int j = 1; j <= m; ++j) {
        if(num[j] < x) {
            flag = 1;break;
        }
    }
    if(flag) continue;
    ans = min(sum, ans);
   }
   if(ans == inf) ans = -1;
   printf("%d\n", ans);
}

int main()
{
//    init();
//    int _;scanf("%d", &_); while(_--)
    solve();
    return 0;
}


Measured memory_bytes: 3820
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
	"log"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc148c(a int,b int) int{
	if b == 0{
		return a
	}
	return abc148c(b,a%b)
}
 
func main(){
	a := 0
	b := 0
	fmt.Scan(&a)
	fmt.Scan(&b)
	c:= abc148c(a,b)
	fmt.Println(a*b/c)
}

//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}

Measured memory_bytes: 640
import collections

N=int(input())
A_data=list(map(int,input().split()))
mod=10**9+7

A=collections.Counter(A_data)

if N%2==1:
    if not A[0]==1:
        print(0)
        exit()
    else:
        for i in range(2,N,2):
            if not A[i]==2:
                print(0)
                exit()

elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            print(0)
            exit()

print(2**(N//2)%mod)

Measured memory_bytes: 14820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n;
  cin >> n;
  ll ans = -1;
  ll num = 0;
  for (ll i = 1; i <= n; i++){
    ll count = 0;
    ll a = i;
    while (a % 2 == 0){
      a /= 2;
      count++;
    }
    if(ans<count){
      num = i;
    }
    chmax(ans, count);
  }
  print(num);
}

Measured memory_bytes: 256
H, W = map(int, input().split())
lst = [[0 for x in range(W)] for y in range(H)]

for i in range(H):
  x = input().split()
  x = list(x[0])
  for j,l in enumerate(x):
    lst[i][j] = l

for i in range(H):
  for j in range(W):
    checker = []
    if lst[i][j] == '#':
      if i != 0:
        num = 1 if lst[i - 1][j] == '.' else 0
        checker.append(num)
      if i != H - 1:
        num = 1 if lst[i + 1][j] == '.' else 0
        checker.append(num)
      if j != 0:
        num = 1 if lst[i][j - 1] == '.' else 0
        checker.append(num)
      if j != W - 1:
        num = 1 if lst[i][j + 1] == '.' else 0
        checker.append(num)
    
    if len(checker) == sum(checker) and len(checker) != 0:
      print('No')
      exit()

print('Yes')

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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> hune(2, vector<ll>(n, 0));
    for(ll i = 0; i < m; i++){
        ll a,b;
        cin >> a >> b;
        if(min(a, b) == 1) hune[0][max(a, b) - 1] = 1;
        if(max(a, b) == n) hune[1][min(a, b) - 1] = 1;
    }
    bool f = false;
    for(ll i = 0; i < n; i++){
        if(hune[0][i] + hune[1][i] == 2){
            f = true;
            break;
        }
    }
    if(f) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
}

Measured memory_bytes: 7836
import kotlin.math.sqrt

//import lib.primeAndIndex

fun primeAndIndex(n : Long): MutableMap<Long, Int> {
    var primeAndIndex: MutableMap<Long, Int> = mutableMapOf()
    var tmp = n
    var i = 2L
    while (tmp != 1L) {
        //println(tmp)
        var indexCount = 0
        while (tmp % i == 0L) {
            tmp /= i
            indexCount++
            //println(tmp)
        }
        //println("end")
        if (indexCount > 0) primeAndIndex[i] = indexCount
        i++
        if (i >= sqrt(n.toDouble())) {
            primeAndIndex[n] = 1
            break
        }
        //println(primeAndIndex)
        //println(tmp)
        //println(i)
    }
    return primeAndIndex
}


fun main(){
    val n = readLine()!!.toLong()
    if(n == 1L){
        println(0)
        return
    }
    val primeAndIndex =  primeAndIndex(n)
    //println(primeAndIndex)
    var count = 0
    primeAndIndex.forEach{
        var sub = 1
        var value = it.value
        while(true){
            //println("$value,$sub")
            if(value >= sub){
                count++
                value -= sub
                sub++
            }else{
                break
            }
        }
    }
    println(count)
}

Measured memory_bytes: 34512
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#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 <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  int64_t n, k;
  cin >> n >> k;

  cout << min(n%k, abs(n%k-k)) << endl;
  return 0;
}

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

using namespace std;

long long int ar[1000000],m[1000000],m2[1000000];

void _seive_ (long long int n)
{
    long long int i,j;
    for (i=2;i<=n;++i){

        for (j=(i*i);j<=n;j+=i){

            ar[j-1]=1;

        }
    }
    j=0;
    m2[1]=2;
    for (i=2;i<=n;++i){

        if(ar[i-1]==0){

            ++j;
            m[j]=i;
            if(j>1){

                m2[j]= m[j]+m2[j-1];

            }
        }
    }

    return ;
}

int main()
{
   long long int num;

   _seive_(1000000);
   while(scanf("%lld",&num)==1 && num!=0) {

        cout<<m2[num]<<endl;

   }

   return 0;

}




































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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    bitset<26> b;
    for (auto &c : s) {
        if (b[c - 'a']) {
            cout << "no\n";
            return 0;
        }
        b[c - 'a'] = true;
    }
    cout << "yes\n";
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


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

int main(){
    int N;
    cin >> N;
    long max=0;
    long min=10000000000;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(min>a)
            min = a;
        if(max<a)
            max = a;
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
// const int N = ;

int n, x, t;

int up(int x, int y) {
    return x % y == 0 ? x / y : x / y + 1;
}

void solve() {
    cin >> n >> x >> t;
    cout << t * up(n, x) << "\n";
}


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

Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;

int data[100][2];
int num[100][2];
int m,n;
vector<int> ans;
int go(){
	for(int i = 0 ; i < m ; i++){
		for(int j = 0 ; j < 2 ; j++){
			if(data[i][j] > 0) data[i][j]--;
		}
	}
	for(int i = 0 ; i < m ; i++){
		for(int j = 0 ; j < 2 ; j++){
			if(j == 0){
				if(data[i][j] == 0)
					data[i][j] = -1 , ans.push_back(num[i][j]);
			}else{
				if(data[i][j] == 0 && data[i][0] ==  -1)
					data[i][j] = -1 , ans.push_back(num[i][j]);
			}
		}
	}
}
int view(){
	for(int j = 0 ; j < 2; j++){
		for(int i = 0 ; i < n ; i++)
			cout << data[i][j] << " ";
		cout << endl;
	}
	cout << "------" << endl;
}
int find(int t,int p){
	for(int i = 0 ; i < m ; i++){
		if(data[i][1] == -1){ data[i][1] = t; num[i][1] = p; return 0;}
	}
	int s = -1;
	for(int i = 0 ; i < m ; i++){
		if(data[i][0] != -1 || data[i][1] < t) continue;
		if( s == -1 || data[i][1] < data[s][1] ){ 
			s = i;
		}
	}
	if(s != -1){
		data[s][0] = t;
		num[s][0] = p;
		return 1;
	}

	for(int i = 0 ; i < m ; i++){
		if(data[i][0] != -1) continue;
		if( s == -1 || data[i][1] > data[s][1] ){ 
			s = i;
		}
	}
	if(s != -1){
		data[s][0] = t;
		 num[s][0] = p; 
		return 2;
	}
	
	return -1;

}

int main(){
	while(cin >> m >> n , m){
		queue<int> Q1,Q2;
		ans.clear();
		memset(data,-1,sizeof(data));
		for(int i = 0 ; i < n ; i++){
			int t; cin >> t;
			Q1.push(t);
			Q2.push(i);
			if(~find(Q1.front(),Q2.front())) Q1.pop() , Q2.pop();
			//view();
			for(int w = 0 ; w < 10 ; w++){
				go();
				if(Q1.size())
					if(~find(Q1.front(),Q2.front())) Q1.pop() , Q2.pop();
			}
		}
		while(Q1.size()){
			if(~find(Q1.front(),Q2.front())) Q1.pop() , Q2.pop();
			go();
		}
		while(ans.size() < n){
			go();
			//view();
		}
		for(int i = 0 ; i < n ; i++)
			cout << ans[i]+1 << (i==n-1?"\n":" ");
	}
}

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

using namespace std;
using LL = long long;

const int maxn = 200200;
LL n, a[maxn];
map<LL, LL> vis;

signed main() {
  // freopen("in", "r", stdin);
  vis.clear();
  scanf("%lld", &n);
  LL ret = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    vis[i - a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    ret += vis[i + a[i]];
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 27808
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] != t[i]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}



Measured memory_bytes: 3652
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    elif op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    vector<float> v(N);
    REP(i,N) cin >> v[i];
    float ans;
    REP(i,N){
        sort(v.begin(), v.end());
        if(v[1] == 1010) ans = v[0];
        v[1] = (v[0] + v[1]) / 2;
        v[0] = 1010;
    }
    cout << ans << endl;
}

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

int main(void){
    string S;
    bool c_flag=false, f_flag=false;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'C')  c_flag = true;
        if (S[i] == 'F' && c_flag)  f_flag = true;
    }
    
    if (c_flag && f_flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
}

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

using namespace std;

int main(){
  vector<int> vec;
  int x;
  while(cin>>x) {
  	vec.push_back(x); 
  }
  vec.erase(vec.begin());
  int counter = -1;
  bool isOdd = true;
  while (isOdd) {
    counter++;
    for(auto &a: vec) {
      if (a % 2 == 1) {
        isOdd = false;
        break;
      }
      a = a / 2;
    }
  }
  printf("%d", counter);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

const int SIZE=110000;
struct P{
    string name;
    int time;
};
P Q[SIZE];
int head,tail;

void enqueue(P x){
    Q[tail]=x;
    ++tail;
    if(tail==SIZE) tail=0;
}

P dequeue(){
    P x=Q[head];
    ++head;
    if(head==SIZE) head=0;
    return x;
}

int main()
{
    int n,q;
    cin >> n >> q;
    P T;
    F(i,0,n){
        cin >> T.name >> T.time;
        enqueue(T);
    }
    P U;
    int elaps=0;
    while(head!=tail){
        U=dequeue();
        if(U.time>q){
            elaps+=q;
            U.time-=q;
            enqueue(U);
        }
        else{
            elaps+=U.time;
            cout << U.name << " " << elaps << endl;
        }
    }
    return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

typedef long long ll;

const int INF = 1e+9;
const int H_MAX=300;
const int W_MAX=300;

int H,W,D;


vector<pair<int,int>> V(H_MAX*W_MAX+1);

int solve(int s,int e,vector<vector<int>> &memo){
    if(memo[s][e]<INF) return memo[s][e];
    int res;
    int x_cur,y_cur,x_next,y_next;
    if(e==0) return memo[s][e]=0;

    x_cur=V[s+D*(e-1)].first;
    y_cur=V[s+D*(e-1)].second;
    x_next=V[s+D*e].first;
    y_next=V[s+D*e].second;

    res=solve(s,e-1,memo)+abs(x_cur-x_next)+abs(y_cur-y_next); 
    return memo[s][e]=res;
}

int main(){
    cin >> H >> W >> D;
    vector<vector<int>> memo(D+1,vector<int>((H*W)/D+1,INF));

    int a;
    rep(i,H){
        rep(j,W){
            cin >> a;
            V[a]={i,j};
        }
    }

    


    int Q;
    int ans;
    cin >> Q;
    vector<int> L(Q),R(Q);

    rep(i,Q) cin >> L[i] >> R[i];
    int start,true_end,nise_end;
    rep(i,Q){
        start=L[i]%D;
        if(start==0) start+=D;
 
        true_end=(R[i]-start)/D;
        nise_end=(L[i]-start)/D;

        cout << solve(start,true_end,memo)-solve(start,nise_end,memo) << endl;
    }

    return 0;
}


Measured memory_bytes: 10400
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 101;
int n, w, v[maxn], tot[maxn];

int main() {
	while (scanf("%d%d", &n, &w) != EOF) {
		if (n == 0) break;
		for (int i = 1; i <= n; ++i) {
			scanf("%d", v + i);
		}
		sort(v + 1, v + 1 + n);
		int cnt = v[n] / w + 1;
		memset(tot, 0, sizeof(tot));
		for (int i = 1; i <= n; ++i) {
			tot[v[i] / w] += 1;
		}
		int height = *max_element(tot, tot + cnt);
		double ans = 0;
		for (int i = 0; i < cnt; ++i) {
			ans += (double)tot[i] / height * (1 - (double)i / (cnt - 1));
		}
		ans += 0.01;
		printf("%.10lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
int n,A[50];
int solve(int i,int m){
    if(m == 0)
    return 1;
    if(i >= n)
    return 0;
    int res = solve(i + 1,m) || solve(i +1,m-A[i]);
    return res;
}
int main(){
    int q,M,i;
    scanf("%d",&n);
    for(i = 0;i < n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i = 0;i < q;i++){
        scanf("%d",&M);
        if(solve(0,M))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



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

using namespace std;

int main()
{
    int n,c=0; string s;
    cin >> n >> s;
    
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            c++;
    }
    
    cout << c << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

ll sum(ll A) {
	ll s = 0;
	while (A > 0) {
		s += A % 10;
		A /= 10;
	}
	return s;
}

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

	ll ans = INT_MAX;
	for (int i = 1; i < N; i++) {
		ll k = N - i;
		ans = min(ans, sum(i) + sum(k));
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
#define br "\n"
#define MAX  1000001
#define ff first
#define ss second

ll mod = 1e9 + 7;

void solve(){
  ll n,k,d;
  cin >> n >> k >> d;
  n = abs(n);
  ll kc = k,dc = d;
  ll ck=0,dk=0;
  while(kc > (ll)10){ 
    kc /= (ll)10;
    ck++;
  }
  while(dc > (ll)10){ 
    dc /= (ll)10;
    dk++;
  }
  if(ck + dk <= 15 && n >= k*d){
    n = n - k*d;
  }
  else{
    ll rem = n/d;
    n  = n - rem*d;
    k = k - rem;
    if(abs(n - d) < n){
      n = abs(n - d);
      k--;
    }
    if(k % 2 != 0) n = min(abs(n - d),abs(n + d));
  }
  cout << n << br;


}
	

int main(){
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif  
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}

Measured memory_bytes: 3640
#include <cstring>
#include <cstdio>
constexpr int MOD = 1e9 + 7;
char str[100005];
int nxt[100005][3], dp[100005], sum[100005];
int main()
{
	// freopen("AGC027-E.in", "r", stdin);
	scanf("%s", str);
	int n = strlen(str), ans = 0;
	bool flg = true;
	for (int i = 1; i < n; i++)
		flg &= str[i] != str[i - 1];
	if (flg)
	{
		puts("1");
		return 0;
	}
	for (int i = 0; i < n; i++)
		sum[i] = ((i ? sum[i - 1] : 0) + (str[i] - 'a' + 1)) % 3;
	nxt[n][0] = nxt[n][1] = nxt[n][2] = n;
	for (int i = n - 1; i >= 0; i--)
	{
		memcpy(nxt[i], nxt[i + 1], sizeof(nxt[i + 1]));
		nxt[i][sum[i]] = i;
	}
	dp[0] = 1;
	for (int i = 0; i < n; i++)
	{
		int x = i ? sum[i - 1] : 0;
		for (int j = 0; j < 3; j++)
		{
			if (j == x)
				continue;
			int y = nxt[i][j];
			if (y < n)
				(dp[y + 1] += dp[i]) %= MOD;
		}
		if (sum[i] == sum[n - 1])
			(ans += dp[i + 1]) %= MOD;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
int main(){

  int x,y,r;

  scanf("%d%d",&x,&y);

  if(y<x){  
    while(y>0){
      r=x%y;
      x=y;
      y=r;
    }
  }
  if(x<y){
while(x>0){
      r=y%x;
      y=x;
      x=r;
    }
  }
  if(y<x) printf("%d\n",x);
  else   printf("%d\n",y);
return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a >= b) {
        rep(i,a) {
        cout << b;
    }
    } else {
        rep(i,b) cout << a;
    }
    cout << endl;
}

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

for _ in range(day_n):

    bath_p, pool_p, bath_n, pool_n = map(int, input().split())

    normal_sum = bath_p * bath_n + pool_p * pool_n
    
    if bath_n >= 5 and pool_n >= 2:
        print(int(normal_sum * 0.8))
    else:
        discounted_sum = normal_sum
        
        if bath_n < 5:
            discounted_sum += bath_p * (5 - bath_n)
        
        if pool_n < 2:
            discounted_sum += pool_p * (2 - pool_n)
        
        discounted_sum *= 0.8
        
        print(int(min(normal_sum, discounted_sum)))


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

    int n,m;
    cin >> n >> m;
    int mn = 0;
    int mx = n;
    rep(i,m){
        int l,r;
        cin >> l >> r;
        mn = max(mn,l);
        mx = min(mx,r);
    }
    if(mn > mx) cout << 0 << endl;
    else cout << mx - mn + 1 <<endl;
    return 0;
}

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


int main(){
	int a,b,c,d,k,sum=0;
	cin >> a >> b >> c >> d >> k;
	sum=c-a;
	if(d>b){
		sum--;
		sum=sum*60+60-b+d;
	}
	else{
		sum=sum*60+d-b;
	}
	
	if(sum>=k) cout << sum-k << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3676
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		br.readLine();
		String line = br.readLine();
		List<String> l = Arrays.asList(line.split(" "));
		Collections.reverse(l);
		for (int i = 0; i < l.size(); i++) {
			if (i != 0)
				System.out.print(" ");
			System.out.print(l.get(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 16912
n = gets.to_i

if n == 3
    puts "2 5 63"
elsif n == 4
    puts "2 5 20 63"
else
    ans = [2, 4]
    n -= 2

    i = -3
    while n > 1
        break if i + 12 > 30_000
        n -= 2
        ans << i += 6
        ans << i += 6
    end

    j = 30_002
    while n > 2
        n -= 3
        ans << j -= 2
        ans << j -= 2
        ans << j -= 2
    end

    if n == 2
        ans += [8, 10]
    elsif n == 1
        ans << 6
    end

    puts ans * " "
end


Measured memory_bytes: 14616
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

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

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int r;
	cin >> r;
	double pi = acos(-1);
	cout << 2.0 * pi * r << endl;			
}

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


void solve(long long D, long long N){
    if (N == 100)
        N++;
    if(D == 0)
        cout << N << endl;
    else if(D == 1)
        cout << N * 100 << endl;
    else 
        cout << N * 10000 << endl;
}

int main(){
    long long D;
    scanf("%lld",&D);
    long long N;
    scanf("%lld",&N);
    solve(D, N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int  h,w,x,y,r;
	cin>>h>>w>>x>>y>>r;
	Yn((y-r)>=0&&(y+r)<=w&&(x-r)>=0&&(x+r)<=h);
}




Measured memory_bytes: 3212
#include <iostream>

int main()
{
	int n, m, x, a[1000], count1 = 0, count2 = 0;
	std::cin >> n >> m >> x;
	for(int i = 0; i < m; i++)
	{
		std::cin >> a[i];
	}
	for(int i = x; i > 0; i--)
	{
		for(int j = 0; j < x; j++)
		{
			if(i == a[j])
			{
				count1++;
			}
		}
	}
	if(n < x)
	{
		for(int i = x; i <= n; i--)
		{
			for(int j = 0; j < m; j++)
			{
				if(i == a[j])
				{
					count2++;
				}
			}
		}
	}else{
		for(int i = x; i <= n; i++)
		{
			for(int j = 0; j < m; j++)
			{
				if(i == a[j])
				{
					count2++;
				}
			}
		}
	}
	if(count1 < count2)
	{
		std::cout << count1 << std::endl;
	}else{
		std::cout << count2 << std::endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,par[200005];
int find(int x)
{
	if (par[x]!=x)
	par[x]=find(par[x]);
	return par[x];
}
bool Union(int x,int y)
{
	x=find(x);
	y=find(y);
	if (x==y)
	return 0;
	par[x]=y;
	return 1;
}
void add(int x,int y)
{
	if (Union(x,y))
	printf("%d %d\n",x,y);
}
void one(int x,int y)
{
	add(x,y);
	add(y,1);
	add(1,x+n);
	add(x+n,y+n);
}
void bits(int x)
{
	int l=-1;
	for (int i=0;i<18;i++)
	{
		if (x&(1<<i))
		{
			if (l==-1)
			add(x,(1<<i));
			else
			add((1<<l),(1<<i));
			l=i;
		}
	}
	add((1<<l),x+n);
}
int main()
{
	scanf("%d",&n);
	if (!(n&(n-1)))
	{
		printf("No");
		return 0;
	}
	printf("Yes\n");
	for (int i=1;i<=2*n;i++)
	par[i]=i;
	add(1,2);
	add(2,3);
	add(3,n+1);
	add(n+1,n+2);
	add(n+2,n+3);
	if (n%4==0)
	bits(n);
	if (n%4==1)
	one(n-1,n);
	if (n%4==2)
	{
		add(n-1,1);
		add(n,3);
		add(n-2,n);
		add(2*n-2,n+1);
		add(2*n-1,2*n-2);
		add(2*n,2*n-2);
	}
	for (int i=4;i<=n-3;i+=4)
	{
		add(i,i+1);
		add(i+1,i+2);
		add(i+2,i+3);
		add(i+3,n+i);
		add(n+i,n+i+1);
		add(n+i+1,n+i+2);
		add(n+i+2,n+i+3);
		add(i,i-4+(i==4));
	}
}

Measured memory_bytes: 3456
N,W = list(map(int,input().split()))
w = [0]
v = [0]

for i in range(N):
  a,b = list(map(int,input().split()))
  w.append(a)
  v.append(b)
  
# dp[i][w] = v
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(1,N+1):
  for j in range(1,W+1):
    if j < w[i]:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i])  # max(iの品を使わない時, iの品を使う時)

print(dp[N][W])

Measured memory_bytes: 120684
import sys
input = lambda: sys.stdin.readline().rstrip() 

def combMod(n, r, p):
    numer = 1
    denom = 1
    for i in range(1, r+1):
        numer = numer * (n-r+i) % p
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

def resolve():
    n, a, b = map(int, input().split())
    mod = 10**9+7
    print((pow(2, n, mod) - 1 - combMod(n, a, mod) - combMod(n, b, mod)) % mod)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

bool isWolf[100005];
int main(){

    ios :: sync_with_stdio(false);
    int N;
    string s;
    cin >> N >> s;

    REP(d,4){
        int x = d/2, y = d%2;
        FOR(i,N){
            isWolf[i] = y;
            if(s[i-1] == 'o' && isWolf[i]) x ^= 1;
            if(s[i-1] == 'x' && !isWolf[i]) x ^= 1;
            swap(x,y);
        }
        if(x==d/2 && y==d%2){
            FOR(i,N){
                cout << (isWolf[i] ? 'W' : 'S');
            }
            cout << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <fstream>
#include <climits>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <deque>
#include <map>
using namespace std;

typedef long long ll;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define forn(i,n) for(int i=0; i<int(n); i++)
#define for1(i,n) for(int i=1; i<=int(n); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void no(int ex = -1) {
	cout << ex << endl;
	//cout << "NO" << endl;
	//exit(0);
}
void bl(bool win) {
	if (win) cout << "YES"; else cout << "NO";
	cout << endl;
}

const int N = 2020;
const ll INF = LLONG_MAX;
const int mod = 998244353;

/*vector<bool> pr;
void prime() {
	int EDGE = 1000;
	pr.assign(EDGE, true);
	pr[0] = false; pr[1] = false;
	for (int i = 2; i < EDGE; i++) {
		if (pr[i])
			if (1LL * i * i < EDGE)
				for (int j = i * i; j < EDGE; j += i)
					pr[j] = false;
	}
}*/
//prime


ll T;

int main() {
	IOS;
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ll n, m, cnt = 0;
	cin >> n;
	vector<ll> pw(N);
	forn(i, N) {
		pw[i] = pow(i, 5);
	}
	for (int i = -N+1; i < N; i++) {
		for (int j = -N+1; j < N; j++) {
			ll q, w;
			if (i < 0) { q = -pw[-i]; }
			else q = pw[i];
			if (j < 0) { w = -pw[-j]; }
			else w = pw[j];
			if (q - w == n) { cout << i << " " << j; return 0; }
		}
	}
}

Measured memory_bytes: 3688
def main():
    N, M, X, Y = map(int, input().split())
    x_data = list(map(int, input().split()))
    y_data = list(map(int, input().split()))

    z = min(Y, min(y_data))
    if max(X, max(x_data)) < z:
        print('No War')
    else:
        print('War')



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n,k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("")
l = 0
r = -1
max = 0
zero = 0
pre = ""
while zero < k && r < n-1
  r += 1
  if s[r] == "1"
    if pre == "0"
      zero += 1
      if zero >= k
        while r < n-1
          if s[r+1] == "1"
            r += 1
          else
            break
          end
        end
      end
    end
  end
  pre = s[r]
end
if zero < k
  puts n
  exit
end
max = r - l + 1
pre = s[0]
while r < n-1
  l += 1
  if s[l] == "1" && pre == "0"
    nextzero = false
    pre = s[r]
    while !nextzero && r < n-1
      r += 1
      if s[r] == "1"
        if pre == "0"
          nextzero = true
          while r < n-1
            if s[r+1] == "1"
              r += 1
            else
              break
            end
          end
        end
      end
      pre = s[r]
    end
  end
  pre = s[l]
  max = [max,r-l+1].max
end
puts max


Measured memory_bytes: 22772
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  vi A(N);
  cin >> A;

  i64 ans = 0;
  rep(i,N){
    if(A[A[i]-1]-1==i) ans++;
  }
  cout << ans/2 << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    int n; cin >> n;
    double sum_y=0, sum_b=0;
    for(int i=0; i<n; ++i){
        double x; string u; cin >> x >> u;
        if(u[0]=='J'){
            sum_y+=x;
        } else{
            sum_b+=x;
        }
    }
    cout << sum_y+sum_b*380000 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }

vector<P>E[100000];
int d[100000],b[100000],cnt[200001],u[200000],v[200000],r[200000];
int main(){
	int n,m,q;reader(n);reader(m);reader(q);
	rep(i,m){
		reader(u[i]);reader(v[i]);u[i]--;v[i]--;r[i]=q;
	}
	rep(i,q){
		int a;reader(a);r[a-1]=i;
	}
	rep(i,m){
		E[u[i]].emplace_back(P(v[i],r[i]));E[v[i]].emplace_back(P(u[i],r[i]));
	}
	d[0]=1;b[0]=q;
	queue<int>que;que.emplace(0);
	while(!que.empty()){
		int p=que.front();que.pop();
		for(P v:E[p]){
			if(d[v.first]==0){
				d[v.first]=d[p]+1;que.emplace(v.first);
			}
			if(d[v.first]==d[p]+1)
				b[v.first]=max(b[v.first],min(b[p],v.second));
		}
	}
	rep(i,n)cnt[b[i]]++;
	int ans=0;
	rep(i,q){
		ans+=cnt[i];
		writer(ans,'\n');
	}
}

Measured memory_bytes: 15484