akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx; int dy = ty - sy;
	rep(i, dy) {
		cout << "U";
	}
	rep(i, dx) {
		cout << "R";
	}
	rep(i, dy) {
		cout << "D";
	}
	rep(i, dx) {
		cout << "L";
	}
	cout << "L";
	dy++; dx++;
	rep(i, dy) {
		cout << "U";
	}
	rep(i, dx) {
		cout << "R";
	}
	cout << "D" << "R";
	rep(i, dy) {
		cout << "D";
	}
	rep(i, dx) {
		cout << "L";
	}
	cout << "U" << endl;
	return 0;
}

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

using namespace std;

#define run_forrest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define pii pair <int, int>
#define sz(a) (int)a.size()
#define F first
#define S second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;	
const int mod = inf + 7;

const int N = 1e5+500;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);	

ll countdiv(ll l, ll r, ll d)
{
	 if (l % d == 0) 
        return (r / d) - (l / d) + 1; 
  
    // A is not divisible by M 
    return (r / d) - (l / d); 
}

long long gcdl(ll a, ll b)
{
	if(b==0)return a;else return gcd(b,a%b);
}
long long lcml(ll a, ll b)
{
	return abs(a*b)/gcdl(a,b);
}

int main()
{                   
	run_forrest_run;
	ll l,r,a,b;
	cin >> l >> r >> a >> b;
	ll LCM = lcml(a,b);
	ll cnt =  countdiv(l,r,a);
	ll cnt2 = countdiv(l,r,b);
	ll both = (r/LCM)-((l-1)/LCM);
	ll all = cnt+cnt2 - both;
	cout << (r-l+1)-all;
}

Measured memory_bytes: 3072
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_int_tuple();
    let mut sum = 0;
    for i in 0..(b - a) {
        sum += i;
    }
    println!("{}", sum - a);
}


Measured memory_bytes: 4352
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
 
#define MAX_V 1024
using namespace std;
 
void get_map();
void check();
struct edge
{
  int to;
  int weight;
};
 
 
#define INF INT_MAX/4
vector<edge> g[2000];
int graph[MAX_V][MAX_V];
int dist[MAX_V];
int numofedge;
int vertex;
int start;
int flag=0;
 
int main()
{
  get_map();
  check();
  {
    for(int j=0;j<vertex;j++) {
      if(graph[start][j]<INF/2 && graph[j][j]<0) {
          cout << "NEGATIVE CYCLE" <<endl;
          return 0;
      }
    }
  }
  
  for(int i=0;i<vertex;i++) {
    if(graph[start][i]>=INF/2) {
      cout << "INF" << endl;
    } else {
      cout << graph[start][i] << endl;
    }
  }
  return 0;
}
 
inline int fastmin(int a, int b) {
  return (((a-b)>>31)&(a-b))+b;
}

int mymin_slow(int a, int b) {
  int t;
  if (a < b) {
    t = a + 1;
    t--;
  } else {
    t = b;
    t = b + 1;
    b--;
  }
  return t;
}
 
void check()
{
  for(int k=0;k<vertex;k++) {
    for(int i=0;i<vertex;i++) {
      int gik= graph[i][k];
      for(int j=0;j<vertex;j++) {
        graph[i][j]= fastmin(graph[i][j], gik+graph[k][j]);
      }
    }
  }
}
 
void get_map()
{
  int edge, from ,to;
  cin >> vertex >> numofedge >> start;
   
  fill(graph[0], graph[vertex], INF);
   
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
        {
          if(i==j)
            {
              graph[i][j]=0;
            }
          /*else
            {
            graph[i][j]=INF;
            }*/
        }
    }
 
  /*for(int i=0;i<vertex;i++)
    {
    dist[i]=INF;
    }
  */
  for(int i=0;i<numofedge;i++)
    {
      cin>>from>>to;
      cin >> graph[from][to];
    }
 
  /*  for(int i=0;i<numofedge;i++)
      {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
      }
  */ 
 
  /*  for(int i=0;i<vertex;i++)
      {
      for(int j=0;j<vertex;j++)
      {
      cout << graph[i][j] << " ";
      }
      cout << endl;
      }*/
  // dist[start]=0;
   
  /*  cout << vertex << endl;
      for(int i=0;i<vertex;i++)
      {
      for(int j=0;j<vertex;j++)
      {
      cout << graph[i][j] << " ";
      }  
      cout << endl;    
      }*/
   
 
}

Measured memory_bytes: 5300
#include <stdio.h>
int main ()
{
	int A,B,C,D,E,F;
	-1000<=A;
	B <=1000;
	scanf ("%d", &A);
	scanf ("%d", &B);
	C = A + B;
	D = A - B;
	E = A * B;
	F = "0";
	if (C >= D && C >= E){
		printf ("%d", C);
	} else if ( D >= C && D >= E){
		printf ("%d", D);
	} else if (E >= C && E >= D){
		printf ("%d", E);
	} else if (A = B = 0) {
	   printf ("%d", F);
	} return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>

constexpr unsigned long Q = 1000000007;

unsigned long rpow(unsigned long x, int n){
  if(n == 0){
    return 1;
  }
  unsigned long result = rpow(x * x % Q, n / 2);
  if(n % 2 == 0){
    result %= Q;
  } else{
    result = result * x % Q;
  }
  return result;
}

int main(){
  int m, n;
  scanf("%d %d", &m, &n);
  printf("%ld\n", rpow(m, n));
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll cnt[214514];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		ll x;
		cin>>x;
		cnt[x]++;
	}
	for(int i=1;i<=n;i++)cout<<cnt[i]<<endl;
	return 0;
}


Measured memory_bytes: 5084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final String s = sc.next();
		final String list[] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
				"r", "s", "t", "u", "v", "w", "x", "y", "z" };

		int count = 0;
		for (int i = 0; i < list.length; i++) {
			if (s.indexOf(list[i]) >= 0) {
				count++;
				continue;
			} else {
				System.out.print(list[i]);
				break;
			}
		}

		if (count == list.length) {
			System.out.print("None");
		}

	}

}

Measured memory_bytes: 25300
n,k=map(int,input().split())
s=input()
l=[]
c=1
for i in range(n-1):
  if not s[i]==s[i+1]:
    l.append(c)
    c=0
  c+=1
l.append(c)
l=l+[0]
if s[0]=='0':
  l=[0]+l
tmp=sum(l[:2*k+1])
ans=tmp
for i in range(2,len(l)-2*k,2):
  tmp=tmp-l[i-1]-l[i-2]+l[i+2*k-1]+l[i+2*k]
  ans=max(ans,tmp)
print(ans)

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

int main() {

  int N;
  cin >> N;
  int j=0;
  
  while (j < N) {
    string S;
    cin >> S;
      if (S=="Y"){
        break;
      }
      else {
        j++;
      }
  }
  if (j==N){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
  }
    

    
 








Measured memory_bytes: 256
/***************************************** SHORT - TEMPLATE ***************************************************/
#pragma optimization_level 3
#include<bits/stdc++.h>
using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)		
#define  all(x)         (x).begin(),(x).end()
#define  newl           cout<<"\n"
#define  pb             push_back
#define  s              second
#define  f              first
#define  ll             long long
#define  vll            vector<ll>
#define  MOD            1000000007
#define  INF            LLONG_MAX
#define  N              200008

/***************************************** FUNCTIONS / DECLARATIONS ********************************************/
ll t=1;
ll n, k,res=INF;
ll a[N];

/***************************************** MAIN FUNCTION - DRIVER *******************************************************/
void MAIN(){
	cin>>k>>n;
	foo(i,1,n)cin>>a[i];
	foo(i,2,n-1)res = min({res, k-(a[i]-a[i-1]), k-(a[i+1]-a[i])});
	res = min(res, a[n]-a[1]);
	cout<<res;newl;	
	
}

int main(){
	fastio;//cin>>t;
	while(t--){
		MAIN();
	}
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int dp[41][401][401];

int main(int argc, char *argv[]) {
  // INFILE();
  int n, ma, mb;
  cin >> n >> ma >> mb;

  vector<vector<int>> goods(n);
  for (auto &g : goods) {
    g.resize(3);
    scan(g);
  }

  fill((int *)dp, (int *)dp[41], 99999);
  for (int i = 0; i < n; i++) {
    dp[i][0][0] = 0;
  }

  for (int k = 1; k <= n; k++) {
    for (int i = 1; i < 401; i++) {
      for (int j = 1; j < 401; j++) {
        if (i - goods[k - 1][0] < 0 || j - goods[k - 1][1] < 0) {
          dp[k][i][j] = dp[k - 1][i][j];
          continue;
        }

        dp[k][i][j] = min(dp[k - 1][i][j],
                          dp[k - 1][i - goods[k - 1][0]][j - goods[k - 1][1]] +
                              goods[k - 1][2]);
      }
    }
  }

  int ans = 99999;
  for (int i = 1; i < 401; i++) {
    for (int j = 1; j < 401; j++) {
      if (ma * j == mb * i) {
        ans = min(ans, dp[n][i][j]);
      }
    }
  }

  if (ans == 99999) {
    cout << "-1\n";
    return 0;
  }

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

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 25984
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  if ( s.front() == s.back() ) {
    if ( sz(s) % 2 == 1 ) std::cout << "Second" << std::endl;
    else std::cout << "First" << std::endl;
  }
  else {
    if ( sz(s) % 2 == 1 ) std::cout << "First" << std::endl;
    else std::cout << "Second" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 512
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int ans = 0;
    for(int i = 1; i <= N; i++){
      int sum = 0;
      String s = i + "";
      for(int j = 0; j < s.length(); j++){
        char c = s.charAt(j);
        sum += (c - '0');
      }
      if(sum >= A && sum <= B){
        ans += i;
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
constexpr int MOD = 1e9 + 7;
inline int quick_pow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		n >>= 1;
	}
	return res;
}
int main()
{
	// freopen("AGC038-A.in", "r", stdin);
	int n, m, a, b;
	scanf("%d%d%d%d", &n, &m, &a, &b);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			putchar(((i < b) ^ (j < a)) + '0');
		puts("");
	}
	return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,m;cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    rep(i,n)
    {
        cin >> a[i];
        sum += a[i];
    }
    int counter = 0;
    rep(i,n)
    {
        if(4*a[i]*m < sum)
        {
            continue;
        } 
        counter++;
    }
    if(counter >= m)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using namespace std;
int n;
long long x = 0;
int main()
{
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >>n;
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 1; j <= n; ++j)
    {
      int g = __gcd(i, j);
      for (int k = 1; k <= n; ++k)
      {
        x += __gcd(g, k);
      }
    }
  }
  cout <<x << '\n';
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define l1 long
#define ld long double
#define lld long long double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x) cout<<"$ "<<x<<" $"<<endl
#define bug(x) cout<<"& "<<x<<" &"<<endl
#define all(v) v.begin(),v.end()
#define lop1(i,j,n) for(int i=j; i<n; ++i)
#define lop2(i,j,n) for(int i=j; i<=n; ++i)
#define lop3(i,n,j) for(int i=n; i>j; --i)
#define lop4(i,n,j) for(int i=n; i>=j; --i)
#define view(v) for(auto i: v) cout<<i<<" "
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
const ll M=1e9+7;
const ld PI=3.1415926536;
//int p[N];
//int find(int k){ return p[k]==k ? k : p[k]=find(p[k]); }
using namespace std;

void solve()
{
    int x;
    cin>>x;
    if(x>=400 and x<=599) cout<<8;
    else if(x>=600 and x<=799) cout<<7;
    else if(x>=800 and x<=999) cout<<6;
    else if(x>=1000 and x<=1199) cout<<5;
    else if(x>=1200 and x<=1399) cout<<4;
    else if(x>=1400 and x<=1599) cout<<3;
    else if(x>=1600 and x<=1799) cout<<2;
    else if(x>=1800 and x<=1999) cout<<1;
    return;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    fast
    ll t=1;
	//cin>>t;
    while(t--) solve();
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define ll long long
#define ar array
static auto _ = [] {
    std::ios::sync_with_stdio (0);
    std::cin.tie (0);
    std::cout.tie (0);
    std::cerr.tie (0);
    return 0;
}
();

void solve() {
    int n;
    cin >> n;
    int a;
    for(int i = 0; i < n; ++i){
        cin >> a;
        if(a % 2 == 0){
            if(a % 3 && a % 5){
                cout << "DENIED" << endl;
                return ;
            }
        }
    }
    cout << "APPROVED" << endl;
}

int main() {
    ios::sync_with_stdio (0);
    cin.tie (0);
    int testCases;
    testCases = 1;
    while (testCases --) {
        solve();
    }
    return 0;
}




Measured memory_bytes: 256
#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 Speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define fr first
#define sc second
#define pb push_back
#define PI acos(-1.0)
#define print(num,ans) cout<<setprecision(num)<<fixed<<ans
#define ordered_set tree<pair<int,int> , null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>


int main()
{
    Speed;
    string s , t;
    cin>>s>>t;
    ll ans = 0;
    for(int i=0;i<s.size();i++)
        if(s[i] == t[i])ans++;
        cout<<ans;


    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    a = int(input())
    b, c = map(int, input().split())
    i =0
    j = 0
    flag = 0
    while j <=c:
        i +=1
        j = a *i
        if j >=b and j<= c :
            flag = 1

    if flag == 0:
        print("NG")
    else:
        print("OK")

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vpii ab(n),cd(n);
    rep(i,0,n)cin>>ab[i].first>>ab[i].second;
    rep(i,0,n)cin>>cd[i].second>>cd[i].first;
    sort(ab.begin(),ab.end());
    sort(cd.begin(),cd.end());
    vb is_emp(n,true);
    int cnt=0;
    rep(bi,0,n){
        int alt=-1;
        rep(ri,0,n){
            //極力小さいdで，極力大きいaを相手したい．
            if(is_emp[ri]&&ab[ri].first<cd[bi].second&&ab[ri].second<cd[bi].first){
                alt=ri;
            }
        }
        if(alt!=-1){
            is_emp[alt]=false;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int dx[2][7] = {{1, 1, 0, 0, 0, -1, -1}, {1, 1, 0, 0, 0, -1, -1}};
int dy[2][7] = {{-1, 0, -1, 0, 1, -1, 0}, {0, 1, -1, 0, 1, 0, 1}};
vector<int> pos[5] = {{1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3, 4}, {0, 1, 2, 3}, {1, 2, 3}};
int c[128];
using board = array<array<int, 5>, 5>;

board filter(board a){
    board b;
    rep(i, 5)rep(j, 5) b[i][j] = 0;
    for(int i=1; i<=3; ++i){
        For(j, 1, pos[i].size()-1){
            int S = 0, x = i, y = pos[i][j];
            rep(k, 7){
                int nx = x + dx[i%2][k], ny = y + dy[i%2][k];
                S |= (a[nx][ny] << k);
            }
            b[x][y] = c[S];
        }
    }
    return b;
}

void solve(){
    rep(S, 1<<19){
        board a;
        rep(i, 5)rep(j, 5) a[i][j] = 0;
        int cur = 0;
        rep(i, 5)for(int j: pos[i]){
            a[i][j] = (S>>cur & 1);
            ++cur;
        }
        board b = filter(a), b2 = filter(b);
        if(b[2][2] != b2[2][2]){
            puts("no");
            return;
        }
    }
    puts("yes");
}

int main(){
    string s;
    while(cin >> s && s != "#"){
        rep(i, 128) c[i] = s[i] - '0';
        solve();
    }
}


Measured memory_bytes: 2992
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    K = int(readline())

    vec = list(range(1, 10))
    for i in range(K):
        tail = vec[i] % 10
        n10 = vec[i] * 10
        if tail == 0:
            vec.append(n10 + tail)
            vec.append(n10 + tail + 1)
        elif tail == 9:
            vec.append(n10 + tail - 1)
            vec.append(n10 + tail)
        else:
            vec.append(n10 + tail - 1)
            vec.append(n10 + tail)
            vec.append(n10 + tail + 1)

    print(vec[K - 1])
    return


if __name__ == '__main__':
    main()


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

int main(){
 	string n;
  	cin  >> n;
  	if(n[0] == n[1] && n[1] == n[2] || n[2] == n[3] && n[1] == n[2]) 
      cout << "Yes\n";
    else
      cout <<"No\n";
}

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

int main(){
  int n; cin>>n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) cin >> d[i];
  sort(d.begin(),d.end());
  int ans;
  if(n%2==1) cout << "0" << endl;
  else{
    int a = n/2;
    ans = d[a] -d[a-1];
    cout << ans << endl;
  } 
}

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

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

	int x[3] = { -1, -1, -1 };
	for (int i = 0; i < m; ++i) {
		int s, c;
		std::cin >> s >> c;
		--s;

		if (x[s] != -1 && x[s] != c) {
			std::cout << -1 << std::endl;
			return 0;
		}

		x[s] = c;
	}

	if (n == 1) {
		std::cout << std::max(x[0], 0) << std::endl;
		return 0;
	}

	if (x[0] == 0) {
		std::cout << -1 << std::endl;
		return 0;
	}
	std::cout << std::max(x[0], 1);

	for (int i = 1; i < n; ++i)
		std::cout << std::max(x[i], 0);

	std::cout << std::endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input=lambda :sys.stdin.readline().rstrip()
# inputs= sys.stdin.buffer.readlines
INF=float("inf")
MOD=10**9+7
#input = sys.stdin.buffer.readline
#sys.setrecursionlimit(2147483647)
#rstrip().decode('utf-8')
#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#map(int,input().split())

# Z-algorithm (O(N))
# https://deve68.hatenadiary.org/entry/20120201/1328109890
def Z(s):
    n=len(s)
    z=[0]*n
    z[0]=n
    L,R=0,0
    for i in range(1,n):
        if(i>=R): # 過去の結果が全く使えない
            L=R=i
            while(R<n and s[R-L]==s[R]): R+=1
            z[i]=R-L
        elif(z[i-L]<R-i): # 過去の結果が全て使える
            z[i]=z[i-L]
        else: # 過去の結果が一部使える
            L=i
            while(R<n and s[R-L]==s[R]): R+=1
            z[i]=R-L
    return z

# example
#print(Z("abaaabaabb")) # [10,0,1,1,4,0,1,2,0,0]


def main():
	n=int(input())
	s=input()
	ans=0
	for i in range(n-1):
		z=Z(s[i:])
		k=len(z)
		for j in range(k):
			ans=max(ans,min(j,z[j]))
	print(ans)
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 48092
n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

p1, p2 = n, 0
f = [0]
s = [0]
for i in range(n):
    f.append(f[i]+arr1[i])
for i in range(m):
    s.append(s[i]+arr2[i])
highest = 0
while p1 >= 0:
    while p2 < m+1 and f[p1] + s[p2] <= k:
        highest = max(highest, p1+p2)
        p2 += 1
    p1 -= 1
    if p2 > 0:
        p2 -= 1
print(highest)


Measured memory_bytes: 127040
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a != b || b != c)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

using ll = long long int;

int main(){
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    bool ans = true;
    ll len = abs(a-b);

    if (w >= v)ans = false;
    else {
        if (len > t * (v-w))ans = false;
    }
    if (ans)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3092
from collections import Counter
from functools import reduce
import bisect
import copy
import fractions
import math
# import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


def update(i, x, seg):
    i = len(a) + i - 1
    seg[i] = x
    while i > 0:
        i = math.floor((i-1) / 2)  # 上のノード
        # seg[i] = min(seg[2*i + 1], seg[2*i + 2])
        seg[i] = fractions.gcd(seg[2*i + 1], seg[2*i + 2])
    # 数列の1要素を変更可能＞消去で良い＞1要素を0に置換しても良い
    # 1要素を0にした時のリスト全体の最大公約数を今回は返す
    return seg[0]


n, a = II(), LI()
# 最大公約数を求める。gcd(0, x) = 0なので各要素を0で初期化する
segtree = [0] * (2*n -1)
maxi = 0

# node n, parent floor((n-1)/2), chile 2*n + 1 2*n + 2
for i in range(n):
    update(i, a[i], segtree)

for i in range(n):
    maxi = max(maxi, update(i, 0, segtree))
    # 元に戻す...???
    update(i, a[i], segtree)

print(maxi)


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

using namespace std;
typedef long long ll;
bool cmp(int a,int b){ 
    return a>b;
}
const int maxn=2e5+5;
int a[maxn];
int main()
{
   int n;
   cin>>n;
   for(int i=1;i<=n;++i)
      scanf("%d",&a[i]);
   ll ans=0;
   sort(a+1,a+1+n,cmp);
   ans+=a[1];
   for(int i=3;i<=n;++i)
      ans+=a[(i+1)/2];
   printf("%lld\n",ans); 
   return 0; 
}


Measured memory_bytes: 4516
suits = ["S", "H", "C", "D"]
table = [[False]*14 for i in range(4)]

N = int(input())
for loop in range(N):
  mark, num = input().split()
  num = int(num)
  
  if mark == "S":
    table[0][num] = True
  elif mark == "H":
    table[1][num] = True
  elif mark == "C":
    table[2][num] = True
  else:
    table[3][num] = True
    
for i in range(4):
  for j in range(1,14):
    if table[i][j] == False:
      print("%s %d"%(suits[i],j))


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


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

    for (;;) {
        int n, m; cin >> n >> m;
        if (n == 0) break;
        vi ma(m);
        REP(i, n) {
            int d, v; cin >> d >> v;
            chmax(ma[d-1], v);
        }
        cout << accumulate(ALL(ma), 0) << endl;
    }

    return 0;
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    if(m>=n)
    cout<<"Yes";
    else
    cout<<"No";
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int d[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << d[K-1] << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cstdlib>
using namespace std;
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 long long INF = 1LL << 60;
    long long dp[100010];
    long long h[100010];

int main(){
    int N , K;
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> h[i];
    for(int i = 0; i < 100010; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        for(int j = 1; j <= K; ++j) chmin(dp[i+j], dp[i] + abs(h[i+j]-h[i]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int k = 0;
	for(int i=0; i<s.size(); i++){
		k += s[i]-'0';
	}
	if(k%9==0){
		cout << "Yes";
	}else{
		cout << "No";
	}
}

Measured memory_bytes: 3736
#include <iostream>
using namespace std;
int main(void){
  int S,h,m,s;
    cin >> S;
    h=S/3600;
    cout << h;
    cout <<":";
    cin >> m;
    m=(S%3600)/60;
    cout << m;
    cout <<":";
    cin >>s;
    s=S-h*3600-m*60;
    cout << s;
    cout << endl;
     
}


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

namespace A {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            var s = new string[N];
            var t = new int[N];

            

            for (int i = 0; i < N; i++) {
                string[] st = Console.ReadLine().Split(' ').ToArray();

                //Console.WriteLine(st);

                //Console.WriteLine(st[0]);
                //Console.WriteLine(st[1]);

                s[i] = st[0];
                t[i] = int.Parse(st[1]);
            }

            string X = Console.ReadLine();

            int ans = 0;
            bool start = false;

            for (int i = 0; i < N; i++) {
                

                if (start) {
                    ans += t[i];
                }

                if (s[i] == X) {
                    start = true;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> d(110);
  rep(i, n) {
    int num;
    cin >> num;
    d.at(i) = num;
  }
  vector<int> num(110, 0);
  rep(i, n) {
    num.at(d.at(i))++;
  }
  int ans = 0;
  rep(i, 101) {
    if (num.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
import Data.List

main :: IO ()
main = do
  getLine
  ds <- map read . words <$> getLine
  print $ solve ds

-- |
-- >>> solve [9, 1, 4, 4, 6, 7]
-- 2
-- >>> solve [9, 1, 14, 5, 5, 4, 4, 14]
-- 0
-- >>> solve [99592, 10342,29105, 78532, 83018, 11639, 92015, 77204, 30914, 21912, 34519, 80835, 100000, 1]
-- 42685
solve :: [Int] -> Int
solve ds = head $ dropWhile (< 0) $ zipWith (-) sds rds
  where
    sds = sort ds
    rds = reverse sds



Measured memory_bytes: 29052
N,M = map(int,input().split())
H = list(map(int,input().split()))
P = [1]*N

for _ in range(M):
    A,B = map(int,input().split())
    Ah = H[A-1]
    Bh = H[B-1]
    if Ah >= Bh:
        P[B-1] = 0
    if Bh >= Ah:
        P[A-1] = 0
        
print(sum(P))

Measured memory_bytes: 19940
#include <iostream>
using namespace std;
int main(void){
    int i, j, H, W;
    
    while(cin >> H >> W){
        if(H == 0 && W == 0)    break;
        for(i = 0; i < H; i++){
            for (j = 0; j < W; j++){
                if((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) {
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

m = list(sorted(A))
if m[-1] == m[-2]:
    for _ in range(N):
        print(m[-1])
else:
    for _ in A:
        if _ == m[-1]:
            print(m[-2])
        else:
            print(m[-1])

Measured memory_bytes: 14160
import itertools
import numpy as np

n, k = map(int, input().split())
l = range(n+1)
T = [0]*(n+1)
T[0] = 0
for i in range(n):
     T[i+1] = T[i] + (i+1)

count = 0
for i in list(range(k,n+1)):
    count = count + (T[n]-T[n-i]) - T[i-1] + 1
count = count + 1
print(count%(10**9+7))

Measured memory_bytes: 44936
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    double sx[n], sy[n], sz[n];
    for (int i = 0; i < n; i++) {
      cin >> sx[i] >> sy[i] >> sz[i];
    }
    int m;
    cin >> m;
    double tx[m], ty[m], tz[m], phi[m];
    for (int i = 0; i < m; i++) {
      cin >> tx[i] >> ty[i] >> tz[i] >> phi[i];
    }
    bool observable[n];
    memset(observable, false, sizeof(observable));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        double l1, l2, r;
        l1 = sqrt(tx[j]*tx[j]+ty[j]*ty[j]+tz[j]*tz[j]);
        l2 = sqrt(sx[i]*sx[i]+sy[i]*sy[i]+sz[i]*sz[i]);
        double tv1, tv2, tv3;
        tv1 = tx[j]-sx[i]; tv2 = ty[j]-sy[i]; tv3 = tz[j]-sz[i];
        r = sqrt(tv1*tv1+tv2*tv2+tv3*tv3);
        double val = (l1*l1+l2*l2-r*r)/(2*l1*l2);
        if (acos(val) < phi[j]) {
          observable[i] = true;
          // cout << i << " " << j << " " << acos(val) << " " << phi[j] << " " << val << endl;
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += observable[i];
    cout << ans << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    int wa = 0;
    vector<int>W(N);
    for(int i = 0; i < N; i++) {
        cin >> W[i];
        wa += W[i];
    }
    int ans = 10000000;
    for(int i = 0; i < N; i++) {
        int wawa = 0;
        for(int j = 0; j < i; j++) {
            wawa += W[j];
        }
        ans = min(ans,abs((wa-wawa)-wawa));
    }
    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//loop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int x;
  cin >> x;

  //process
  
  
  //output
  if (x == 1)
  	cout << "0" << endl;
  else
  	cout << "1" << endl;
}

Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var h, w, ans int
	fmt.Scan(&h, &w)

	if h == 1 || w == 1 {
		ans = 1
	} else {
		if h%2 == 0 || w%2 == 0 {
			ans = (h * w) / 2
		} else {
			ans = 1 + ((h * w) / 2)
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
n, x = map(int, input().split())
num_lists = list(map(int, input().split()))

num_lists.sort()
cnt = 0
sum = 0
for i in range(len(num_lists)):
    sum += num_lists[i]
    if sum <= x:
        cnt = i+1
    else:
        x = 0
        cnt = i
        break
x -= sum

if 0 < x:
    cnt -= 1

print(cnt)

Measured memory_bytes: 9148
N, D = map(int, input().split())


def is_less_or_equal_d(x, y):
    return D**2 >= x**2 + y**2


ans = 0
for _ in range(N):
    x, y = map(int, input().split())
    ans += is_less_or_equal_d(x, y)
print(ans)


Measured memory_bytes: 9164
#include<stdio.h>
int main()
{
   int sum=0;
   char ch;
   while(true)
   {
       while((ch=getchar())!='\n')
       {
           sum+=ch-'0';
       }
       if(sum==0)
        break;
       else
       {
           printf("%d\n",sum);
           sum=0;
       }
   }
}



Measured memory_bytes: 2680
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int day = sc.nextInt();

        StringBuilder sb = new StringBuilder("Christmas");

        for (int i = 0; i < 25 - day; i++) {
            sb.append(" Eve");
        }

        System.out.println(sb.toString());
    }
}

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define pi 3.1415926536
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int a[100005];
priority_queue<int> pq;
map<int, int> taken;
int main()
{
    int n;
    cin >> n;
    int mini = mod;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        mini = min(a[i], mini);
    }
    bool found = true;
    while (found)
    {
        found = false;
        for (int i = 0; i < n; ++i)
        {
            int x = a[i] % mini;
            if (x > 0 and x < mini)
            {
                mini = x;
                found = true;
                break;
            }
        }
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll = long long;


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

	if (r < 1200)
		cout << "ABC\n";
	else if (r >= 1200 and r < 2800)
		cout << "ARC\n";
	else
		cout << "AGC\n";
	
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, t;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> s >> t;
  rep(i, n) { cout << s[i] << t[i]; }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256