akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
using namespace std::chrono;
long long int p=1e9 +7;
int n;
ll seq[3000];
bool debugging=0;
bool outputcheck=0;
bool timecheck=0;
void init(){
    if(debugging){
        
    }
    else{
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>seq[i];
        }
        
    }
}
long long int modpower(ll b,ll po, ll mod=p){
    long long int ans=1;
    while(po){
        if(po&1){
            ans*=b;
            ans%=mod;
        }
        b*=b;
        b%=mod;
        po>>=1;
    }
    return ans;
}
ll solve(){
   ll value[n][n];
   for(int i=0;i<n;i++){
       value[i][i]=seq[i];
   }
   for(int range=1;range<n;range++){
       for(int i=0;i<n-range;i++){
            value[i][i+range]=max(seq[i]-value[i+1][i+range],seq[i+range]-value[i][i+range-1]);
       }
   }
   return value[0][n-1]; 
}
ll solvebad(){

}
int output(){
   
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//cin >>t;
	t=1;
    srand(time(0));
	while(t--){
	   init();
	   if(debugging){
	       if(outputcheck){
	          if(solve()!=solvebad()){//checking for random input
	             output();
	          }
	       }
	       if(timecheck){
	           auto start=high_resolution_clock::now();
	           solve();
	           auto stop=high_resolution_clock::now();
	           auto duration = duration_cast<microseconds>(stop - start);
	           cout<<duration.count()<<" Fast\n";
	           start=high_resolution_clock::now();
	           solvebad();
	           stop=high_resolution_clock::now();
	           duration = duration_cast<microseconds>(stop - start);
	           cout<<duration.count()<<" Slow\n";
	       }
	   }
	   else{
	       cout<<solve()<<"\n";//solving it correctly
	   }
	}
}

Measured memory_bytes: 70272
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	long long t[10002];
	int n;
	while(cin>>n,n){
		t[0]=0;
		for(int i=1;i<=n;i++)	cin>>t[i];

		sort(t,t+n+1);

		long long total=0;
		for(int i=1;i<n;i++)	total+=t[i]+=t[i-1];
		cout<<total<<endl;
	}
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  cout<<(N+1)/2<<endl;
  return 0;
}


Measured memory_bytes: 896
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]<L[j]<L[k] and L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[k]+L[j]>L[i]:
                ans+=1
print(ans)

Measured memory_bytes: 68200
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
N = read_int()
A = read_array()
A.sort()
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > int(1e18):
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 22532
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    ll a, b, c;  cin >> a >> b >> c;
  	if(0 < c-a-b && 4*a*b < (c-a-b)*(c-a-b)){  cout << "Yes" << endl;  }
  	else{  cout << "No" << endl;  }
	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define eps 0.00000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
		long long dp[200][100][30] = {};
int main(){
	while(true){
		int n,m;
		cin >> n >> m;
		if(n == 0&&m == 0){
			return 0;
		}
		for(int i = 0;i < 200;++i){
			for(int j = 0;j < 100;++j){
			for(int q = 0;q < 30;++q){
				dp[i][j][q] = LONG_INF;
			}
			}
		}
		vector<pair<long long,long long>> wow[200];
		for(int i = 0;i < n;++i){
			int t;
			cin >> t;
			REP(q,t){
				int a,b;
				cin >> a >> b;
				wow[i+1].push_back(make_pair(a,b));
			}
		}
		for(int q = 0;q < wow[1].size();++q){
			dp[1][0][q] = 0;
		}
		if(m != 0){
			for(int q = 0;q < wow[2].size();++q){
				dp[2][1][q] = 0;
			}
		}
		for(int i = 1;i <= n-1;++i){
			for(int q = 0;q < wow[i].size();++q){
				for(int j = 0;j <= m;++j){
					for(int t = 0;t < wow[i+1].size();++t){
							dp[i+1][j][t] = min(dp[i+1][j][t],dp[i][j][q] + (wow[i][q].second+wow[i+1][t].second)*abs(wow[i][q].first - wow[i+1][t].first));
					}
					if(j < m&&i != n-1){
						for(int t = 0;t < wow[i+2].size();++t){
								dp[i+2][j+1][t] = min(dp[i+2][j+1][t],dp[i][j][q] + (wow[i][q].second+wow[i+2][t].second)*abs(wow[i][q].first - wow[i+2][t].first));
						}
					}
				}
			}
		}
		long long ans = LONG_INF;
		for(int i = 0;i < wow[n].size();++i){
				for(int j = 0;j <= m;++j){
					ans = min(ans,dp[n][j][i]);	
				}
		}
			for(int i = 0;i < wow[n-1].size();++i){
				for(int j = 0;j < m;++j){
					ans = min(ans,dp[n-1][j][i]);	
				}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 7820
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        double a, b, h, m;
        cin >> a >> b >> h >> m;

        const double pi = acos(-1);
        double d = 2 * pi * ((h + m / 60) / 12 - m / 60);
        cout << fixed << setprecision(10) << sqrt(a * a + b * b - 2 * a * b * cos(d)) << endl;

        return 0;
}


Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define LL long long
#define ffor(i,s,n) for(int i=(s);i<(n);i++)
#define efor(i,s,n) for(int i=(s);i<=(n);i++)
using namespace std;

LL n;
LL a[100];


int main(){
	cin>>n;
	ffor(i,0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
    return 0;

}


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

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    if (A+B == 3) {
        cout << 3 << endl;
    }
    else if (A + B == 4) {
        cout << 2 << endl;
    }
    else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    string s,t,u; cin >> s >> t;
    int a, b; cin >> a >> b;
    cin >> u;
    if (u == s) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0, h, w;
int main() {
    int w, h; char c; cin >> w >> h >> c;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0 || i==h-1) {
                if (j == 0 || j == w - 1) cout << '+';
                else cout << '-';
            }
            else if (j == 0 || j == w - 1) cout << "|";
            else if (i == h / 2 && j == w / 2) cout << c;
            else cout << '.';
        }cout << endl;
    }
}


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

B_lst = list(map(int,input().split()))
A_lst = [0] * n

A_lst[0] = B_lst[0]
A_lst[n-1] = B_lst[n-2]

if n >= 3:
    for i in range(1,n-1):

        if B_lst[i-1] > B_lst[i]:
            A_lst[i] = B_lst[i]
        else:
            A_lst[i] = B_lst[i-1]

print(sum(A_lst))


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}     

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
char s[100005],cmp1[100005],cmp2[100005];
int ans1,ans2;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>s;
	int len=strlen(s);
	for(int i=0;i<len;i++){
		if(i%2) cmp1[i]='1',cmp2[i]='0';
		else cmp1[i]='0',cmp2[i]='1';
	}
	for(int i=0;i<len;i++){
		if(s[i]!=cmp1[i]) ans1++;
		if(s[i]!=cmp2[i]) ans2++;
	}
	cout<<min(ans1,ans2);
	re 0;
}

Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{	
	vector<int> a(3);
	for (int i = 0; i < 3; i++) cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[0] + a[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int n;
vector<int> h(100101,0);
vector<int> dp(100101,-1);

int dfs(int a){
  if(dp[a] != -1) return dp[a];
  if(a >= n) return 1001001001;
  if(a == n-1) return 0;
  int way1 = dfs(a+1) + abs(h[a+1]-h[a]);
  int way2 = dfs(a+2) + abs(h[a+2]-h[a]);
  return dp[a] = min(way1,way2);
}

int main(){
  cin >> n;
  rep(i,n) cin >> h[i];
  cout << dfs(0) << endl;
}

Measured memory_bytes: 8744
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>


int main(int argc, char *argv[])
{
	string s,t,u;
	int a,b;
	cin >> s>>t>>a>>b>>u;
	
	if (s==u) a--; else b--;

	cout<< a<<" "<<b<<endl;
	return 0;
}


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

string s;

int main()
{
	cin >> s;

	if(s == "Sunny")
		cout << "Cloudy" << endl;
	else if (s == "Cloudy")
		cout << "Rainy" << endl;
	else if (s == "Rainy")
		cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: Vec<char> = sc.chars();
    let N = S.len();
    let T: Vec<char> = sc.chars();
    let M = T.len();
    let mut res = Vec::new();
    for s in 0..N-M+1 {
        let mut ok = true;
        for i in 0..M {
            if S[s+i] != '?' && S[s+i] != T[i] {
                ok = false;
                break;
            }
        }
        if ok {
            let mut key = S.clone();
            for i in 0..M {
                key[s+i] = T[i];
            }
            for i in 0..N {
                if key[i] == '?' {
                    key[i] = 'a';
                }
            }
            res.push(key);
        }
    }
    if res.is_empty() {
        println!("UNRESTORABLE");
        return;
    }
    res.sort();
    let ans: String = res[0].iter().map(|&i| i).collect();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>

using namespace std;

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

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

    int a, b;
    vector<int> r(n);
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        if (h[a-1] >= h[b-1]) {
            r[b-1]++;
        }
        
        if (h[b-1] >= h[a-1]) {
            r[a-1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (r[i] == 0) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    x = I()
    goh = x // 500 * 1000
    x -= goh//1000 * 500
    go = x // 5 * 5
    print(goh+go)
    return


if __name__ == "__main__":
    solve()

Measured memory_bytes: 38384
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
    bool isPalindrom(string str)
    {
        auto srev = str;
        reverse(all(srev));
        return srev == str;
    }

public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        string str;
        cin >> str;
        int n = str.length();
        if (isPalindrom(str) && isPalindrom(str.substr(0, (n - 1) / 2)) && isPalindrom(str.substr((n + 1) / 2)))
            cout << "Yes\n";
        else
            cout << "No\n";
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int main() {
    int a, b, x; cin >> a >> b >> x;
    string ans;
    if (x < a) {
        ans = "NO";
    } else if (x > a + b) {
        ans = "NO";
    } else {
        ans = "YES";
    }
    cout << ans << endl;
    return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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


void solve(){
  int N;
  cin >> N;

  int a[200000 + 5];
  rep(i, N) cin >> a[i+1];

  int ball[200000+5] = {};
  RREP(i, 1, N+1){
    int ans = 0;
    for(int j = 2 * i; j <= N; j += i){
      ans += ball[j];
    }
    if(ans % 2 != a[i])
      ball[i] = 1;
  }

  int m = 0;
  REP(i, 1, N+1){
    if(ball[i]) m++;
  }
  cout << m << endl;
  REP(i, 1, N+1){
    if(ball[i]) cout << i << " ";
  }
  cout << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int n;  cin >> n;
	map<char, ll>  mp, keepmp;
  	for(char i = 'a' ; i <= 'z' ; i++)  mp[i] = INF;
  
	for(int i = 0 ; i < n ; i++){
      
      	for(char j = 'a' ; j <= 'z' ; j++)  keepmp[j] = 0;
		string input;  cin >> input;
		for(int j = 0 ; j < input.size() ; j++)
			keepmp[input[j]] += 1;
      
        for(char j = 'a' ; j <= 'z' ; j++)
            mp[j] = min(mp[j], keepmp[j]);
	}

	string ans;
	for(char i = 'a' ; i <= 'z' ; i++)
		for(int j = 0 ; j < mp[i] ; j++)
          ans += i;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pii pair <int,int>
ll mod=1000000007;
int dp[100000]={0};
unordered_set<int> s[200001];
int vis[200001]={1};
int dfs(int x)
{
	vis[x]=1;
	int sz=1;
	for(auto i:s[x])if(!vis[i])
		sz+=dfs(i);
	return sz;
}
int main()
{
	fast;
	int n,k;cin>>n>>k;
	for(int i=0;i<=n;i++)vis[i]=0;
	while(k--)
	{
		int x,y;
		cin>>x>>y;
		s[x].insert(y);
		s[y].insert(x);
	}
	
	int sz,ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
			sz=dfs(i);
		ans=max(sz,ans);
	}
	cout<<ans;
}


Measured memory_bytes: 40164
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    if n == 1:
        print("Hello World")
    else:
        print(II()+II())
    return

#B
def B():
    return

#C
def C():
    n = II()
    xyh = LIR(n)
    xyh.sort(key = lambda x:x[2], reverse = True)
    x1, y1, h1 = xyh[0]
    del xyh[0]
    for x in range(101):
        for y in range(101):
            h = abs(x - x1) + abs(y - y1) + h1
            flg = True
            for xn, yn, hn in xyh:
                if max(h - abs(x - xn) - abs(y - yn), 0) == hn:
                    continue
                flg = False
                break
            if flg:
                print(x, y, h)
                return 
    return

#D
def D():
    n, m = LI()
    ans = 1
    for i in range(1,int(math.sqrt(m)+1)):
        if m % i == 0:
            a = m // i
            #print(i,a)
            if a * n <= m:
                ans = max(ans, a)
            if i * n <= m:
                ans = max(ans, i)
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38640
//Dragon_warrior7(IITK)
// #pragma GCC optimize("O0") 
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
//#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
//#define ull unsigned ll
#define vll vector<ll>
#define vpll vector<pll> 
#define rub cerr << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{for (int i = 0; i < v.size(); i++)cin>>v[i];}
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll int gcd(ll int a ,ll int b)
{if(b==0) return a;a%=b;return gcd(b,a);}
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
ll sum=0;
cin>>n;
for(int i=1;i<=n;i++)
{
    for(int j=1;j<=n;j++)
    {
        for(int k=1;k<=n;k++)
        sum+=gcd(i,gcd(j,k));
    }
}
cout<<sum;


















return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll nCrModpDP(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C));   
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
  
   return (nCrModp(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p; 
} 
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,h,k,m,maxi,d,x;
	string s,w;
	cin>>s>>w;
	ll ans=inf;
	for(i=0;i<=s.length()-w.length();i++)
	{
		c=0;
		for(j=0;j<w.length();j++)
		{
			if(s[i+j]!=w[j])
				c++;
		}
		ans=min(ans,c);
	}
	cout<<ans;
}


	

		

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

int main()
{
  int n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  string t, u;
  cin >> t;
  int point[256] = {};
  point['r'] = r;
  point['s'] = s;
  point['p'] = p;

  for (int i = 0; i < n; i++) {
    switch (t[i]) {
    case 'r': u += 'p'; break;
    case 's': u += 'r'; break;
    case 'p': u += 's'; break;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i < k || u[i] != u[i - k]) {
      ans += point[size_t(u[i])];
    } else {
      u[i] = ' ';
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    string s,t;cin>>s>>t;
    ll n=sz(s),m=sz(t);
    vl sum1A(n+1),sum1B(n+1),sum2A(m+1),sum2B(m+1);
    ll q;cin>>q;
    rep(i,n){
        sum1A[i+1]=sum1A[i]+(s[i]=='A'?1:0);
        sum1B[i+1]=sum1B[i]+(s[i]=='B'?1:0);
    }
    rep(i,m){
        sum2A[i+1]=sum2A[i]+(t[i]=='A'?1:0);
        sum2B[i+1]=sum2B[i]+(t[i]=='B'?1:0);
    }
    rep(i,q){
        ll a,b,c,d;cin>>a>>b>>c>>d;
        ll Y=(sum1A[b]-sum1A[a-1])-(sum1B[b]-sum1B[a-1]);
        ll X=(sum2A[d]-sum2A[c-1])-(sum2B[d]-sum2B[c-1]);
        if((Y-X)%3==0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

int main(){
        int N,K;
        int h;
        cin >> N >> K;
        vector<int> v;
        for(int i = 0; i < N; i++){
                cin >> h;
                v.push_back(h);
        }
        sort(v.begin(), v.end(), greater<int>());
        int min_height = INT_MAX;
        int t;
        for(int i = 0; i < N - K + 1; i++){
                t =  v[i] - v[i+K-1];
                if(t <= min_height) min_height = t;
        }
        cout << min_height;
}


Measured memory_bytes: 892
from math import sqrt, cos, radians

A, B, H, M = map(int, input().split())

long_hand_angle = M * 6
short_hand_angle = (H * 60 + M) * 0.5
theta = abs(long_hand_angle - short_hand_angle)
theta = min(theta, 360 - theta)

C = sqrt(A**2 + B**2 - 2 * A * B * cos(radians(theta)))
print(C)

Measured memory_bytes: 9504
//ACできなかった  WAがいくつかある

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <functional>
#include <string.h>

using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))





typedef pair <int, int> P;
typedef tuple <int, int, int> P3;


#define INF (0x7fffffff)
template <typename T>
class Rmq {
public:
	int n;
	vector<T> dat;

	void init(int _n) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		dat.resize(2 * n - 1, INF);//

	}

	void update(int k, int x) {
		k += n - 1;
		dat[k] = x;
		while (k > 0) {
			k = (k - 1) / 2;//k/2でない注意
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}

	}
	int find(int a, int b) {
		return find0(a, b, 0, 0, n);
	}
	int find0(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)//等号が必要
			return INF;
		if (a <= l && r <= b)
			return dat[k];
		else {
			int x1, x2;
			x1 = find0(a, b, k * 2 + 1, l, (l + r) / 2);//ここはl,r
			x2 = find0(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(x1, x2);
		}
	}
};
vector<int> a,rev;
Rmq<int> cl0, cl1;
priority_queue<P3, vector<P3>, greater<P3> >  q;
//
void add(int l, int r) {
	int pp;
	if (l < r) {
		if (l % 2)
			//
			pp = cl1.find(l, r);
		else
			pp = cl0.find(l, r);
		q.push(P3(pp, l, r));
	}

}

int main(){
	int n;
	scanf("%d ", &n);
	a.resize(n);
	rev.resize(200005);//
	rep(i, n) {
		scanf("%d ", &a[i]);
		rev[a[i]] = i;
	}
	
	cl0.init(n); cl1.init(n);
	rep(i, n) {
		if (i % 2) {
			cl1.update(i, a[i]);
		}
		else {
			cl0.update(i, a[i]);
		}
	}
	
	int l, r, m, x;
	x =  cl0.find(0, n);
	
	q.push(P3(x, 0, n));
	vector<int> ans;//
	rep(i,n/2){//
		tie(x, l, r) = q.top(); q.pop();
		
		m = rev[x];
		int y;

		if (l % 2) {
			y = cl0.find(m+1, r);
		}
		else {
			y = cl1.find(m+1, r);
		}
		ans.push_back(x);
		ans.push_back(y);
		
		add(l, m);
		add(m + 1, rev[y]);
		add(rev[y] + 1, r);

	}
	rep(i, a.size()) {
		printf("%d%c", ans[i], ((i==(a.size()-1)?'\n':' ')));
	}
	
	return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

vector<pair<ll, ll>> prime_factorize(ll n)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= n; ++a)
    {
        if (n % a != 0)
            continue;
        ll ex = 0;

        while (n % a == 0)
        {
            ++ex;
            n /= a;
        }
        res.push_back({a, ex});
    }
    if (n != 1)
        res.push_back({n, 1});
    return res;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    const auto &res_a = prime_factorize(a);
    const auto &res_b = prime_factorize(b);
    ll ans = 0;
    map<ll, int> m;
    for (auto itr = res_a.begin(); itr != res_a.end(); itr++)
    {
        m[itr->first]++;
    }
    for (auto itr = res_b.begin(); itr != res_b.end(); itr++)
    {
        if (m[itr->first] == 1)
        {
            ans++;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			int q = cin.nextInt();
			if(n+q==0){
				break;
			}
			int[][] date = new int[n][101];
			for(int i = 0;i<n;i++){
				int m = cin.nextInt();
				for(int j = 0;j<m;j++){
					int a = cin.nextInt();
					date[i][a]=1;
				}
			}
			boolean f = true;
			int max=0,day=0;
			for(int j = 1;j<101;j++){
				int sum=0;
				for(int i = 0;i<n;i++){
					sum+=date[i][j];
				}
				if(sum>max){
					max=sum;
					day=j;
				}
			}
			if(max>=q){
				System.out.println(day);
			}
			else{
				System.out.println(0);
			}
		}

	}

}

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

signed main(){
    vector<vector<int>> G(3,vector<int>(3));
    for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>G[i][j];
    int N; cin>>N;
    for(int i=0;i<N;i++){
        int b; cin>>b;
        for(int i=0;i<3;i++)for(int j=0;j<3;j++){
            if(G[i][j]==b)G[i][j]=-1;
        }
    }
    bool pro=false;
    for(int i=0;i<3;i++){
        if(G[i][0]==-1 &&G[i][1]==-1 &&G[i][2]==-1)pro=true;
        if(G[0][i]==-1 && -1==G[2][i]&& G[1][i]==-1)pro=true;
    }
    if(G[0][0]==-1 &&G[1][1]==-1 && G[2][2]==-1)pro=true;
    if(G[0][2]==-1 && G[2][0]==-1 && G[1][1]==-1)pro=true;
    cout<<(pro? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int SIZEN = 100010;
int N;
int L[SIZEN];
int R[SIZEN];
int a[SIZEN];
int b[SIZEN];
int mnb[SIZEN];
int id[SIZEN];
int tmp[SIZEN];
bool Cmp(const int &A,const int &B){
    return a[A] > a[B];
}

int main(){
    scanf("%d",&N);
    int mxl = 0;
    int mnr = INF;
    int mxn = 0;
    for(int i = 1;i <= N;i++){
        scanf("%d%d",&L[i],&R[i]);
        if(mxl < L[i])mxl = L[i];
        if(mnr > R[i])mnr = R[i];
        mxn = max(mxn,R[i] - L[i] + 1);
    }
    int ans = max(mnr - mxl + 1,0) + mxn;
    // printf("ans = %d,mxl = %d,mnr = %d\n",ans,mxl,mnr);

    for(int i = 1;i <= N;i++){
        a[i] = max(0,R[i] - mxl + 1);
        b[i] = max(0,mnr - L[i] + 1);
        id[i] = i;
    }
    sort(id + 1,id + 1 + N,Cmp);
    mnb[N] = b[id[N]];
    for(int i = N-1;i >= 1;i--)mnb[i] = min(mnb[i+1],b[id[i]]);

    // for(int i = 1;i <= N;i++)printf("L = %d,R = %d,a = %d,b = %d\n",L[id[i]],R[id[i]],a[id[i]],b[id[i]]);
    // printf("mnb : ");for(int i = 1;i <= N;i++)printf("%d ",mnb[i]);printf("\n");
    
    for(int i = 1;i <= N;i++){
        int x = id[i];
        ans = max(ans,a[x] + mnb[i+1]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4080
_,a,b,*c=$<.map{|l|l.split.map &:to_i}
m,i,*o=-1,-2
b.map{|v|c[v]=i+=1}
s=->f,l,r{l<=r&&(f[f,l,d=c[x=a[m+=1]]]
f[f,d+2,r]
o<<x)}
s[s,0,i+1]
puts o*" "

Measured memory_bytes: 6140
main :: IO ()
main = do
  [l,r] <- map (read :: String -> Int) . words <$> getLine
  let r_ = mod r 2019
  let l_ = r_ - ((mod r 2019) - (mod l 2019))
  if r-l < 2019 then print (ans l_ r_) else print 0
 
ans :: Int -> Int -> Int
ans m n = minimum [mod (i*j) 2019 | i <- [m..n], j <- [m..n], i < j]


Measured memory_bytes: 1148
n = int(input())
a = list(map(int, input().split()))

def check(n, a):
    for i in range(n):
        if not a[i*2]==a[i*2+1]:
            return print(0)
    return print((2**n)%(10**9+7))

if len(set(a))==(n+1)//2:
    a = sorted(a)
    if n % 2:
        del a[0]
        check(int((n-1)/2), a)
    else:
        check(int(n/2), a)
else:
    print(0)

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

int main() {
    int r;
    int D;
    int x;
    cin >> r;
    cin >> D;
    cin >> x;
    for (int i = 0; i < 10; i++) {
      x = x * r - D;
      cout << x << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 300000
#define P 1000001
using namespace std;
typedef long long ll;
ll n,m,a,b[N],c[N];
ll dp[P];
 
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    dp[a]++;
  }
  for(int i=0;i<P;i++)dp[i]=dp[i]*i;
  for(int i=1;i<P;i++)dp[i]=dp[i-1]+dp[i];
  cin>>m;
  for(int i=0;i<m;i++)cin>>b[i];
  for(int i=0;i<m;i++)cin>>c[i];
  for(int i=0;i<m;i++){
    if(dp[b[i]]>=c[i])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 13656
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace std;

/*
  let's try computer shogi!!!
 */

struct hinge{
  long long int s; // スタート
  long long int t; // 終わり
  long long int h; // 曲がるタイミング
};

const long long int zero = 0;
long long int X;
long long int K;
vector< long long int> r;
vector<hinge> h;

long long int Q;
vector< long long int> t;
vector< long long int> a;

int main(){
  cin >> X;
  cin >> K;
  r.resize(K);
  h.resize(K+1);
  
  h[0].s = zero;
  h[0].t = X;
  h[0].h = zero;
  
  for( long long int i=0;i<K;++i){
    cin >> r[i];
  }
  r.push_back(1145141919);
  cin >> Q;
  t.resize(Q);
  a.resize(Q);
  for( long long int i=0;i<Q;++i){
    cin >> t[i];
    cin >> a[i];
  }
  
  long long int nt = 0;
  long long int qcnt = 0;
  
  for( long long int i=0;i<K+1;++i){
    long long int dt = r[i] - nt;
    
     while(nt <= t[qcnt] && t[qcnt] <= r[i] && qcnt <Q){
       long long int sand = ( a[qcnt] < h[i].h ? h[i].s : min(h[i].s + a[qcnt]-h[i].h, h[i].t));
       cerr<<nt<<","<<t[qcnt]<<","<<r[i]<<","<<i<<","<<sand<<" (nt,t,r,i,sand)"<<endl;
       if(i%2==0){
	 cout<<max(sand-(t[qcnt]-nt),zero)<<endl;
       }else{
	 cout<<min(X,sand+(t[qcnt]-nt))<<endl;
       }
       qcnt++;
     }
     
     if(i==K){continue;}
     cerr<<dt<<"(dt)"<<endl;
     if(i%2==0){
       h[i+1].s = max(h[i].s - dt,zero);
       h[i+1].t = max(h[i].t - dt,zero);
       h[i+1].h = h[i].h + max(zero, (dt - h[i].s));
     }else{
       h[i+1].s = min(X,h[i].s + dt);
       h[i+1].t = min(X,h[i].t + dt);
       h[i+1].h = h[i].h;
     }
     cerr<<h[i+1].s<<","<<h[i+1].t<<","<<h[i+1].h<<"(sth)"<<endl;
     nt = r[i];
  }
}

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

#define ls rt<<1
#define rs rt<<1|1
typedef pair<int,int> pii;
const int maxn = 2e5 + 10;
const int maxm = 1e6 + 10 ;
const int inf=0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int st=(1<<20)-1;
const int mod = 1e9+7;
const double eps = 1e-5;
const int vec[2][2]={1,0,0,1};

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

inline ll sv(ll x) {
    ll ans=1;
    for(int i=1;i<=x;i++) {
        ans*=i;
        ans%=mod;
    }
    return ans;
}

struct node {
    int x,y,id;
}a[maxn];
struct edge{
    int x,y,w;
    bool operator < (const edge &b)const{
        return w<b.w;
    }
}e[maxn<<2];
inline bool cmp1(const node &x,const node &y){
    return x.x<y.x;
}
inline bool cmp2(const node &x,const node &y){
    return x.y<y.y;
}
int f[maxn];
inline int fa(int x) {
    if(f[x]==x) return x;
    return f[x]=fa(f[x]);
}
int main() {
#ifdef LOCAL
    freopen("input.txt","r",stdin);
#endif // LOCAL
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n;
    n=read();
    for(int i=0;i<n;i++) {
        a[i].x=read();
        a[i].y=read();
        a[i].id=i;
    }
    sort(a,a+n,cmp1);
    int m=0;
    for(int i=1;i<n;i++) {
        e[m].x=a[i].id; e[m].y=a[i-1].id;
        e[m].w=a[i].x-a[i-1].x;
        m++;
    }
    sort(a,a+n,cmp2);
    for(int i=1;i<n;i++) {
        e[m].x=a[i].id; e[m].y=a[i-1].id;
        e[m].w=a[i].y-a[i-1].y;
        m++;
    }
    sort(e,e+m);
    for(int i=0;i<n;i++) f[i]=i;
    ll ans=0;
    for(int i=0;i<m;i++) {
        int fx=fa(e[i].x),fy=fa(e[i].y);
        if(fx!=fy) {
            f[fx]=fy;
            ans+=e[i].w;
        }
    }
    cout<<ans;
    return 0;
}
//校园网真tm卡


Measured memory_bytes: 8064
//***in the name of GOD***
#include <bits/stdc++.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[0] == 'S'){
    cout << "Cloudy";
  }else if(s[0] == 'C'){
    cout << "Rainy";
  }else{
    cout << "Sunny";
  }
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    ans = 0
    A = []
    B = []
    N = int(input())

    for _ in range(N):
        s = input()
        ans += s.count("AB")
        if s[0] == "B":
            B.append(1)
        else:
            B.append(0)
        if s[-1] == "A":
            A.append(1)
        else:
            A.append(0)
    if A == B:
        if sum(A) > 0:
            ans += sum(A) - 1
    else:
        ans += min(sum(A), sum(B))
    return ans


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


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K <= A) {
        cout << K << endl;
    }
    else if (A <= K && K <= A+B) {
        cout << A << endl;
    }
    else if (A+B <= K && K <= A+B+C) {
        cout << 2*A+ B -K << endl;
    }   
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int A, B, X;
	cin >> A >> B >> X;

	if (X < A) cout << "NO" << endl;
	else if (X > A + B) cout << "NO" << endl;
	else cout << "YES" << endl;
	

	return 0;
}

Measured memory_bytes: 256