akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


//
// Main
//

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let p = (n - 1) * (n - 2) / 2; // comb(n-1, 2)

    if p < k {
        println!("-1");
    } else {
        let mut r = (n - 1) + p - k;

        println!("{}", r);

        'outer: for i in 1..(n + 1) {
            for j in 1..(n + 1) {
                if r == 0 {
                    break 'outer;
                }

                if i < j {
                    println!("{} {}", i, j);
                    r -= 1;
                }
            }
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  map<char,int> m;
  for(auto c:s) m[c]++;
  if(abs(m['a']-m['b'])<2&&abs(m['a']-m['c'])<2&&abs(m['c']-m['b'])<2) puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 512
s = str(input())
n = len(s)
s = s[::-1]
x, tot = 1, 0
m = 2019
ans = 0
cnt = [int() for _ in range(m)]
for i in range(n):
    cnt[tot] += 1
    tot += (int(s[i])) * x
    tot %= m
    ans += cnt[tot]
    x = x * 10 % m
print(ans)


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

int main(){
  int n;
  int total=0;
  cin >> n;
  vector<int> w(n);
  vector<int> sum(n);
  vector<int> z(n);
  for(int i=0;i<n;i++){
    cin >> w.at(i);
    total += w.at(i);
  }
  sum.at(0)=w.at(0);
  for(int i=1;i<n;i++){
    sum.at(i) = w.at(i)+sum.at(i-1);
  }
 
  for(int i=0;i<n;i++){
    z.at(i)=abs(total-2*sum.at(i));
  }
  
  sort(z.begin(),z.end());
  cout << z.at(0) << endl;
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement
n,m,q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

ans = 0
for i in combinations_with_replacement(range(1,m+1),n):
  t = 0
  for j in abcd:
    if i[j[1]-1] - i[j[0]-1] == j[2]:
      t += j[3]
  ans = max(ans, t)
print(ans)

Measured memory_bytes: 9128
n,m=map(int,input().split())
L=[]
R=[]
for i in range(m):
    l,r=map(int,input().split())
    L.append(l)
    R.append(r)
if max(L)>min(R):
    print(0)
else:
    print(min(R)-max(L)+1)

Measured memory_bytes: 11052
N, P = map(int, input().split())
S = input()
ans = 0
mod = [0]*P
if P==2 or P==5:
    for i in range(N):
        if int(S[i])%P==0:
            ans+=i+1
    print(ans)
else:
    un1 = 0
    un = 0
    for i in range(N-1, -1, -1):
        #a =int(S[i])*10**un + un1
        a =int(S[i])*pow(10,un,P)+(un1)%P
        un += 1
        un1 = a
        mod[a%P]+=1
    ans += mod[0]  
    for i in range(P):
        ans += mod[i]*(mod[i]-1)/2
    print(int(ans))

Measured memory_bytes: 41308
#include <iostream>
using namespace std;
int N;
struct Point{
int x, y, t;
} A[100005];
void Read()
{
    cin >> N;
    A[1] = {0, 0, 0};
    for(int i = 2; i <= N + 1; i++)
    {
        cin >> A[i].t >> A[i].x >> A[i].y;
    }
    ++N;
}
inline int mod(int x)
{
    return max(x, -x);
}
void Solve()
{
    for(int i = 1; i < N; i++)
    {
        int diff = A[i + 1].t - A[i].t;
        int dx = mod(A[i + 1].x - A[i].x);
        int dy = mod(A[i + 1].y - A[i].y);
        if(diff < dx + dy)
        {
            cout << "No\n";
            return;
        }
        if(diff % 2 != (dx + dy) % 2)
        {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
typedef long long ll;
using namespace std;
ll gcd(ll da,ll xiao)
{
        if(da<xiao)
                swap(da,xiao);
        while(xiao>0)
        {
               ll temp=xiao;
                xiao=da%xiao;
                da=temp;
        }
        return da;
}
int main()
{
       int n;
       while(scanf("%d",&n)!=EOF)
       {
               ll ans;
               scanf("%lld",&ans);
               for(int i=2;i<=n;i++)
               {
                       ll x;
                       scanf("%lld",&x);
                       ans=ans/gcd(ans,x)*x;
                      
               }
               cout<<ans<<endl;
       }

    return 0;
}


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

using namespace std;

int main(){
	string s;
	int c=0,max=0,b=0;
	cin >> s;
	for (int i = 0; i < 3; i++)
	{
		if(s[i]=='R'){
			b=0;
			c++;
		}else{
			if(max<c)
				max=c;
			c=0;
			b=1;
		}
	}
	if(b==0){
		if(max<c)
			max=c;
	}

	cout << max;
	
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
bool s[1005][1005],cnt[1005];
int n,m,a[1000005],b[1000005],ans;
int main()
{
    scanf("%d%d",&n,&m);
    for(reg int i=1;i<=m;i++)scanf("%d%d",&a[i],&b[i]);
    for(reg int i=1;i<=n;i++)
    {
        s[i][i]=1;
        for(reg int j=m;j>=1;j--)
        {
            reg bool x=s[i][a[j]],y=s[i][b[j]];
            if(x&y)
			{
				cnt[i]=1;
				break;
			}
            else if(x)s[i][b[j]]=1;
            else if(y)s[i][a[j]]=1;
        }
    }
    for(reg int i=1;i<n;i++)
    {
        if(cnt[i])continue;
        for(reg int j=i+1;j<=n;j++)
        {
            if(cnt[j])continue;
            reg int tmp=1;
            for(reg int k=1;k<=n;k++)if(s[i][k]&&s[j][k])tmp=0;
            ans+=tmp;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 6784
#include <stdio.h>

int main(void)
{
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)return 0;
		for(i=0 ; i<H ; i++){
			for(j=0 ; j<W ;j++)
				printf("#");
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 1756
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;

const ll INF = 9223372036854775807;
const int inf = 2147483647;

ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}


int main() {
    int n;
    int a[100000];
    cin >> n;
    REP(i,n){
        cin >> a[i];
    }
    ll res = 0;
    REP(i,n){
        res += a[i];
    }
    res -= n;
    put(res);
    return 0;
}


Measured memory_bytes: 256
// URL: https://atcoder.jp/contests/abc133/tasks/abc133_d

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n; io.getV(n);
  long[] a; io.getA(n, a);

  auto x = new long[](n);

  foreach (i, ai; a) x[0] += (-1)^^i * ai;
  x[0] /= 2;

  foreach (i; 1..n) x[i] = a[i-1]-x[i-1];
  x[] *= 2;

  io.put(x);
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.meta, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, ref T v)
  if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


Measured memory_bytes: 12488
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k, q;
	cin >> n >> k >> q;
	vector<ll> a(n);
	REP(i, n)  cin >> a[i];
	vector<ll> b = a;
	UNIQUE(b);
	sort(ALL(b));
	vector<bool> used(n, true);
	ll ans = INF;
	REP(i, b.size()) {
		REP(j, n) if(a[j] < b[i]) used[j] = false;
		ll l = b[i] - 1, r = INF;
		while(r - l > 1) {
			ll m = (l + r) / 2;
			ll cnt1 = 0, cnt2 = 0;
			vector<P> v;
			REP(j, n) {
				if(!used[j]) {
					v.pb(P(cnt1, cnt2));
					cnt1 = cnt2 = 0;
				} else {
					cnt1++;
					if(a[j] <= m) cnt2++;
				}
			}
			v.pb(P(cnt1, cnt2));
			ll cnt = 0;
			REP(j, v.size()) {
				cnt += max(0ll,min(v[j].first - k + 1, v[j].second));
			}
			if(cnt >= q) r = m;
			else l = m;
		}
		if(r != INF) ans = min(ans, r - b[i]);
	}
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 384
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    set<int> se;
    VI k(M), p(M);
    VVI s(M, VI(N));
    REP(i, M) {
        cin >> k[i];
        REP(j, k[i]) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    REP(i, M) {
        cin >> p[i];
    }
    ll ans = 0;
    REP(on, 1 << N) {
        bool b = true;
        for (int j = 0; j < M; j++) {
            int cnt = 0;
            for (int i = 0; i < k[j]; i++) {
                if (on & (1 << s[j][i])) cnt++;
            }
            if (cnt % 2 != p[j]) {
                b = false;
                break;
            }
        }
        if (b) ans++;
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 256
import sys
N,M=map(int, sys.stdin.readline().split())

mod=10**9+7
fact, inv_fact=[1], [1]
fact_tmp=1
for i in range(1, M+1):
    fact_tmp*=i
    fact_tmp%=mod
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, mod-2, mod))

def ncr(n,r):
	if n<0 or r<0 or n<r:	return 0
	else:   return (fact[n]*inv_fact[r]*inv_fact[n-r])%mod

def npr(n,r):
	if n<0 or r<0 or n<r:	return 0
	else:   return (fact[n]*inv_fact[n-r])%mod

ans=0
for k in range(N+1):
    if k%2==0: ans+=ncr(N,k)*ncr(M,k)*npr(k,k)*(npr(M-k,N-k)**2)
    else:      ans-=ncr(N,k)*ncr(M,k)*npr(k,k)*(npr(M-k,N-k)**2)
    ans%=mod
print ans

Measured memory_bytes: 159496
# C
import itertools

S = input()

ans = 0

ans += int(S)

for i in range(1, len(S)):
    for j in itertools.combinations(range(1,len(S)),i):
        aa = 0
        for k in j:
            ans += int(S[aa:k])
            aa = k
        ans += int(S[aa:len(S)])
print(ans) 


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[100100],n,k,g;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),g=__gcd(g,a[i]);
	if(k%g)return puts("IMPOSSIBLE"),0;
	else if(*max_element(a+1,a+n+1)<k)return puts("IMPOSSIBLE"),0;
	puts("POSSIBLE");
}

Measured memory_bytes: 640
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
string N;
int M;
int K;

int64_t recursive(int i, int k, bool f) {
  if (k == K) {
    return 1;
  } else if (i == M) {
    return 0;
  }
  int64_t ret = 0;
  int last = (N[i] - '0');
  if (!f) last = 9;
  for (int j = 0; j <= last; ++j) {
    // cout << "i=" << i << " N[i]=" << N[i] << " last=" << last << endl;
    int nk = (j == 0) ? k : k + 1;
    ret += recursive(i + 1, nk, f && (j == last));
  }
  return ret;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin >> N >> K;
  M = N.size();
  int64_t answer = recursive(0, 0, true);
  cout << answer << endl;
  return 0;
}


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

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

    char si1mojime[N];
    char dammy;
    scanf("%c", &dammy);
    int i;
    char buff[100];

    for (i = 0; i < N; i++){
        gets(buff);
        si1mojime[i] = buff[0];
        }

    /*
    for (i = 0; i < N; i++)
    {
        printf("%c\n", si1mojime[i]);
    }
    */

    unsigned long long m, a, r, c, h;
    m = a = r = c = h = 0;
    for (i = 0; i < N; i++){
        if(si1mojime[i] == 'M'){
            m += 1;
        }else if(si1mojime[i] =='A'){
            a += 1;
        }else if(si1mojime[i]=='R'){
            r += 1;
        }else if(si1mojime[i]=='C'){
            c += 1;
        }else if(si1mojime[i] =='H'){
            h += 1;
        }

    }

    unsigned long long ans = 0;
    ans 
    = m * a * r 
    + m * a * c 
    + m * a * h 
    + m * r * c 
    + m * r * h 
    + m * c * h 
    + a * r * c 
    + a * r * h 
    + a * c * h 
    + r * c * h;

    // printf("%d %d %d %d %d", m, a, r, c, h);
    printf("%llu", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
#define vll vector<ll>
#define inf 1e12
#define pll pair<ll,ll>
#define ff first 
#define ss second 
#define PI acos(-1)
#define prm 998244353
#define endl '\n'
using namespace std;
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//cout << fixed << setprecision(0)
/*
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res=(res*x)%mod;
		y=y/2;
		x=(x*x)%mod;
	}
	return res;
}
ll inv(ll a) 
{
return power(a,mod-2);
}
 
ll fact[2000007];
ll inr[2000007];
void pre()
{
	fact[0]=1;
	for(ll i=1;i<=2000005;i++)fact[i]=(fact[i-1]*i)%mod;
	inr[0]=1;
	for(ll i=1;i<=2000005;i++)inr[i]=inv(fact[i]);
}
 
ll ncr(ll n,ll r)
{
	ll a=(fact[n]*inr[r])%mod;
	ll b=(a*inr[n-r])%mod;
	return b;
}
 
ll spf[10000050];
void sieve()
{
	for(ll i=2;i*i<=10000030;i++)
	{
		if(spf[i]==0)
		{
			for(ll j=i+i;j<=10000030;j+=i)
			{
				if(spf[j]==0)
				{
					spf[j]=i;
				}
			}
		}
	}
}
*/

int main()
{
    fastio; 
    //sieve();
    //pre();
    ll T=1;
    //cin>>T;  
    while(T--)
    {
    	string s;
    	cin>>s;
    	ll r=0;
    	ll ans=0;
    	for(ll i=0;i<3;i++)
    	{
    		if(s[i]=='S')
    		{
    			ans=max(r,ans);
    			r=0;
			}
			else r++;
		}
		ans=max(ans,r);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3660
n,x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
if a[0]>x:
    ans = a[0]-x
    a[0]=x
for i in range(n-1):
    b = a[i]+a[i+1]
    if b<=x:
        continue
    else:
        sub = b-x
        a[i+1] = a[i+1]-sub
        ans+=sub
print(ans)

Measured memory_bytes: 63984
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    {

        in(n);
        if (n >= 400 && n <= 599)
        {
            cout << 8 << endl;
        }
        if (n >= 600 && n <= 799)
        {
            cout << 7 << endl;
        }
        if (n >= 800 && n <= 999)
        {
            cout << 6 << endl;
        }
        if (n >= 1000 && n <= 1199)
        {
            cout << 5 << endl;
        }
        if (n >= 1200 && n <= 1399)
        {
            cout << 4 << endl;
        }
        if (n >= 1400 && n <= 1599)
        {
            cout << 3 << endl;
        }
        if (n >= 1600 && n <= 1799)
        {
            cout << 2 << endl;
        }
        if (n >= 1800 && n <= 1999)
        {
            cout << 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <vector>

using namespace std;

using Vector=vector<int>;
using Matrix=vector<Vector>;

Vector operator*(Matrix &a, Vector &b) {
    Vector c(a.size());
    for (size_t i=0; i<a.size(); ++i)
        for (size_t j=0; j<a[i].size(); ++j)
            c[i] += a[i][j]*b[j];

    return c;
}

int main() {
    size_t n, m;
    scanf("%zu %zu", &n, &m);

    Matrix a(n, Vector(m));
    for (size_t i=0; i<n; ++i)
        for (size_t j=0; j<m; ++j)
            scanf("%d", &a[i][j]);

    Vector b(m);
    for (size_t j=0; j<m; ++j)
        scanf("%d", &b[j]);

    Vector c=a*b;
    for (size_t i=0; i<n; ++i)
        printf("%d\n", c[i]);

    return 0;
}

Measured memory_bytes: 2796
//AtCoder ABC078 C - HSI
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N,M;
    cin>>N>>M;
    ll num=pow(2,M);
    ll ans=(1900*M+(N-M)*100)*num;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = [0] * N
    S = sum(A)
    X[0] = S - 2 * sum([A[i] for i in range(N) if i % 2 == 1])
    A[0] -= X[0] // 2
    A[N-1] -= X[0] // 2

    for i in range(1, N):
        X[i] = A[i-1] * 2
        A[i-1] -= X[i] // 2
        A[i] -= X[i] // 2

    print(*X)
    # print(*A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 60772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX_V 1111
const ll MOD = 1e9+7;

struct SCC{
  int V; 
  vector<int> G[MAX_V];  //グラフの隣接リスト
  vector<int> rG[MAX_V]; //逆に辺を貼ったグラフの隣接リスト
  vector<int> vs;        //帰り掛け順の並び
  bool used[MAX_V];      //すでに調べたか
  int cmp[MAX_V];        //属する強連結成分のトポロジカル順序

  SCC(int v){
    V=v;
    fill_n(used,MAX_V,0);
    fill_n(cmp,MAX_V,0);
  }
  
  void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  void dfs(int v){
    used[v]=true;
    for(int i=0;i<G[v].size();i++)
      if(!used[G[v][i]])dfs(G[v][i]);
    vs.push_back(v); //探索終了したものから追加
  }

  void rdfs(int v,int k){
    used[v]=true;
    cmp[v]=k;
    for(int i=0;i<rG[v].size();i++)
      if(!used[rG[v][i]])rdfs(rG[v][i],k);
  }

  int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++)
      if(!used[v])dfs(v);

    memset(used,0,sizeof(used));
    int k=0;
    for(int i=vs.size()-1;i>=0;i--)
      if(!used[vs[i]])rdfs(vs[i],k++);

    return k;
  }

};

vector<int> g[1111];
ll used[1111]={};

ll dfs(int k){
  ll res=1;
  for(int i=0;i<g[k].size();i++){
    res*=dfs(g[k][i]);
    res%=MOD;
  }
  return (res+1)%MOD;
}

int main(){
  int n,m;
  cin>>n>>m;
  SCC sc(n);
  int s[1111],d[1111];
  for(int i=0;i<m;i++){
    cin>>s[i]>>d[i];
    sc.add_edge(--s[i],--d[i]);
  }
  int k = sc.scc();
  for(int i=0;i<m;i++){
    if(sc.cmp[d[i]]==sc.cmp[s[i]])continue;
    g[sc.cmp[d[i]]].push_back(sc.cmp[s[i]]);
    used[sc.cmp[s[i]]]=1;
  }
  ll ans=1;
  for(int i=0;i<k;i++){
    if(used[i])continue;
    ans*=dfs(i);
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}





Measured memory_bytes: 3336
#include<iostream>
#include<cstdio>
using namespace std;
struct node
{
	int v,nxt;
};
node edge[6001];
bool dp[3001];
int n,a[3001],len,head[3001];
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9')
		c=getchar();
	while ('0'<=c&&c<='9')
	{
		sum=sum*10+c-'0';
		c=getchar();
	}
	return sum;
}
void add(int x,int y)
{
	edge[++len].v=y;
	edge[len].nxt=head[x];
	head[x]=len;
	return;
}
bool used[3001];
void dfs(int x)
{
	used[x]=1;
	for (int i=head[x];i>0;i=edge[i].nxt)
		if (!used[edge[i].v])
		{
			dfs(edge[i].v);
			if (!dp[edge[i].v]&&a[edge[i].v]<a[x])
				dp[x]=1;
		}
	return;
}
int main()
{
	int x,y;
	n=read();
	for (int i=1;i<=n;++i)
		a[i]=read();
	for (int i=1;i<=n-1;++i)
	{
		x=read(),y=read();
		add(x,y);
		add(y,x);
	}
	for (int i=1;i<=n;++i)
	{
		for (int j=1;j<=n;++j)
			used[j]=dp[j]=0;
		dfs(i);
		if (dp[i])
			printf("%d ",i);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int h,n,a[1010],b[1010],dp[10010];
signed main(){
    cin>>h>>n;
    rep(i,n)cin>>a[i]>>b[i];
    rep(i,h+1)dp[i]=INF;
    dp[0]=0;
    rep(i,n){
        rep(j,h){
            int to;
            if(j+a[i]>=h)to=h;
            else to=j+a[i];
            dp[to]=min(dp[to],dp[j]+b[i]);
        }
    }
    cout<<dp[h]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
#define rep(i,a,n) for(int i =a;i<n;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
bool isprime(int n)
{if(n%2!=0&&n%3!=0&&n%5!=0&&n%7!=0)
return 1;
else return 0;
}
int main(){
	ios;
	int m,d,count;
	cin>>m>>d;
	rep(i,4,m+1)
	{if(isprime(i))
     {continue;
	 }
     else 
	 rep(j,2,d+1)
     {if(j/10<2||j%10<2)
      continue;
      else if((j/10)*(j%10)==i)
      {count++;
	  }
	 }
	}
	cout<<count<<endl;
	return 0;
}


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

void print(int* A,int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << A[i];
		if (i != n - 1)
		{
			cout << " ";
		}
	}
	cout << endl;
}
void insert(int* A, int n)
{
	for (int i = 1; i < n; i++)
	{
		print(A, n);
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;

		}
		A[j + 1] = v;

	}
}
void bubble(int *A, int n)
{
	int flag = 1;
	int count=0;
	while (flag)
	{
		
		//print(A, n);
		flag = 0;
		for (int j = n - 1; j > 0; j--)
		{
			if (A[j] < A[j - 1])
			{
				count++;
				int temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				flag = 1;
			}
		}
	}
	print(A, n);
	cout << count << endl;
}
int main()
{
	int n;
	cin >> n;
	
	int* A = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	
	bubble(A, n);
	return 0;
}


Measured memory_bytes: 3096
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString as BS
import qualified Data.Map.Strict as Map
import Control.Applicative

main :: IO ()
main = do
  n <- readLn
  loop n Map.empty

splitSpace :: BS.ByteString -> [BS.ByteString]
splitSpace = BS.split 32

loop 0 _   = return ()
loop n dic = do
  [c, s] <- splitSpace <$> BS.getLine
  case c of
    "insert" -> loop (n - 1) (Map.insert s n dic)
    "find" -> do
      putStrLn (if Map.member s dic then "yes" else "no")
      loop (n - 1) dic



Measured memory_bytes: 215276
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        double a=scanner.nextLong();
        double b=scanner.nextLong();
        double c=scanner.nextInt()*Math.PI/180.0;
        System.out.println(a*b*Math.sin(c)/2);
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(c))+a+b);
        System.out.println(b*Math.sin(c));
    }

}



Measured memory_bytes: 26420
#重みのないグラフでの最短経路問題
#隣接リストと始点を与えると始点からの距離のリストを返す
from collections import deque
def NC_Dij(lis,start):

    ret = [float("inf")] * len(lis)
    ret[start] = 0
    
    q = deque([start])

    while len(q) > 0:
        now = q.popleft()

        for nex in lis[now]:

            if ret[nex] > ret[now] + 1:
                ret[nex] = ret[now] + 1
                q.append(nex)

    return ret


#重みがあるグラフの最短経路問題
#隣接リストは[隣接点,コスト]で入っていること
#負の重みの辺があってはダメ
#連結じゃないと遅くなる

import heapq
def Dijkstra(lis,start):

    ret = [float("inf")] * len(lis)
    ret[start] = 0
    end_flag = [False] * len(lis)
    end_num = 0
    
    q = [[0,start]]

    while len(q) > 0:

        ncost,now = heapq.heappop(q)

        if end_flag[now]:
            continue

        end_flag[now] = True
        end_num += 1

        if end_num == len(lis):
            break

        for nex,ecost in lis[now]:

            if ret[nex] > ncost + ecost:
                ret[nex] = ncost + ecost
                heapq.heappush(q , [ret[nex] , nex])

    return ret


#設定
#One_OriginがTrue場合は0オリジンに直す
#TreeFlagがTrueの時はNのみ入れる。Falseでは頂点数Nと辺数Mを入力。
#Edge_costがTrueならば辺に重みがある。それ以外は常に1になる
#Non_Directなら無向グラフになる
#lisは隣接リスト, コストが存在しない場合隣接番号が直接入る
#存在する場合は[頂点,コスト]のリストが入る

One_Origin = False
Tree_Flag = False
Edge_Cost = True
Non_Direct = False

#input N (& M)
if Tree_Flag:
    N = int(input())
    EDGES = N-1
else:
    N,M,r = map(int,input().split())
    EDGES = M

uvc = [] #Edge_list and costs
lis = [ [] for i in range(N) ] #neighbor list


for i in range(EDGES):

    if Edge_Cost:
        u,v,c = map(int,input().split())
    else:
        u,v = map(int,input().split())

    if One_Origin:
        u -= 1
        v -= 1

    if Edge_Cost:
        uvc.append([u,v,c])
        lis[u].append([v,c])

        if Non_Direct:
            lis[v].append([u,c])

    else:
        uvc.append([u,v,1])
        lis[u].append(v)

        if Non_Direct:
            lis[v].append(u)

dis = Dijkstra(lis,r)

for i in dis:
    if i == float("inf"):
        print ("INF")
    else:
        print (i)


Measured memory_bytes: 161324
#include<stdio.h>

int main() {
  int i,n,q,key,S[10000],answer = 0;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++) {
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i = 0 ; i < q ; i++) {
    scanf("%d",&key);
    if(search(S, n, key))
      answer++;
  }
  printf("%d\n", answer);
  return 0;
}

int search(int S[], int n, int key) {
  int i=0;

  S[n] = key;
  while(S[i] != key)
    i++;
  return i != n;
}



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

int main()
{
    string s; cin >> s;
    string ans = "Yes";
    for(int i=0;i<s.size();i++){
        if(i%2 == 0 && s[i] == 'L'){
            ans = "No";
            break;
        }
        else if(i%2 == 1 && s[i] == 'R'){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
   vector<string> redcard(N);
  vector<int> yenvec(N);
  for (int i=0;i<N;i++){
    string red;
   cin >> red;
  redcard.at(i) = red;
  }
  
  int M;
  cin >> M;
   vector<string> bluecard(M);
  for (int i=0;i<M;i++){
    string blue;
   cin >> blue;
  bluecard.at(i) = blue;
  }
  
   for (int i=0;i<N;i++){
   string testword = redcard.at(i);
   int yen=0;
     for (int k=0;k<N;k++){
   if(testword == redcard.at(k)){  yen++;   }
  }
     for (int j=0;j<M;j++){
   if(testword == bluecard.at(j)){  yen--;   }
  }
     yenvec.at(i) = yen;
  }
  
  sort(yenvec.begin(), yenvec.end());
  
  cout << max(yenvec.at(N-1),0) << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
char a=65,b=65,j[26];
int main(){
	int p,q,k;
	cin>>p>>q>>k;
	if (abs(q-p)>abs(k-p))
		cout<<'B';
	else
		cout<<'A';
    return 0;
}

Measured memory_bytes: 256
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1
    
    def __call__(self, n):
        return self.fact(n)
    
    def fact(self, n):
        ''' n! % mod '''
        if n >= self.mod:
            return 0
        self._make(n)
        return self._factorial[n]
    
    def fact_inv(self, n):
        ''' n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self._make_inv(n)
        return self._factorial_inv[n]
    
    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self.fact_inv(n-r)*self.fact_inv(r) % self.mod
        return self(n)*t % self.mod
    
    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self.fact_inv(n-1)*self.fact_inv(r) % self.mod
        return self(n+r-1)*t % self.mod
    
    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod
    
    @staticmethod
    def xgcd(a, b):
        '''
        Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)
        '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0
    
    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod
    
    def _make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1
    
    def _make_inv(self, n):
        if n >= self.mod:
            n = self.mod
        self.make(n)
        if self._size_inv < n+1:
            for i in range(self._size_inv, n+1):
                self._factorial_inv.append(self.modinv(self._factorial[i]))
            self._size_inv = n+1

print(Factorial()(int(input())))

Measured memory_bytes: 12792
package main

import (
	"fmt"
)

func main() {
	var m1, d1, m2, d2 int
	fmt.Scan(&m1, &d1, &m2, &d2)
	if m1 == m2 {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
N,M=map(int,input().split())

fav=[0 for x in range(M+1)]
for i in range(N):
  A=[int(x) for x in input().split()]
  for j in range(A[0]):
    fav[A[j+1]]+=1
ans=0
for c in fav:
  if c==N:
    ans+=1
print(ans)

  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
    in >> P.first >> P.second;
    return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
    out << "(" << P.first << ", " << P.second << ")";
    return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
    for(auto &x: arr) in >> x;
    return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
    for(auto &x: arr) out << x << ' '; cout << "\n";
    return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
    for(auto &x: arr) in >> x;
    return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
    for(auto &x: arr) out << x << ' '; cout << "\n";
    return out;
}
set<int> jf;
map<int,int> rf;
int32_t main(){
	int n , m;
	cin>>n>>m;
	rep(i,0,m){
		int x;
		string y;
		cin>>x>>y;
		if(y =="AC"){
			jf.insert(x);
		}
		else{
			if(!jf.count(x)){
				rf[x]++;
			}
		}
	}
	ll u = 0;
	allin(w,rf){
		if(jf.count(w.F))
		u += w.S;
	}
	cout<< ((int) jf.size()) <<" " << u << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
main(){
  int n,x=100000,y,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    x*=1.05;
    y=x/1000;
    if(x-y*1000==0) x=y*1000;
    else x=y*1000+1000;
  }

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

Measured memory_bytes: 0
n=int(input())
l=list(map(int,input().split()))
ans=[0 for i in range(n)]
for i in range(n):
    for j in range(len(l)):
        if len(l)-j==l[len(l)-1-j]:
            ans[i]=len(l)-j
            del l[len(l)-1-j]
            break
if 0 in ans:
    print(-1)
else:
    for i in range(n):
        print(ans[n-i-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, ans = 0, div = 0;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		ans+=n/i;
		if(n%i==0)
		{
			div++;
		}
	}
	printf("%d\n",ans-div);
}

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


int main()
{
	int r, c;
	int m[101][101] = { { 0 } };
	cin >> r >> c;
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			cin >> m[i][j];
		}
	}
	int allsum = 0;
	for (int i = 0; i < r; i++){
		int sum = 0;
		for (int j = 0; j < c; j++){
			cout << m[i][j] << " ";
			sum += m[i][j];
			allsum += m[i][j];
		}
		cout << sum << endl;
	}
	for (int j = 0; j < c; j++){
		int sum = 0;
		for (int i = 0; i < r; i++){
			sum += m[i][j];
		}
		cout << sum << " ";
	}
	cout << allsum << endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
int a[200100];
int b[200100];

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

  cin>>N;
  for(int i=1;i<=N;i++) cin>>a[i];
  vector<int> res;
  for(int i=N;i>=1;i--){
    int s=0;
    for(int j=N/i*i;j>i;j-=i) s+=b[j];
    b[i] = (s&1)^a[i];
    if (b[i]) res.pb(i);
  }
  cout<<res.size()<<endl;
  for(int k:res) cout<<k<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t x;
    cin >> x;
    cout << (x<1200?"ABC":"ARC") << endl;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

int edge[300000][2];

int qmem[600000];

int *e[300000];
int el[300000];

int d[300000];
int a[1000000][2];
int s=0;

void push(int x, int y){
	int c=s++, p=(c-1)/2;
	while(c>0 && x<a[p][0]){
		a[c][0]=a[p][0];
		a[c][1]=a[p][1];
		c=p, p=(c-1)/2;
	}
	a[c][0]=x;
	a[c][1]=y;
}
int pop(int *t){
	int td=a[0][0];
	*t=a[0][1];
	s--;
	int x=a[s][0], y=a[s][1];
	int p=0, c=p*2+1;
	while(c<s && a[c=(c+1<s&&a[c+1][0]<a[c][0])?c+1:c][0]<x){
		a[p][0]=a[c][0];
		a[p][1]=a[c][1];
		p=c, c=p*2+1;
	}
	a[p][0]=x;
	a[p][1]=y;
	return td;
}

void dike(int x){
	push(0,x);
	d[x]=0;
	while(s){
		int p;
		if(pop(&p)>d[p]) continue;
		for(int i=0; i<el[p]; i++){
			int to=e[p][i];
			long now=d[p]+1;
			if(now<d[to]){
				d[to]=now;
				push(now,to);
			}
		}
	}
}

int main(void){
	int n=nextint();
	int m=nextint();
	for(int i=0; i<m; i++){
		int A=nextint()-1;
		int B=nextint()-1;
		edge[i*3+0][0]=A*3+0; edge[i*3+0][1]=B*3+1;
		edge[i*3+1][0]=A*3+1; edge[i*3+1][1]=B*3+2;
		edge[i*3+2][0]=A*3+2; edge[i*3+2][1]=B*3+0;
		el[A*3+0]++; el[A*3+1]++; el[A*3+2]++;
	}
	int ne=0;
	for(int i=0; i<n*3; i++){
		e[i]=&qmem[ne];
		ne+=el[i];
		el[i]=0;
	}
	for(int i=0; i<m*3; i++){
		int A=edge[i][0];
		int B=edge[i][1];
		e[A][el[A]++]=B;
	}
	int s=(nextint()-1)*3;
	int t=(nextint()-1)*3;
	for(int i=0; i<n*3; i++){
		d[i]=INT_MAX;
	}
	dike(s);
	printf("%d\n", d[t]==INT_MAX?-1:d[t]/3);
}


Measured memory_bytes: 9736
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 5e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


signed main() {
	FAST_IO;
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(all(a));
	sort(all(b));
	if (n % 2 == 1) {
		cout << b[n / 2 + 1] - a[n / 2 + 1] + 1 << "\n"; 
	} else {
		cout << b[n / 2] + b[n / 2 + 1] - a[n / 2] - a[n / 2 + 1] + 1 << "\n";
	}
 	return 0;
}

Measured memory_bytes: 6368
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> X) {
  auto Y = X;
  sort(ALL(Y));
  REP(i,N) {
    if (X[i] >= Y[N/2]) cout << Y[N/2 - 1] << endl;
    else cout << Y[N/2] << endl;
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> X(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &X[i]);
	}
	solve(N, X);
	return 0;
}


Measured memory_bytes: 6912
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  let answer = 0;

  for (let i = 1; i <= N; i++) {
    const [l, r] = input[i].map(Number);

    answer += r - l + 1;
  }

  return answer;
};

console.log(main(read()));


Measured memory_bytes: 30436
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int a, p ;
    cin >> a >> p ;
    cout << (a*3 + p) / 2 << endl ;
}

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

int main(void){
    int N,K;
    cin>>N>>K;
    vector<ll> a(N),b(N);
    rep(i,N) cin>>a[i]>>b[i];
    
    ll res = 0;
    rep(i,N) if((K|a[i])==K) res += b[i];

    for(int r=0;(1<<r)<=K;r++){
        if((K&(1<<r)) == 0) continue;
        int Kr = K - (K%(1<<r)) - 1;
        ll sum = 0;
        rep(i,N) if((Kr|a[i])==Kr) sum += b[i];
        res = max(res,sum);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

ss = ins()
s = ss[::-1]
n = len(s)
a = [ [0]*13 for i in range(n) ]
r = 10
if s[0]=='?':
    for i in range(10):
        a[0][i] = 1
else:
    a[0][int(s[0])] = 1

for i in range(1,n):
    if s[i]=='?':
        ds = list(range(10))
    else:
        ds = [int(s[i])]
    for d in ds:
        for j in range(13):
            k = (j+d*r)%13
            #ddprint("r {} d {} j {} k {}".format(r,d,j,k))
            a[i][k] = (a[i][k]+a[i-1][j])%R
    r = (r*10)%13

if DBG:
    for i in range(6):
        printn(i)
        print(a[i])
print(a[n-1][5])


Measured memory_bytes: 62300
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		char[] arr = str.toCharArray();
		Boolean flagC = false;
		Boolean flagF = false;
		String res ="No";
		
		for (int i = 0; i < arr.length; i++) {
			if (arr[i]=='C') {
				flagC = true;
			}
			
			if (arr[i]=='F'&&flagC) {
				res = "Yes";
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 10064