akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    unsigned int x;
    cin >> x;
    bitset<32> bs(x);
    cout << bs << endl;
    cout << ~bs << endl;
    cout << (bs<<1) << endl;
    cout << (bs>>1) << endl;
    return 0;
}




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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  string s;
  cin >> s;
  string ans="";
  for(int i=1;i<=s.length();i++){
    if(i%2){
      ans.push_back(s[i-1]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int count=0;
    for (int i = 1; i < s.size(); i++)
    {
        if(s[i]==s[i-1]){
        }
        else{
            count++;
        }
    }
    cout << count << "\n";
}


Measured memory_bytes: 512
import collections

N = int(input())
A = sorted(map(int, input().split()))[::-1]

dict = {}
line = []
for a in A:
    if a not in dict:
        dict[a] = 1
    else:
        dict[a] += 1

    if dict[a] == 2:
        line.append(a)
    if dict[a] == 4:
        line.append(a)
    if len(line) == 2:
        print(line[0]*line[1])
        break
else:
    print(0)





Measured memory_bytes: 14636
#include<bits/stdc++.h>
using namespace std;
long long n,W,ans,INF=1e9+1,sum,dp[101][100001];
pair<long long,long long> v[101];
int main()
{
    cin >> n >> W;
    for(int i=1; i<=n; i++)
        cin >> v[i].first >> v[i].second, sum += v[i].second;
    sort(v+1,v+1+n);
    for(int i=0; i<=n; i++) { dp[i][0] = 0; for(int j=1; j<=sum; j++) dp[i][j] = INF; }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=sum; j++)
        {
            if(j >= v[1].second)
            {
                if(j >= v[i].second && dp[i-1][j-v[i].second] != INF)
                    dp[i][j] = min(dp[i][j],dp[i-1][j-v[i].second] + v[i].first);
                if(dp[i-1][j] && dp[i-1][j] != INF)
                    dp[i][j] = min(dp[i-1][j],dp[i][j]);
            }
        }
    }
    for(int i=1; i<=sum; i++)
    {
        if(dp[n][i] <= W && dp[n][i]) 
            ans = i;
    }
    cout << ans;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string s ;
  cin >> s ; 
  int ans = 0 ;
  
  rep(i,s.size()){
    if(s.at(i) == '1' ) ans ++ ;
  }
  
  cout <<ans << endl ;
    

}


Measured memory_bytes: 3604
/*
 * author : anaksoleh
 * 30 sep 2019
 */

#include <bits/stdc++.h>
using namespace std;


int main()
{
    int N,K;

    cin >> N >> K;
    int num;
    int cnt = 0;
    for(int i = 1 ; i <= N ; i++){
        cin >> num;
        if(num >= K){
            ++cnt;
        }
    }
    cout << cnt << '\n';

    return 0;
}


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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;    
    if(a == b && b == c && a % 2 == 0){
        cout << -1;
        return 0;
    }
    int ct = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
        int ta = a / 2;
        int tb = b / 2;
        int tc = c / 2;
        a = b = c = 0;
        a = tb + tc;
        b = ta + tc;
        c = ta + tb;
        ct++;
    }
    cout << ct;
    return 0;
}


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

int main()
{
  int n;
  while (std::cin >> n) {
    if (n == 0) break;
    
    bool na = true;
    std::map<int, long long> id_sales_map;

    for (int i = 0; i < n; ++i) {
      int ID;
      long long price, number;
      std::cin >> ID >> price >> number;

      if (id_sales_map[ID] < 1000000) {
        id_sales_map[ID] += price * number;
        if (id_sales_map[ID] >= 1000000) {
          std::cout << ID << std::endl;
          na = false;
        }
      }
    }

    if (na) {
      std::cout << "NA" << std::endl;
    }
  }

  return 0;
}

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

int main(int argc, char *argv[]){
  long long sum=0;
  int N; cin>>N;
  vector<long long> A(N,-1000000001);
  vector<long long> B(N,-1000000001);
  for(int i=0; i<N; i++){
    long long a;
    cin>>a;
    A[i]=a;
    B[i]=a-i+1;
  }
  sort(B.begin(),B.end());
  int med;
   med=B[(N*0.5)];
  
  for(int i=0; i<N; i++){
    sum+=abs(B[i]-med);
   // cout<<abs(B[i])<<" "<<med<<endl;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>

using namespace std;

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

ll arr[100010] = {};


//最大公約数
ll gcd(ll a, ll b) {
	if ( a%b == 0 )
		return b;
	return gcd(b,a%b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	ll n,a,res = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		//cout << lcm(res, a) << endl;
		res = lcm(res,a);
	}

	cout << res << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

long long connect(int a, int b)
{
    ostringstream oss;
    oss << a << b;

    istringstream iss(oss.str());
    long long ret;
    iss >> ret;
    return ret;
}

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

    multiset<int> ms;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        ms.insert(a);
        if(ms.size() > 100)
            ms.erase(--ms.end());
    }

    vector<long long> ret;
    for(multiset<int>::iterator it1=ms.begin(); it1!=ms.end(); ++it1){
        for(multiset<int>::iterator it2=ms.begin(); it2!=ms.end(); ++it2){
            if(it1 != it2)
                ret.push_back(connect(*it1, *it2));
        }
    }
    sort(ret.begin(), ret.end());

    cout << ret[2] << endl;

    return 0;
}

Measured memory_bytes: 1388
#include<stdio.h>
#include<math.h>
int main(){
  int unused __attribute__((unused));
  long int N, B, R, ans;

  unused = scanf("%ld %ld %ld", &N, &B, &R); //N個のボール，B:青ボール，R:赤ボール

  if(B>=0 && R>=0 && N >=1 && N<=pow(10, 18)){
    if(B==0) printf("%d", 0);
    else if(N<=B) printf("%ld", N);
    else if(N<=(B+R)) printf("%ld", B);
    else{
      ans = (N/(B+R))*B;
      if(N%(B+R) > B) ans += B;
      else ans += N%(B+R);
      printf("%ld", ans);
    }
  }

  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
inline void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

vector<vector<int>> timeline(30, vector<int>(200005, 0));
vector<int> use(200005, 0);
int main(){
    
   int n;
   int C;
   scanf("%d%d", &n, &C);
    
   rep(i, n){
       int s, t, c; scanf("%d%d%d", &s, &t, &c);
       ++timeline[c-1][2*s-1]; --timeline[c-1][2*t];
   }
   rep(i, C) partial_sum(timeline[i].begin(), timeline[i].end(), timeline[i].begin());
 

   rep(i, C) rep(j, 200001) if(timeline[i][j] > 0) ++use[j];
   ppp(*max_element(use.begin(), use.end()));


   return 0;
}


Measured memory_bytes: 24576
from sys import stdin

n = int(stdin.readline().rstrip())
p_lst = [int(x) for x in stdin.readline().rstrip().split()]

if sorted(p_lst) == p_lst:
  print("YES")
else:
  for i in range(n):
    for j in range(n):
      if i < j:
        p_lst_tmp = p_lst.copy()
        tmp = p_lst_tmp[i]
        p_lst_tmp[i] = p_lst_tmp[j]
        p_lst_tmp[j] = tmp
        if sorted(p_lst_tmp) == p_lst_tmp:
          print("YES")
          exit()
  print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
ll ans,n,q;
string s;

cin >> n>>q;
cin >> s;

int len=(int)(s.length());
int table[len]={0};
rep(i,n-1) {
    if(s[i]=='A'&&s[i+1]=='C'){
        if(i==0)table[i]=1;
        else table[i]=table[i-1]+1;
    }
    else {
        if(i==0)table[i]=0;
        else table[i]=table[i-1];
    }
}
/* for (int i = 0; i < n; ++i) {
    cout << table[i] << " ";
}cout  << endl; */

rep(i,q){
    int l,r,aa;
    cin >> l>>r;
    if(l-2<0)aa=0;
    else aa=table[l-2];
    cout <<table[r-2]-aa << endl;
}



return 0;
}





Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int h,w;cin>>h>>w;
    int b = 0;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) {
            cin>>a[i][j];
            if(a[i][j] == '#') b++;
        }    
    }
    cout << (b == h + w - 1 ? "Possible":"Impossible") << endl;
    return 0;
    
}


Measured memory_bytes: 256
package main

import "fmt"

var H []int
var T [][]int

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	H = make([]int, N)
	T = make([][]int, N)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		H[i] = V
		T[i] = []int{}
	}
	for i := 0; i < M; i++ {
		var A, B int
		fmt.Scan(&A, &B)
		T[A-1] = append(T[A-1], B-1)
		T[B-1] = append(T[B-1], A-1)
	}
	ans := make(map[int]bool)
	for i := 0; i < N; i++ {
		highest := H[i]
		flag := true
		for _, node := range T[i] {
			if highest <= H[node] {
				flag = false
				break
			}
		}
		if flag {
			ans[i] = true
		}
	}
	fmt.Println(len(ans))
}


Measured memory_bytes: 14420
n = gets.chomp.to_i
hlist = gets.chomp.split.collect{ |item| item.to_i}
list = hlist.reverse
result = "Yes"
prev = list[0]
list.each do |hi|
  if hi <= prev
    prev = hi
  elsif (hi-1) <= prev
    prev = hi-1
  else
    result = "No"
  end
end
puts result

Measured memory_bytes: 12804
mod = 10 ** 9 + 7

N, K = [int(i) for i in input().split()]
B, R = 1, N - K + 1
for i in range(K):
    print(B * R % mod)
    B = B * (K - i - 1) // (i + 1)
    R = R * (N - K - i) // (i + 2)


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextInt();
        long b = scanner.nextInt();
        long c = scanner.nextInt();
        if(c-a-b<0){
            System.out.println("No");
        }else if((c-a-b)*(c-a-b)>4*a*b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  string s;
  cin >> s;
  string t;
  for(int i=0;i<3;i++) t += s[i];
  cout << t << endl;
  return 0;
}


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

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

	int64_t D, T, S;
	cin >> D >> T >> S;

	if (T*S >= D) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3648
/**
 * Libraries
 */
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <iomanip>
#include <set>
#include <unordered_map>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

/**
 * macros
 */
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define repx(i,s,e,d) for(int i=s,i##_end=(e);i<i##_end;i+=d)
#define repxr(i,s,e,d) for(int i=s,i##_end=(e);i>i##_end;i+=d)
#define rept(n) for(int ___i___=0,i##_len=(n);___i___<i##_len;++___i___)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end());
#define CEIL(x, y) (((x) + (y) - 1) / (y))

/**
 * helpers
 */
typedef long long int lli;
typedef pair<int, int> ii;
#define int long long int
// struct S{
//     bool operator<(const S& x) const {
//         return ;
//     }
// };
struct Robot{
    int x, l;
    int deleted;
    inline int right() {
        return x + l;
    }
    inline int left() {
        return x - l;
    }
    bool operator<(const Robot& r) const {
        return this->x - this->l < r.x - r.l;
    }
};

signed main() {
    int N; cin >> N;
    Robot robots[100000];
    rep(i, N) {
        int x, l; cin >> x >> l;
        robots[i].x = x; robots[i].l = l;
        robots[i].deleted = 0;
    }
    sort(robots, robots + N);

    ii rL[100000];
    rep(i, N) {
        rL[i] = ii(i, robots[i].left());
    }
    sort(rL, rL + N, [](const ii& x, const ii& y) {
            return x.second < y.second;
            });

    rep(i, N) {
        if (robots[i].deleted == 1) continue;

        int rl = robots[i].left(), rr = robots[i].right();
        auto li = lower_bound(rL, rL + N, ii(-1, rl), [](const ii& x, const ii& y) {
            return x.second < y.second;
            });
        auto ri = lower_bound(rL, rL + N, ii(-1, rr), [](const ii& x, const ii& y) {
            return x.second < y.second;
            });

        bool deleteMe = false;
        for (auto it = li; it != ri; ++it) {
            int j = it->first;
            if (i == j) continue;
            if (robots[j].deleted == 1) continue;

            if (robots[j].right() < rr) {
                deleteMe = true;
                break;
            }
        }

        if (deleteMe) {
            robots[i].deleted = 1;
            continue;
        }
        for (auto it = li; it != ri; ++it) {
            int j = it->first;
            if (i == j) continue;
            if (robots[j].deleted == 1) continue;

            if (rr <= robots[j].right()) {
                robots[j].deleted = 1;
            }
        }
    }

    int ans = 0;
    rep(i, N) {
        if (robots[i].deleted == 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

namespace ConsoleApp7
{
    class Program
    {

        static void Main(string[] args)
        {
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    int imul = i * j;

                    Console.WriteLine(i + "x" + j + "=" + imul);
                }
            }
        }
    }
}
   


Measured memory_bytes: 13732
num = int(input())

p = [0, 0]

for i in range(num):
    list = input().split()
    if list[0] == list[1]:
        p[0] += 1
        p[1] += 1
    elif sorted(list)[0] == list[0]:
        p[1] += 3
    else:
        p[0] += 3

print(p[0],p[1])


Measured memory_bytes: 5596
(defun c ()
  (let* ((n (read))
         (m (list (list -1 -1))))
    (dotimes (i n)
      (let ((x (read)))
        (cond ((> x (caar m))
               (push (list x i) m))
              ((> x (caadr m))
               (setf (cdr m) (list (list x i)))))))
    (dotimes (i n)
      (format t "~a~%"
              (if (= i (cadar m))
                  (caadr m)
                  (caar m))))))
(c)

Measured memory_bytes: 59112
def prime(num):
    if num==1:
        return False
    elif num==2 or num==3:
        return True
    else:
        for i in range(2,int(num**0.5)+1):
            if num%i==0:
                return False
        else:
            return True

n=int(input())
tmp=n
plist=[]
if prime(n):
    print('{}: {}'.format(n,n))
else:
    while 1:
        for i in range(2,tmp+1):
            if tmp%i==0:
                plist.append(i)
                tmp=tmp//i
                break
        else:
            break
    print('{}: {}'.format(n,' '.join(map(str,plist))))


Measured memory_bytes: 5640
"""
22:40:00

"""
N, M, Q = map(int, input().split())

fields = [[0] * (N+1) for i in range(N+1)]
accs = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    L,R = map(int, input().split())
    fields[L][R] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        accs[i][j] = fields[i][j] + accs[i-1][j] + accs[i][j-1] - accs[i-1][j-1]
# print(accs)
ans = []
for i in range(Q):
    p,q = map(int, input().split())
    ans.append(accs[q][q] - accs[p-1][q])
    print(accs[q][q] - accs[p-1][q])
# print(*ans)    

Measured memory_bytes: 19452
import sys
from string import ascii_lowercase as AL

input = sys.stdin.readline


def main():
    S = input().rstrip()
    K = int(input())

    N = len(S)
    T = [s for s in S]
    for i in range(N):
        if T[i] == "a":
            continue
        idx = AL.index(T[i])
        if 26 - idx <= K:
            K -= (26 - idx)
            T[i] = "a"

    _, r = divmod(K, 26)
    T[-1] = AL[AL.index(T[-1]) + r]

    ans = "".join(T)
    print(ans)


if __name__ == "__main__":
    main()


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

const int MAXN = 400002;

int b[52];
bool c[52][52];
bool pc[52];

bool a[52][52][52];

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); cout.tie(nullptr); cin.tie(nullptr);
    int n;
    cin >> n;

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

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

    for (int i = 0; i <= 50; ++i) {
        a[0][i][i] = true;
    }

    for (int i = 1; i <= 50; ++i) {
        for (int j = 0; j <= 50; ++j) {
            for (int l = 0; l <= 50; ++l) {
                a[i][j][l] = a[i - 1][j][l] | a[i - 1][j % i][l];
            }
        }
    }


    ll ans = 0;

    for (int j = 50; j > 0; --j) {
        bool gd = true;
        for (int l = 0; l < n && gd; ++l) {
            gd = false;
            for (int i = 0; i <= 50; ++i) {
                gd |= c[l][i] && a[j - 1][i][b[l]];
            }
        }

        if (gd) {
            continue;
        }

        ans += (1ll << j);

        for (int i = 0; i < n; ++i) {
            memcpy(pc, c[i], sizeof(pc));
            for (int l = 0; l <= 50; ++l) {
                c[i][l % j] |= pc[l];
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        if (!c[i][b[i]]) {
            cout << "-1\n";
            return 0;
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 384
n,q=map(int,input().split())
ls=[]
for _ in range(n):
    ls.append(list(map(str,input().split())))
ans=[]
time=0
while len(ls)!=0:
    lsi=ls[0]
    lsi1=int(lsi[1])
    if lsi1>q:
        time+=q
        lsi[1]=lsi1-q
        ls.append(lsi)
        ls.pop(0)
    elif lsi1<=q:
        time+=lsi1
        lsi[1]=time
        ans.append(lsi)
        ls.pop(0)

def convert(list):
    res=" ".join(map(str, list))
    return res

for j in ans:
    print(convert(j))


Measured memory_bytes: 15656
N=int(input())
T,X,Y=0,0,0
for i in range(N):
  t,x,y=map(int,input().split())
  if abs(X-x)+abs(Y-y)>t-T or t%2!=(x+y)%2:
    print("No")
    exit()
  T,X,Y=t,x,y
print("Yes")


Measured memory_bytes: 3060
n=int(input())
a=[3,5,7,9,11,13,17,19]

count=0
for i in range(len(a)):
  for j in range(i+1,len(a)):
    for k in range(j+1,len(a)):
      if a[i]*a[j]*a[k]<=n:
        count+=1

print(count)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
vector<int> G[1003];
int N,M;
bool visited[1003];

void dfs(int v,int &cnt) {
    if(visited[v]) return;

    cnt++;
    visited[v]=true;
    for(auto u:G[v]) {
        if(visited[u]) continue;
        dfs(u,cnt);
    }

}

int main() {
    cin>>N>>M;
    rep(i,M) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans=0;
    rep(i,N) {
        if(visited[i]) continue;
        int cnt=0;
        dfs(i,cnt);
        if(cnt==1) ans++;
        else ans--;
    }
    cout<<abs(ans)<<endl;
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------



int main() {

  int a, b;
  cin >> a >> b;

  if(a>=13) {
    cout << b << endl;
  }else if(a>=6) {
    cout << b/2 << endl;
  }else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main(){

    input!{
        r: f32,
    }

    let pi = 3.14;
    println!("{}", 2.0*r*pi);

}

Measured memory_bytes: 2228
N =int(input())
l =[input()]
s =l[0][-1]
a = True
for i in range(N-1):
    m =input()
    if not m in l and m[0]==s:
        l.append(m)
        s = m[-1]
    else:
        a=False
        break
if a:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#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() {
   int a,b;cin>>a>>b;
   if(a%2==b%2)
   {
       cout<<(a+b)/2<<endl;
   }
   else
   {
       cout<<"IMPOSSIBLE"<<endl;
   }
   
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, k, p;
	int i, j;
	scanf("%d%d", &k, &n);
	if (n%k == 0)
		printf("%d", n / k);
	else
	{
		for (i = n / k; i >= 2; i--)
		{
			if (n%i == 0)
				break;
		}
		printf("%d", i);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n, t[100001], x[100001], y[100001];
int main()
{
	
	cin >> n;
	REP(i, 0, n) cin >> t[i] >> x[i] >> y[i];
	
	bool flag = true;
	int nt = 0, nx = 0, ny = 0;
	REP(i, 0, n) {
		int dist = abs(x[i] - nx) + abs(y[i] - ny);
		int tm = t[i] - nt;
		
		if (tm < dist) {
			flag = false;
			break;
		}
		if ((tm - dist) % 2 != 0) {
			flag = false;
			break;
		}

		nt = t[i];
		nx = x[i];
		ny = y[i];
	}
	
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int num=9999;
	static int d;
	static int g;
	static int p[];
	static int c[];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		d = sc.nextInt();
		g = sc.nextInt();
		p = new int[d];
		c = new int[d];

		for(int i=0;i<d;i++) {
			p[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		calc(0,0,0,0);
		
		System.out.println(num);
	}
	
	static void calc(int piv, int tmp_num, long tmp_sum, long check) {
		if( piv==d ) {
			if( tmp_sum<g ) {
				for(int i=d;i>0;i--) {
					// 既に解いている問題ならスルー
					if( check/(Math.pow(10,i-1))==1 || (check/(Math.pow(10,i-1)))%Math.pow(10,d-i) == 1)
						continue;
					if( tmp_sum+100*i*(p[i-1]-1) >= g ) {
						while(true) {
							tmp_num++;
							tmp_sum += 100*i;
							if(tmp_sum >= g)
								break;
						}
						break;
					}
				}
			}
			if( tmp_sum>=g && num>tmp_num && tmp_num!=0 )
				num = tmp_num;
			return;
		}
		
		// 100*piv点の問題を全て解いた場合
		calc(piv+1,tmp_num+p[piv],tmp_sum+100*(piv+1)*p[piv]+c[piv],check+(long)Math.pow(10,piv));
		// 100*piv点の問題を全く解かない場合
		calc(piv+1,tmp_num,tmp_sum,check);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a[112345];

    cin >> n;
    REP(i, n)
    cin >> a[i];

    bool used[112345];
    fill(used, used + n + 1, false);

    int res = 0;
    int cur = 1;
    while (true)
    {
        used[cur] = true;
        cur = a[cur - 1];

        res++;

        if (used[cur])
        {
            cout << -1 << endl;
            return 0;
        }
        if (cur == 2)
        {
            cout << res << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;

int main(){
	int n,A[200000],B[200000],count=0,sw=1,now,a=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	now=n/2;
	if(n%2==1){
		sw=-1;
	}
	for(int i=0;i<n;i++){
		B[now]=A[i];
		count++;
		sw*=-1;
		now+=count*sw;
	}
	for(int i=0;i<n;i++){
		cout<<B[i];
		if(i!=n-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string S;

int main()
{
    cin >> S;
    if (S == "ABC") {
        cout << "ARC" << endl;
        return 0;
    } else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>

using namespace std;

int C[3][3];

int main() {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> C[i][j];
    }
  }
  for (int i = 0; i < 3; ++i) {
    if (!((C[i][0] - C[(i + 1) % 3][0]) == (C[i][1] - C[(i + 1) % 3][1]) &&
          (C[i][1] - C[(i + 1) % 3][1]) == (C[i][2] - C[(i + 1) % 3][2]))) {
      printf("No\n");
      return 0;
    }
  }
  for (int j = 0; j < 3; ++j) {
    if (!((C[0][j] - C[0][(j + 1) % 3]) == (C[1][j] - C[1][(j + 1) % 3]) &&
          (C[1][j] - C[1][(j + 1) % 3]) == (C[2][j] - C[2][(j + 1) % 3]))) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		int[] t = new int[n + 2];
		String[] sa = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			t[i + 1] = t[i] + Integer.parseInt(sa[i]);
		}
		t[n + 1] = t[n];

		int[] v = new int[n + 2];
		sa = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			v[i + 1] = Integer.parseInt(sa[i]);
		}
		br.close();

		double ans = 0;
		double pre = 0;
		for (double x = 0.5; x <= t[n]; x+=0.5) {
			double min = Double.MAX_VALUE;
			for (int i = 0; i < v.length; i++) {
				min = Math.min(min, calc(t, v, i, x));
			}
			ans += (min + pre) / 4;
			pre = min;
		}
		System.out.println(ans);
	}

	static double calc(int[] t, int[] v, int i, double x) {
		if (i == 0) {
			return x;
		}
		if (x < t[i - 1]) {
			return v[i] + t[i - 1] - x;
		} else if (t[i - 1] <= x && x <= t[i]) {
			return v[i];
		} else {
			return v[i] + x - t[i];
		}
	}
}


Measured memory_bytes: 22996
a, b, c, x = [int(input()) for i in range(4)]
v = 0
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            v = (500*i) + (100*j) + (50*k)
            if v == x:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <numeric>
#define ll long long
using namespace std;
int main() {
  int M1,D1,M2,D2;
  cin>>M1>>D1>>M2>>D2;
  if(D2==1) cout<<"1"<<endl;
  else cout<<"0"<<endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int md=1e9+7;
int n,c[100005],ans=1;
int main()
{
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		c[x]++;
	}
	for(int i=(n&1)^1;i<n;i+=2)
	{
		if(c[i]!=2-(i==0))
		{
			puts("0");
			return 0;
		}
		ans=ans*c[i]%md;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
import sys
import itertools
import math
N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = [int(v) for v in input().split()]
    X.append(x)
    Y.append(y)

s = range(N)
ll = []
for l in itertools.permutations(s):
    d = 0
    for j in range(N - 1):
        d += math.sqrt((X[l[j]] - X[l[j + 1]]) * (X[l[j]] - X[l[j + 1]]) + (Y[l[j]] - Y[l[j + 1]]) * (Y[l[j]] - Y[l[j + 1]]))
    # print(l)
    # print(d)
    ll.append(d)
print(sum(ll) / len(ll))

Measured memory_bytes: 4400
#include<stdio.h>
 
#define INF 10000
#define WHITE 0
#define BLACK 1
#define NIL -1
 
int n,d[100],pi[100],w[100][100],mincost,cost;
 
void prim(void)
{
  int u,v,i,color[100];
  for(u=0;u<n;u++)
    {
      d[u]=INF;
      pi[u]=NIL;
      color[u]=WHITE;
    }
  d[1]=0;
   
  while(1)
    {
      mincost=INF;
      for(i=0;i<n;i++)
    {
      if((color[i]!=BLACK)&&(d[i]<mincost))
        {
          mincost=d[i];
          u=i;
        }
    }
      if(mincost==INF)
    {
      break;
    }
 
      color[u]=BLACK;
 
      for(v=0;v<n;v++)
    {
      if((color[v]!=BLACK)&&(w[u][v]<d[v]))
        {
          pi[v]=u;
          d[v]=w[u][v];
        }
    }
    }
  for(i=0;i<n;i++)
    {
      cost+=d[i];
    }
}
 
int main()
{
  int i,j;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
    {
      scanf("%d",&w[i][j]);
      if(w[i][j]==-1) w[i][j]=INF;
    }
    }
  prim();
   
  printf("%d\n",cost);
     
 
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int m;
  while(cin>>m){
    if(m==0) break;
    double s1=0,s2=0;
    int t1=0,t2=0;
    REP(i,m-1){
      int t;
      cin>>t;
      s1 += sin((double)t*M_PI/180);
      t1 += t;
    }
    s1+=sin((double)(360-t1)*M_PI/180);
    cin>>m;
    REP(i,m-1){
      int t;
      cin>>t;
      s2 += sin((double)t*M_PI/180);
      t2 += t;
    }
    s2 += sin((double)(360-t2)*M_PI/180);
    if(abs(s1-s2)<EPS){
      cout<<0<<endl;
    }else if(s1>s2){
      cout<<1<<endl;
    }else if(s2>s1){
      cout<<2<<endl;
    }
  }
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, x;
  cin >> N >> x;
  vint a(N);
  rep(i, N) cin >> a[i];
  int dp[N][N];
  rep(i, N) dp[0][i] = a[i];
  reps(i, 1, N) {
    rep(j, N) dp[i][j] = min(dp[i-1][j], a[(j-i+N)%N]);
  }

  int ans = inf;
  rep(i, N) {
    int sum = i*x;
    rep(j, N) sum += dp[i][j];
    chmin(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 31488
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define rsort(obj) sort(ALL(obj)); reverse(ALL(obj))
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define LLINF 1145141919810LL
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  typedef pair<int, int> P;
  int N, a, b, c, d; cin >> N;
  vector<P> red, blue;
  REP(i, N){
    cin >> a >> b;
    red.pb(P(b, a));
  }
  REP(i, N){
    cin >> c >> d;
    blue.pb(P(c, d));
  }
  sort(ALL(red)); sort(ALL(blue)); reverse(ALL(red));
  bool use[100] = {};
  int ans = 0;
  REP(i, N){
    REP(j, N){
      P R = red[j], B = blue[i];
      if(R.second < B.first and R.first < B.second and !use[j]){
        use[j] = 1; ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

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

        static int[] Solve(int N, int[][] edges)
        {
            var children = new List<Tuple<int, int>>[N];
            for (int i = 0; i < N; ++i) { children[i] = new List<Tuple<int, int>>(); }
            foreach (int[] edge in edges)
            {
                int u = edge[0] - 1;
                int v = edge[1] - 1;
                int w = edge[2];
                children[u].Add(new Tuple<int, int>(v, w));
                children[v].Add(new Tuple<int, int>(u, w));
            }
            var visited = new bool[N];
            var colors = new int[N];
            var queue = new Queue<int>();
            visited[0] = true;
            queue.Enqueue(0);
            while (queue.Count > 0)
            {
                int a = queue.Dequeue();
                foreach (var child in children[a])
                {
                    int b = child.Item1;
                    int w = child.Item2;
                    if (!visited[b])
                    {
                        visited[b] = true;
                        colors[b] = (w % 2 == 0) ? colors[a] : colors[a] ^ 1;
                        queue.Enqueue(b);
                    }
                }
            }
            return colors;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            var edges = new int[N - 1][];
            for (int i = 0; i < N - 1; ++i) { edges[i] = ReadInts(); }
            foreach (int ans in Solve(N, edges))
            {
                Console.WriteLine(ans);
            }
        }
    }
}


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

bool prime[100010];
int c[100010];
int Q;

int main () {

    fill(prime, prime + 100000, true);
    for (int i = 2; i <= 100000; i++) {
        if (prime[i]) {
            for (int j = i + i; j <= 100000; j += i) {
                prime[j] = false;
            }
        }
    }

    for (int i = 3; i <= 100000; i++) {
        if (prime[i] && prime[(i+1)/2]) {
            c[i]++;
        }
    }

    for (int i = 4; i <= 100000; i++) {
        c[i] += c[i-1];
    }

    scanf("%d", &Q);

    for (int i = 0; i < Q; i++) {
        int l, r;
        scanf("%d %d", &l, &r);

        printf("%d\n", c[r] - c[l-1]);
    }

    return 0;
}

Measured memory_bytes: 1152