akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
using i64 = long long;

int main() {
    int n, m, x;
    std::cin >> n >> m >> x;
    std::vector<int> p(n);
    std::vector v(n, std::vector<int>(m));
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        for (auto &e : v[i]) std::cin >> e;
    }

    constexpr int inf = std::numeric_limits<int>::max();
    int ret = inf;
    std::vector<int> w(m);
    for (int i = 0; i < (1 << n); i++) {
        int s = 0;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                s += p[j];
                for (int k = 0; k < m; k++) w[k] += v[j][k];
            }
        }

        if (std::all_of(w.begin(), w.end(), [x](const int a) { return a >= x; })) {
            if (ret > s) ret = s;
        }

        std::fill(w.begin(), w.end(), 0);
    }

    std::cout << (ret == inf ? -1 : ret) << std::endl;

    return 0;
}


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

using namespace std;

#define int int64_t

bool check(string t)
{
    return t.empty() || *min_element(begin(t), end(t)) == *max_element(begin(t), end(t));
}

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = s.size();
    for(int c = 'a'; c <= 'z'; c++)
    {
        string t = s;
        int step = 0;
        while(!check(t))
        {
            for(int i = 0; i + 1 < t.size(); i++)
                if(t[i + 1] == c)
                    t[i] = c;
            t.pop_back();
            step++;
        }
        ans = min(ans, step);
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


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


Measured memory_bytes: 3536
#include <cstdio>
#include <cstring>

using namespace std;

#define rep1(i,x) for(int i=1;i<=(x);++i)

int a[100001];
int memo[100001];
int start[100001];

int main()
{
    int n, k;
    while (scanf("%d %d", &n, &k), n || k) {
        memset(a, 0, sizeof(a));
        memset(memo, 0, sizeof(memo));
        memset(start, 0, sizeof(start));

        bool f = false;

        rep1(i, k) {
            int tmp; scanf("%d", &tmp);
            if (tmp == 0) f = true;
            else a[tmp] = true;
        }

        rep1(i, n) {
            if (a[i]) {
                if (i - 1 >= 0 && a[i - 1]) {
                    start[i] = start[i - 1];
                    memo[start[i]]++;
                } else {
                    start[i] = i;
                    memo[start[i]]++;
                }
            }
        }

        int ma = 0;
        int now = -1;

        rep1(i, n) {
            if (a[i]) {
                if (now == start[i]) continue;
                if (ma < memo[start[i]]) {
                    ma = memo[start[i]];
                    now = start[i];
                }
            } else if (f) {
                int v;
                if (i + 1 <= n && a[i - 1] && a[i + 1]) {
                    v = memo[start[i - 1]] + memo[start[i + 1]] + 1;
                    if (ma < v) {
                        ma = v;
                        now = start[i + 1];
                    }
                } else if (a[i - 1]) {
                    v = memo[start[i - 1]] + 1;
                    if (ma < v) {
                        ma = v;
                        now = start[i - 1];
                    }
                } else if (i + 1 <= n && a[i + 1]) {
                    v = memo[start[i + 1]] + 1;
                    if (ma < v) {
                        ma = v;
                        now = start[i + 1];
                    }
                }
            }
        }

        printf("%d\n", ma);
    }
}

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

int main() {
  int x;cin>>x;
  int k;
  if (x<600) k=8;
  else if (x<800) k=7;
  else if (x<1000) k=6;
  else if (x<1200) k=5;
  else if (x<1400) k=4;
  else if (x<1600) k=3;
  else if (x<1800) k=2;
  else if (x<2000) k=1;
  cout<<k;
}


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

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string str;
    cin >> str;
    int res = 0;
    int cur = 0;
    for (int i = 0; i < 3; i++) {
        if (str[i] == 'R') {
            cur++;
        } else {
            res = max(res, cur);
            cur = 0;
        }
    }
    res = max(res, cur);
    cout << res << '\n';
}
/*

 */

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    char n[10];
    cin >> n;

    int ok = 0;
    for( int i = 0; i < 3; i++ )
        if( n[i] == '7' )
            ok = 1;

    if( ok )cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

int main()
{
  int x, y, z, k;
  cin >> x >> y >> z >> k;

  vector<int64_t> A(x), B(y), C(z);
  for (auto&& e : A) cin >> e;
  for (auto&& e : B) cin >> e;
  for (auto&& e : C) cin >> e;
  sort(begin(A), end(A), [](auto a, auto b){return a > b;});
  sort(begin(B), end(B), [](auto a, auto b){return a > b;});
  sort(begin(C), end(C), [](auto a, auto b){return a > b;});

  vector<int64_t> ABC;
  for (int a = 0; a < x; a++) {
    for (int b = 0; b < y; b++) {
      if ((a + 1) * (b + 1) > k) break;
      for (int c = 0; c < z; c++) {
        if ((a + 1) * (b + 1) * (c + 1) > k) break;
        ABC.push_back(A[a] + B[b] + C[c]);
      }
    }
  }
  sort(begin(ABC), end(ABC), [](auto a, auto b){return a > b;});

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


Measured memory_bytes: 1404
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n, y;
  cin >> n >> y;
  int k;
  for(int i = 0; i <= y/10000; i ++){  
    for(int j = 0; j <= n; j ++){
      k = n - i - j;
      if(k>=0&&(10000*i + 5000*j + 1000*k == y)){
	cout << i << " " << j << " " << k << endl;
	return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


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

using namespace std ;

int block[100005] ; 
int user[100005] ; 
int size[100005] ; 


int find(int x ) {
	
	return user[x] == x ? x : user[x] = find(user[x]);
	
}

int main () { 
	
	int t  ; 
	int n , k , m ; 
	cin >> n >> k >> m ;
	for (int i = 1 ; i <= n ; i ++ ) {
		user[i] = i ; 
		size[i] = 1 ;
	}
	int a , b ; 
	int rootA , rootB ; 
	for ( int i =  1 ; i <= k ; i ++ )  {
		cin >> a >> b;
		
		rootA = find(a) ; 
		rootB = find(b) ; 
		block[a]++ ; 
		block[b]++ ;  
		if ( rootA != rootB ) {
			user[rootA] = user[b] ; 
			size[rootB] += size[rootA] ;
		
		}
		
		
	}
	for (int i = 1 ; i <= m  ; i ++ )  {
		cin >> a >> b ;
		rootA = find(a) ; 
		rootB = find(b) ; 
		if ( rootA == rootB ) {
			block[a]++ ; 
			block[b]++ ; 
		}
	}
	for ( int i = 1 ; i <= n ; i ++ ) {
		cout << size[find(i)] -1 - block[i] << " " ;
	}
	cout << endl ; 
	
}


Measured memory_bytes: 2560
N = int(input())
H = list(map(int, input().split()))

res = []
cnt = 0
for i in range(N-1):
    if H[i+1] <= H[i]:
        cnt += 1
        if i == N - 2:
            res.append(cnt)
    else:
        res.append(cnt)
        cnt = 0
if res == []:
    print(0)
else:
    print(max(res))

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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    vector<int> v(n),a(n);
    for(i = 0;i < n;i++) cin >> v[i];
    for(i = n-1;i >= 0;i--){
        for(j = i;j >= 0;j--){
            if(v[j] == j+1){
                break;
            }
        }
        if(j == -1){
            cout << -1 << endl;
            return;
        }
        a[i] = v[j];
        for(;j < i;j++){
            v[j] = v[j+1];
        }
    }
    for(i = 0;i < n;i++) cout << a[i] << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  ll f=0;
  if(s[0]=='0'||s[n-1]=='1') f=1;
  for(ll i=0;i<n/2;i++) {
    if(s[i]!=s[n-i-2]) f=1;
  }
  if(f) {
    cout << -1 << endl;
    return 0;
  }
  vec a(n-1),b(n-1);
  ll id=0;
  for(ll i=0;i<n-1;i++) {
    a[i]=i+1;
    if(s[i]=='1') {
      while(id<i) {
        b[id]=i+1;
        id++;
      }
    }
  }
  while(id<n-1) {
    b[id++]=n;
  }
  for(ll i=0;i<n-1;i++) {
    cout << a[i] << " " << b[i] << endl;
  }
}

Measured memory_bytes: 3200
N=int(input())
S=list(map(int,input().split()))
shingi=True
total=0
while shingi==True:
    count=0
    for i in S:
        if i%2==0:
            count+=1
        else:
            shingi=False
    if count==len(S):
        total+=1
    S=list(map(lambda x:x/2,S))
print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long a;
  cin >> a;
  int ans = 0;
  long long p = 100;
  for(int i = 0; ; i++){
    p += p / 100;
    if (p >= a) { ans = i + 1; break; }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
x, n = map(int, input(). split())
p = list(map(int, input(). split()))
if x not in p:
  print(x)
else:
  d = 1
  while True:
    if x-d not in p:
      print(x-d)
      break
    if x+d not in p:
      print(x+d)
      break
    d += 1

Measured memory_bytes: 61888
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner stdId = new Scanner(System.in);
        int a = stdId.nextInt();
        int b = stdId.nextInt();
        int c = stdId.nextInt();
        int tmp = 0;

        String j = "No";

        if (a > b) {
            tmp = a;
            a = b;
            b = tmp;
        }
        if (a > c) {
            tmp = a;
            a = c;
            c = tmp;
        }
        if (b > c) {
            tmp = b;
            b = c;
            c = tmp;
        }

        System.out.println(a + " " + b + " " + c);

    }
}

Measured memory_bytes: 26224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  int a,b,q; cin >> a >> b >> q;
  vector<ll> s(a), t(b), x(q);
  rep(i,a) cin >> s[i];
  rep(i,b) cin >> t[i];
  rep(i,q) cin >> x[i];

  rep(i,q) {
    ll xi = x[i];
    auto slb = lower_bound(ALL(s), xi);
    auto tlb = lower_bound(ALL(t), xi);

    ll sl, sr, tl, tr;
    if(slb == s.end()) sl = sr = *s.rbegin();
    else if (*slb == xi) sl = sr = xi;
    else if (slb == s.begin()) sl = sr = *slb;
    else sl = *prev(slb), sr = *slb;

    if(tlb == t.end()) tl = tr = *t.rbegin();
    else if (*tlb == xi) tl = tr = xi;
    else if (tlb == t.begin()) tl = tr = *tlb;
    else tl = *prev(tlb), tr = *tlb;

    ll ans = 100000000000;

    vector<pair<ll,ll>> pp(4);
    pp[0]= {sl, tl};
    pp[1]= {sl, tr};
    pp[2]= {sr, tl};
    pp[3]= {sr, tr};
    for(auto [l,r] : pp) {
      if (l > r) swap(l,r);
      if ( l <= xi && xi <= r) umin(ans, min(xi-l + r-l, r-xi + r-l));
      else if ( xi <= l ) umin(ans, r - xi);
      else /* ( r <= x ) */ umin(ans, xi - l); 
    }
    cout << ans << endl;
  }


}


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n, k;
  cin >> n >> k;
  vector<double> p(n);
  rep(i,n){
    double x; cin >> x;
    p[i] = double((x + 1) / 2);
  }
  vector<double> sum(n+1,0);
  rep(i, n) sum[i + 1] = sum[i] + p[i];
  //show(sum);
  double ans = -1.0;
  for (int i = 0; i < n - k + 1; i++) {
    chmax(ans, sum[i + k] - sum[i]);
  }
  printf("%.9f", ans);
  return 0;
}

Measured memory_bytes: 6424
#include<stdio.h>

int main(){
    int i,j,answer;

    for(i=1;i<=9;i++)
    {
         for(j=1;j<=9;j++)
         {
             answer = i * j;
             printf("%dx%d=%d\n",i,j,answer);
         }
    }

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int x;
    cin >> x;
    int ans = 1;
    rep(i, sqrt(x) + 1) {
        rep(j, sqrt(x) + 1) {
            if(pow(i, j) > ans && pow(i, j) <= x) {
                ans = pow(i, j);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000


// Graph

int dp[110000];
int visited[110000];


class Graph {
    protected:
        vector< vector<int> > G;
        void dfs(int from, int visited[], void (*func)(int));
    public:
        int count;
        Graph (int);
        void add(int, int);
        void dfs(void (*func)(int));
        void print();
        int ans(int);
};

Graph::Graph(int n) {
    count = n;

    vector<int> g;
    for (int i = 0; i < n; i++) {
        G.push_back(g);
    }
}

void Graph::add(int from, int to) {
    G[from].push_back(to);
    G[to].push_back(from);
}

int Graph::ans(int v) {
    visited[v] = 1;
    if (G[v].empty()) {
        dp[v] = 0;
        return dp[v];
    } else if (dp[v] >= 0) {
        return dp[v];
    }
    int m = 0;
    for (int i = 0; i < G[v].size(); i++) {
        m = max(m, ans(G[v][i]) + 1);
    }
    dp[v] = m;
    return m;
}

void Graph::dfs(int from, int visited[], void (*func)(int)) {
    if (visited[from]) {
        return;
    }
    stack<int> s;
    visited[from] = 1;
    s.push(from);
    while (!s.empty()) {
        int v = s.top(); s.pop();
        (*func)(v);
        for (int i = 0; i < G[v].size(); i++) {
            if (!visited[G[v][i]]) {
                visited[G[v][i]] = 1;
                s.push(G[v][i]);
            }
        }
    }
}

void Graph::dfs(void (*func)(int)) {
    int visited[count];
    for (int i = 0; i < count; i++) {
        visited[i] = 0;
    }
    for (int i = 0; i < count; i++) {
        dfs(i, visited, func);
    }
}

void Graph::print() {
    for (int i = 0; i < G.size(); i++) {
        cout << i << ": ";
        for (int j = 0; j < G[i].size(); j++) {
            cout << G[i][j] << " ";
        }
        cout << endl;
    }
}

class DGraph: public Graph {
    public:
        DGraph (int n): Graph(n) {};
        void add(int, int);
};

void DGraph::add(int from, int to) {
    G[from].push_back(to);
}


int n, m;
int x, y;

int main() {
    cin >> n >> m;
    for (int i = 0; i < 110000; i++) {
        dp[i] = -1;
    }
    DGraph g(n + 1);
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        g.add(x, y);
    }

    for (int i = 1; i <= n; i++) {
        g.ans(i);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8560
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
	int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      cout<<"OK\n";
      return;
    }
  }
  cout<<"NG\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 3800
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

unordered_map<int, int> m;

signed main() {
  int n = in();
  rep(i, n) {
    int a = in();
    m[a]++;
  }

  vi v;
  int sum = 0;
  each(t, m) {
    if (t.se > 1) {
      v.pb(t.se - 1);
      sum += t.se - 1;
    }
  }
  print(m.size() - sum % 2);
}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define N 3000
double a[N+5];
int main() {
  	int n;
  	cin>>n;
  	for(int i=0;i<n;i++) {cin>>a[i];}
  	double dp[n+1][n+1],s=0.0;
  	cout<<fixed<<setprecision(10);
  	memset(dp,0.0,sizeof(dp));
  	dp[0][0]=1.0;
  	for(int i=1;i<=n;i++) {
    	for(int j=0;j<=i;j++) {
        	dp[i][j]=a[i-1]*dp[i-1][j-1]+(1.0-a[i-1])*dp[i-1][j];
        }
    }
  	for(int i=(n+1)/2;i<=n;i++) {s+=dp[n][i];}
  	cout<<s<<endl;
return 0;
}


Measured memory_bytes: 74108
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	int a, b;
	cin >> a >> b;
	if ((a + b) % 3 == 0)
		cout << "Possible";
	else if(a % 3==0)
		cout << "Possible";
	else if (b % 3 == 0)
		cout << "Possible";
	else
		cout << "Impossible";
}

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

string s;

int main(void) {
  // Here your code !
  cin >> s;

  int num_c = 0;
  int pos_c;

  for (int i = 2; i <= s.size() - 2; ++i) {
    if (s[i] == 'C') {
      num_c += 1;
      pos_c = i;
    }
  }


  if (s[0] == 'A' && num_c == 1) {
    bool all_lower = true;
    for (int i = 0; i < s.size(); ++i) {
      if (i == pos_c || i == 0) continue;
      all_lower &= ((int)('a') <= (int)(s[i]) && (int)(s[i]) <= (int)('z'));
    }
    if (all_lower) {
      printf("AC\n");
      return 0;
    }
  }

  printf("WA\n");
  return 0;
}


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

int main() {
    int N, X, Y; cin >> N >> X >> Y;
    X--; Y--;
    vector<int> ans(N+1, 0);
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            int dist = min(j-i, abs(X-i) + abs(Y-j) + 1);
            ans[dist]++;
        }
    }
    for (int i = 1; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, M, K; cin >> N >> M >> K;
    if (K == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    string CAN = "No";
    if (K % N == 0 || K % M == 0) CAN = "Yes";
    else {
        rep(i, N+1) {
            rep(j, M+1) {
                if (M * i + N * j - 2 * j * i == K) {
                    CAN = "Yes";
                    goto QUIT;
                }
            }
        }
    }
QUIT:
    cout << CAN << endl;
}


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

int main(){
  int n,m;cin >> n >> m;
  vector<int> x;
  bool f=false;
  for(int i=0;i<m;i++){
    int a,b;cin >> a >>b;
    if(a==1){
      x.push_back(b);
    }
    if(b==n){
      x.push_back(a);
    }
  }
  int l1=x.size();
  set<int> y(x.begin(),x.end());
  if(l1==y.size()){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << "POSSIBLE" << endl;
  }

}


Measured memory_bytes: 10356
alph = ['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']
word = list(input())

achars = alph[:]
for char in word:
    achars.remove(char)

if len(word) < 26:
    print(''.join(word)+achars[0])
else:
    ind = 26
    for i in range(1,26):
        if alph.index(word[i]) > alph.index(word[i-1]):
            ind = i
    if ind == 26:
        print(-1)
    else:
        word = word[:ind]
        for char in alph:
            if alph.index(char) > alph.index(word[ind-1]) and char not in word:
                word[ind-1] = char
                break
        print(''.join(word))

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int n;
int a[110000];
int f[110000];

int LIS(int n)
{
    int res = 0;
    int max1 = 0;
    for(int i = 1; i < n; ++i)
    {
        if(a[i] <= a[i - 1]) {
        	res++;
			max1 = max(max1,res);
		}else{
			
			res = 0;
		}
    }
    return max1;
}


int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%d",&a[i]);
	int ans = LIS(n);
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest 115：B - Christmas Eve Eve


def main():
    N = int(raw_input().strip())
    P = []
    for _ in range(N):
        p = int(raw_input().strip())
        P.append(p)

    P.sort()
    P[-1] = P[-1]/2
    print sum(P)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    double R;
    double L;
    cin >> R;
    L = M_PI * R * 2;
    cout << L;
    return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),k=nxtl(),x=nxtl(),y=nxtl();
    if(n<=k)
        cout<<x*n<<endl;
    else 
    {
        cout<<x*k+(n-k)*y<<endl;
    }

    
    return 0;   
}


 
 


Measured memory_bytes: 256
import math
a,b,h,m=map(int,input().split())

m_angle = 360 * (m/60)
h_angle = 360 * (h/12) + 30 * (m/60)

angle_dif = abs(m_angle-h_angle)

ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(angle_dif)))**(1/2)

print(ans)


Measured memory_bytes: 9500
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll lo=(n-1)*a+b, hi=(n-1)*b+a;
    cout << max(0ll, (hi-lo+1)) << '\n';
}


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


c = 0
num = 0
def check(n):
	strn = str(n)
	l = [0, 0, 0]
	for c in strn:
		if c == '3':
			l[0] = 1
		elif c == '5':
			l[1] = 1
		elif c == '7':
			l[2] = 1
	return all(l) or False

def gen(n):
	global c
	# print(n)
	if n > num:
		return
	if check(n):
		# print(n)
		c += 1
	for i in [3, 5, 7]:
		k = 10 * n + i
		gen(k)

def main():
	global num
	num = int(input().strip())
	gen(0)
	print(c)

if __name__ == '__main__':
	main()


Measured memory_bytes: 57052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;


int main() {
  ll N,a,b;
  cin>>N>>a>>b;
  if(a==b){
    cout<<1;
  }
  else if(N==1||a>b){
    cout<<0;
  }
  else{
    cout<<(N-2)*(b-a)+1;
  }
      
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n, m; cin >> n >> m;
    ll a[51]; INITA(a, 0, 50, 0);
    ll b[51]; INITA(b, 0, 50, 0);
    ll c[51]; INITA(c, 0, 50, 0);
    ll d[51]; INITA(d, 0, 50, 0);
    REP(i, n) { cin >> a[i] >> b[i]; }
    REP(i, m) { cin >> c[i] >> d[i]; }
    REP(i, n) {
        ll min_diff = 10e14;
        int min_idx = 0;
        REP(j, m) {
            ll diff = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (diff < min_diff) {
                min_diff = diff;
                min_idx = j;
            }
        }
        cout << min_idx + 1 << endl;
    }
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    vector<int> k_vec(q);
    rep (i, q)
        cin >> k_vec[i];

    repall (k, k_vec) {
        ll d = 0, m = 0, dm = 0;
        ll ans = 0;
        rep (i, s.length()) {
            d += (s[i] == 'D');
            m += (s[i] == 'M');
            dm += (s[i] == 'M' ? d : 0);
            if (i >= k) {
                d -= (s[i - k] == 'D');
                m -= (s[i - k] == 'M');
                dm -= (s[i - k] == 'D' ? m : 0);
            }
            if (s[i] == 'C') ans += dm;
        }
        print(ans);
    }

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 1948
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)


def main():
    MOD = 998244353
    N, K = map(int, input().split())
    L = [0] * K
    R = [0] * K
    for i in range(K):
        L[i], R[i] = map(int, input().split())

    dp = [0] * (N + 1)
    dpsum = [0] * (N + 1)
    dp[1] = 1
    dpsum[1] = 1
    for i in range(2, N + 1):
        for j in range(K):
            li = i - R[j]
            li = max(li, 1)
            ri = i - L[j]
            if ri < 0:
                continue
            dp[i] += (dpsum[ri] - dpsum[li - 1]) % MOD
        dpsum[i] += (dpsum[i - 1] + dp[i]) % MOD
    print(dp[N] % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81816
//16
#include<iostream>
#include<algorithm>
#include<utility>

using namespace std;

typedef pair<char,int[3]> pci;

bool cmp(pci a,pci b){
  return a.second[0]>b.second[0]||(a.second[0]==b.second[0]&&a.second[1]<b.second[1]);
}				   

int main(){
  for(int n;cin>>n,n;){
    pci t[10];
    for(int i=0;i<n;i++){
      cin>>t[i].first;
      for(int j=0;j<n-1;j++){
	int r;
	cin>>r;
	t[i].second[r]++;
      }
    }
    stable_sort(t,t+n,cmp);
    for(int i=0;i<n;i++){
      cout<<t[i].first<<endl;
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    int sum = 0;
    vector<int> A(n);
    rep(i,n){
        cin >> A[i];
        sum += A[i];
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    if(4 * m * A[m - 1] < sum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

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

long long abs_diff(long long a, long long b){
    return MAX(a-b, b-a);
}

void solve(void){
    int n;
    scanf("%d\n", &n);
    long long sums[n], sum;
    rep(n, i) {
        long long a;
        scanf("%lld", &a);
        sums[i] = a;
    }
    rep(n-1, i) sums[i+1] += sums[i];
    sum = sums[n-1];

    if (n == 2) printf("%lld\n", abs_diff(sums[0], sums[1]-sums[0]));
    else {
        long long min = INF;
        rep(n-1, i) if (min > abs_diff(sums[i], sum-sums[i])) min = abs_diff(sums[i], sum-sums[i]);
        printf("%lld\n", min);
    }
}

int main(void){
  solve();
  return 0;
}


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

int a[100005];
int n;

long long calc(int MOD) {
	long long sum = 0, res = 0;
	for (int i = 1; i <= n; ++i)  {
		sum += a[i];
		if (i%2 == MOD && sum <= 0) {
			res += (1-sum);
			sum = 1;
		}
		else if (i%2 != MOD && sum >= 0) {
			res += (sum+1);
			sum = -1;
		}
	}
	return res;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) 
		scanf("%d", &a[i]);
	cout << min(calc(0), calc(1));
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = parseInt(sc.next());
		int[] a = new int[n+1];
		for(i=1;i<=n;i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		int[] b = new int[n+1];
		for(i=n/2+1;i<=n;i++) {
			b[i] = a[i];
		}
		int sum=0;
		for(i=n/2;i>0;i--) {
			sum = 0;
			for (j = 2*i; j <= n; j+=i) {
				sum += b[j];
			}
			if((sum & 1) == a[i]) {
				b[i] = 0;
 			} else {
				b[i] = 1;
 			}
		}
		int cnt = 0;
		StringBuilder sb = new StringBuilder();
		for (i = 1; i <= n; i++) {
			if(b[i] == 1) {
				cnt++;
				sb.append(String.valueOf(i));
				sb.append(" ");
			}
		}
		out.println(cnt);
		out.println(sb);
	}
}


Measured memory_bytes: 50500
#include<iostream>
#include<numeric>
using namespace std;
int main(){
    int k,a,b,c,tmp,ans=0;
    cin>>k;
    for(a = 1;a<=k;a++){
         for(b = 1;b<=k;b++){
             tmp = gcd(a,b);
              for(c = 1;c<=k;c++){
                  ans = ans + gcd(tmp,c);
              }
         }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    long long int a = 1000000000+7;
    
    long long int x = 1;

    for(int i = 1; i <= n; i++) x = i * x % a;

    cout << x << endl;
    
    return 0;
}

Measured memory_bytes: 256
import collections

H,W = list(map(int,input().split()))
field = [["#"]*(W+2)]

white = 0
for i in range(H):
    field.append(list(input()))
    counter = collections.Counter(field[-1])
    white += counter["."]
    field[-1].insert(0,"#")
    field[-1].append("#")
field.append(["#"]*(W+2))

queue = collections.deque()
queue.append((1,1))

distances = [[-1]*(W+2) for i in range(H+2)]
distances[1][1] = 0

while queue:
    y,x = queue.popleft()
    for i,j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
        newx,newy = x+i,y+j
        if field[newy][newx] == "." and distances[newy][newx] == -1:
            distances[newy][newx] = distances[y][x]+1
            if (newy,newx) == (H,W):
                break
            else:
                queue.append((newy,newx))

if distances[H][W] == -1:
    print(-1)
else:
    print(white-distances[H][W]-1)

Measured memory_bytes: 3444
import numpy as np
N,X = map(int, input().split())
L = list(map(int, input().split()))

dist = np.zeros(N+1, dtype=int)
for i in range(N):
  dist[i+1] = dist[i] + L[i]

i = 0
count = 0
while dist[i] <= X:
  count += 1
  i += 1
  if i == N +1:
    break
print(count)
"""
dist = 0
count = 1
for i in range(N):
  if dist + L[i] <= X:
    count += 1
    dist += L[i]
print(count)
"""

Measured memory_bytes: 27132
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <cmath>
#include <cstdlib>
#include <sstream>

#include <boost/range/irange.hpp>
using boost::irange;

using namespace std;

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

    int64_t n;
    cin >> n;
    
    vector<char> ss;
    ss.reserve(64);
    
    do
    {
        auto dm = div(n, -2L);
        if(dm.rem == -1)
        {
            dm.rem = 1;
            dm.quot += 1;
        }
        ss.push_back(dm.rem + '0');
        n = dm.quot;
    }
    while(n != 0);
    
    copy(ss.rbegin(), ss.rend(), ostream_iterator<char>(cout));
    cout << '\n';

    return 0;
}


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

#define INF 0x3F3F3F3F
#define DINF 1e+12
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define pb push_back
#define debug(x) if(1) cout << #x << " = " << x << endl;
#define debug2(x,y) if(1) cout << #x << " = " << x << " --- " << #y << " " << y << "\n";
#define all(S) (S).begin(), (S).end()
#define F first
#define S second
#define EPS 1e-9
#define mp make_pair

// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);

using namespace std;

typedef long long ll;
typedef pair < int, int >  ii;

int main(){

	int N, A;
	
	while(cin >> N >> A){
		int q = N/500;
		int r = N-(500*q);
		if(A >= r) cout << "Yes\n";
		else cout << "No\n";
	}


	return 0;
}


Measured memory_bytes: 256
require 'set'

loop do
    n = gets.to_i
    break if n == 0

    schedule = (1..n).map {gets.split.map(&:to_i)}

    if schedule[0][5] == 1 || schedule[0][6] == 1 || schedule[0][9] == 1 || schedule[0][10] == 1
        p 0
        next
    end

    state = [1] * 16 + [1, 1]
    state[5] = state[6] = state[9] = state[10] = 0
    states = [state]

    (1..n-1).each do |k|
        next_states = Set.new
        states.each do |*a, i, j|
            # p [a, i, j]
            (0..2).to_a.repeated_permutation(2) do |y, x|
                next if i != y && j != x
                next if schedule[k][y*4+x] == 1
                next if schedule[k][y*4+x+1] == 1
                next if schedule[k][(y+1)*4+x] == 1
                next if schedule[k][(y+1)*4+x+1] == 1
                b = a.map {|t| t + 1}
                b[y*4+x] = 0
                b[y*4+x+1] = 0
                b[(y+1)*4+x] = 0
                b[(y+1)*4+x+1] = 0
                next if b.any? {|t| t > 6}
                next_states << [*b, y, x]
            end
        end
        states = next_states
    end

    p states.empty? ? 0 : 1
end

Measured memory_bytes: 13108
#include<bits/stdc++.h>
#define ll      long long
#define pb	    push_back
#define F	    first
#define S	    second
#define B	    begin()
#define E	    end()
#define pii     pair < ll , ll >
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std ;
int jamil ;
int main()
{
    FASTIO
    int jamil ;
    cin >> jamil ;
    ll l[87] ;
    l[0] = 2 ;
    l[1] = 1 ;
    for ( int i = 2 ; i <= jamil ; i++ )
    {
        l[i] = l[i-1] + l[i-2] ;
    }
    cout << l[jamil] ;
	return 0 ;
}


Measured memory_bytes: 3636
#include <iostream>

int mod = 1000000007;
int dp[1001][1001];

int main()
{
	int n, m;
	std::cin >> n >> m;
	char c;
	std::cin >> c;
	dp[0][0] = 1;
	for (int j = 1; j < m; ++j)
	{
		std::cin >> c;
		if (c == '.')
			dp[0][j] = dp[0][j - 1];
	}
	for (int i = 1; i < n; ++i)
	{
		std::cin >> c;
		if (c == '.')
			dp[i][0] = dp[i - 1][0];
		for (int j = 1; j < m; ++j)
		{
			std::cin >> c;
			if (c == '.')
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	std::cout << dp[n - 1][m - 1] << '\n';
	return 0;
}

Measured memory_bytes: 4096
import scala.io.{StdIn => in}

object Main extends App {
  val Array(a, b, c, d) = in.readLine.split(" ").map(_.toLong)

  val a1 = b / c
  val a2 = (a-1) / c
  val b1 = b / d
  val b2 = (a-1) / d

  val a3 = a1 - a2
  val b3 = b1 - b2

  def gcd(a:Long, b:Long):Long = {
    if(b == 0) a
    else gcd(b, a%b)
  }

  val lcm = c * d / gcd(c, d)

  val c1 = b / lcm
  val c2 = (a-1) / lcm

  val c3 = c1 - c2

  val ans = if(c == 1 || d == 1) 0 else ((b - (a-1)) - (a3 + b3 - c3)) max 0
  println(ans)
}

Measured memory_bytes: 25424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
string a,b,c;cin>>a>>b>>c;
char cha=a[0];a.erase(a.begin());
while(a.length()||(b.length())||(c.length())){
    if(cha=='a'){
        cha=a[0];
        if(a.length()==0){cout<<"A";return 0;}
        a.erase(a.begin());
    }
    if(cha=='b'){cha=b[0]; if(b.length()==0){cout<<"B";return 0;}b.erase(b.begin());       }
    if(cha=='c'){cha=c[0]; if(c.length()==0){cout<<"C";return 0;}c.erase(c.begin());       }
}        


}

Measured memory_bytes: 256
s = input()

if s == 'SUN':
    print('7')
elif s == 'MON':
    print('6')
elif s == 'TUE':
    print('5')
elif s == 'WED':
    print('4')
elif s == 'THU':
    print('3')
elif s == 'FRI':
    print('2')
else:
    print('1')

Measured memory_bytes: 8812
#include <iostream>
#include <vector>
#include <climits>
#include <queue>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;

    vector<vector<int>> rooms(N);
    //vector<int> dist(N);
    vector<int> route(N);
    vector<bool> seen(N);

    int A, B;
    for(int i = 0; i < M; i++) {
        cin >> A >> B;
        rooms[A-1].push_back(B-1);
        rooms[B-1].push_back(A-1);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)a
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        // v から辿れる頂点をすべて調べる
        for(int i = 0; i < rooms[v].size(); i++) {
            if (dist[rooms[v][i]] != -1) continue; // すでに発見済みの頂点は探索しない
            dist[rooms[v][i]] = dist[v] + 1;
            route[rooms[v][i]] = v;
            que.push(rooms[v][i]);
        }
    }

    int j;
    for(j = 1; j < N; j++) {
        if(dist[j] == -1) {
            break;
        }
    }
    if(j == N) {
        cout << "Yes" << endl;
        for(int i = 1; i < N; i++) {
            //cout << i << ", " << dist[i] << ", " << route[i]+1 << endl;
            cout << route[i]+1 << endl;
        }
    } else {
        cout << "No" << endl;
    }


#if 0
    for(int i = 0;i < N; i++) {
        cout << "room: " << i << endl;
        for(auto j = 0; j < rooms[i].size(); j++) {
            cout << rooms[i][j] << ", ";
        }
        cout << endl;
    }
#endif

    return 0;
}

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

const int maxn = 500;
const int mo = (int)(1e9) + 7;
int a[maxn], b[maxn], va[maxn], vb[maxn];
int g[maxn][maxn], c[maxn][maxn], f[maxn][maxn][maxn / 3];

inline void add(int& x, int v) {
	x += v; if (x >= mo) x -= mo;
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
	g[0][0] = 1; int mx = n / 3;
	for (int i = 0; i <= mx; ++i) {
		for (int j = 0; j <= 2 * i; ++j) {
			add(g[i + 1][j], g[i][j]);
			if (j < 2 * i) add(g[i][j + 1], 1LL * g[i][j] * (2 * i - j) % mo);
		}
	} 
	for (int i = 1; i <= n; ++i) {
		va[a[i]] = 1; int now = i;
		memcpy(vb, va, sizeof(va));
		for (int j = 1; j <= n; ++j) {
			if (!vb[b[j]]) ++now; vb[b[j]]++;
			if (vb[a[i]] == 1 && vb[b[j]] == 1) c[i][j] = now;
		}
	} 
	f[0][0][0] = 1; 
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j) if (i || j)
			for (int k = 0; k <= mx; ++k) {
				if (i && !j) f[i][j][k] = f[i - 1][j][k];
				else if (!i && j) f[i][j][k] = f[i][j - 1][k];
				else if (i && j) f[i][j][k] = (0LL + f[i - 1][j][k] + f[i][j - 1][k] - f[i - 1][j - 1][k] + mo) % mo;
				if (k && i && j && c[i][j]) add(f[i][j][k], 1LL * f[i - 1][j - 1][k - 1] * (n - 3 * (mx - k) - c[i][j]) % mo);
			}
	return printf("%d\n", 1LL * f[n][n][mx] * g[mx][mx << 1] % mo), 0;
}

Measured memory_bytes: 132992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    if(int(a.find('C'))!=-1 and int(a.rfind('F'))!=-1 and a.find('C')<a.rfind('F'))
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256