akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static int[][] map = new int[101][101];
	static int[][] dp = new int[101][101];
	public static void main(String[] args) {
		
		FastScanner sc = new FastScanner();
		Scanner stdIn = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		out.println((a*b)/3.305785);
		out.flush();
	}
}
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
    	return (int)nextLong();
    }
    

}

Measured memory_bytes: 17452
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int ans=0,x,y;
	string a;
	cin>>a;
	int len=a.size() ;
	for(int i=0;i<len;i++)
	  if(a[i]=='A')
	  {
	  	x=i;
	  	break;
	  }
	for(int j=len-1;j>=0;j--)
	  if(a[j]=='Z')
	  {
	  	y=j;
	  	break;
	  }
	for(int i=x;i<=y;i++)
	  ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 640
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

n = int(input())
X, Y = zip(*[[int(i) for i in input().split()] for j in range(n)])

if n == 1:
    print(1)
    exit()

used = [False] * n
D = {(X[i], Y[i]): i for i in range(n)}

def dfs(i, p, q):
    if used[i]:
        return
    used[i] = True
    if (X[i] + p, Y[i] + q) in D:
        dfs(D[X[i] + p, Y[i] + q], p, q)
    if (X[i] - p, Y[i] - q) in D:
        dfs(D[X[i] - p, Y[i] - q], p, q)

ans = int(1e12)

for i in range(n):
    for j in range(i + 1, n):
        p = X[i] - X[j]
        q = Y[i] - Y[j]
        used = [False] * n
        cnt = 0
        for k in range(n):
            if used[k]:
                continue
            cnt += 1
            dfs(k, p, q)

        ans = min(ans, cnt)

print(ans)

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

// Shortcut

#pragma optimize ("O3")
#define int long long
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << ' ';
#define PrintVl(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << endl;
#define PrintA(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a));
#define mmset(a) memset(a, 0x3f, sizeof(a));
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, M = (1 << 9), mod = 1e9 + 7, inf = 1e9 + 7;

int n, m;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    if (m == 1) Ptest(0);
    cout << n - m;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
// A - Sorted Arrays
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 1;
  double count = 0;
  string s = "init", t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  rep(i, 1, n)
  {
    if (s == "init")
    {
      if (d[i] > d[i - 1])
      {
        s = "plus";
      }
      else if (d[i] < d[i - 1])
      {
        s = "minus";
      }
    }
    else if (s == "plus")
    {
      if (d[i - 1] > d[i])
      {
        ans++;
        s = "init";
      }
    }
    else if (s == "minus")
    {
      if (d[i - 1] < d[i])
      {
        ans++;
        s = "init";
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
 
int max(int a, int b)
{
    return (a > b) ? a : b;
}
 
long long int knapSack(int W, long long int wt[], long long int val[], int n)
{
    int i, w;
    long long int K[n + 1][W + 1];
 
    for (i = 0; i <= n; i++)
    {
        for (w = 0; w <= W; w++)
        {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w]
                        = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }
 
    return K[n][W];
}
 
int main()
{
    int n, W;
    cin >> n>>W;
    long long int val[n], wt[n];
    for (int i = 0; i < n; i++)
    {
        cin >> wt[i];
        cin >> val[i];
    }
    cout << knapSack(W, wt, val, n);
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll int divisible_a_rang(ll int num, ll int n, ll int buy){
    ll a, b, min;
    a=n/num;
    if (n%num) a++;
    a=a*num;
    b=buy/num;
    b=b*num;
    min=b-a;
    min=(min/num)+1;
    return min;
}

int main(){
    ll a, b, x;
    cin>> a >> b >> x;

    cout << divisible_a_rang(x,a,b) << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int n;
bool b[100000],c[100000];
string judge(bool x,bool y){
  c[0]=x;c[1]=y;
  int i;
  for(i=2;i<n;i++){
    c[i]=b[i-1]^c[i-1]^c[i-2];
  }
  if(c[0]==b[n-1]^c[n-1]^c[n-2] && c[1]==b[0]^c[0]^c[n-1]){
    string t="";
    for(i=0;i<n;i++){
      if(c[i])t+='S';
      else t+='W';
    }
    return t;
  }
  return "";
}

int main(){
  int i,j,k,cnt=0;
  string s;
  cin>>n;
  cin>>s;
  for(i=0;i<n;i++){
    if(s[i]=='o')b[i]=true;
    else b[i]=false;
  }
  string tt=judge(true,true),tf=judge(true,false);
  string ft=judge(false,true),ff=judge(false,false);
  if(tt!=""){
    cout<<tt<<endl;
    return 0;
  }
  if(tf!=""){
    cout<<tf<<endl;
    return 0;
  }
  if(ft!=""){
    cout<<ft<<endl;
    return 0;
  }
  if(ff!=""){
    cout<<ff<<endl;
    return 0;
  }
  cout<<-1<<endl;
}


Measured memory_bytes: 896
s=input()
op=["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            formula=s[0]+op[i]+s[1]+op[j]+s[2]+op[k]+s[3]
            if eval(formula)==7:
                print(formula+"=7")
                exit(0)

Measured memory_bytes: 3060
n = int(input())
dict = {}
for i in range(n):
    s = ''.join(sorted(input()))
    if s in dict.keys():
        dict[s] += 1
    else:
        dict[s] = 1
res = 0
for v in dict.values():
    res += v * (v - 1) // 2
print(res)


Measured memory_bytes: 17848
alpha = [chr(i) for i in range(97, 97+26)]

import sys
s = " "
for line in sys.stdin:
    s += line.lower()

for i in s:
    if i.lower() in alpha:
        alpha.append(i.lower())
        
for i in alpha[:26]:
    print(str(i) + " : " + str(alpha.count(i) - 1))      

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

using namespace std;

#define MAX 10
#define INF 1e9
typedef vector<int> Vec;

int N, res;
map<Vec,int> dist[2];
Vec v[2];

void bfs(int p){
  int t = !p;
  Vec next;
  queue<Vec> que; 

  dist[p][v[p]] = 0;
  que.push(v[p]);

  while(!que.empty()){
    Vec s = que.front(); que.pop();

    if(s == v[t]){
      res = dist[p][s];
      break;
    }

    if(dist[p][s] >= (N-1)/2){
      break;
    }

    for(int i = 0 ; i < N-1 ; i++){
      for(int j = i + 1 ; j < N ; j++){
	next = s;
	reverse(next.begin()+i, next.begin()+j+1);

	if(!dist[p].count(next)){
	  dist[p][next] = dist[p][s] + 1;
	  que.push(next);
	} 
      }
    }
  }
}

int main(){
  cin >> N;
  v[0].resize(N);
  for(int i = 0 ; i < N ; i++){
    cin >> v[0][i];
    v[1].push_back(i+1);
  }

  res = 9;
  bfs(0); bfs(1);
  map<Vec,int>::iterator it, val;
  
  for(it = dist[0].begin() ; it != dist[0].end() ; ++it){
    val = dist[1].find(it->first);
    if(val != dist[1].end()){
      res = min(res, it->second+val->second);
    }    
  }
  cout << res << endl;

  return 0;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

template<class T> bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

void Main() {
  ll n = read<ll>();
  ll a = read<ll>();

  ll ans = n;

  rep(k, 1, 41) {
    // k 回途中で食べる

    // k 回食べるときの最大間隔 s の最小値を二分探索で求める
    ll s;
    {
      // OK な下限を探すパターン
      ll ok = n;  // check が絶対trueになる値
      ll ng = -1;  // check が絶対falseになる値

      auto check = [&](ll x) -> bool {
        return ceil(pow(n, 1.0 / (k+1))) <= x;
        /*
        ll z = 1;
        rep(i, k + 1) {
          z *= x;
          if (z >= n) return true;
        }
        return false;
        */
      };

      while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        bool c = check(mid);
        // cout << "ok: " << ok << ", ng: " << ng << ", ";
        // cout << "check(" << mid << ") -> " << c << endl;
        if (c) ok = mid;
        else ng = mid;
      }
      s = ok;
    }

    //cout<<"k: "<<k<<endl;
    //cout<<"s: "<<s<<endl;

    rep(i, k+1) {
      // i 個、 -1 する
      bool ok = 0;
      ll z = 1;
      rep(j, i) {
        z *= (s - 1);
        if (z >= n) ok = 1;
      }
      rep(j, k+1-i) {
        z *= s;
        if (z >= n) ok = 1;
      }
      if (ok) {
        ll cand = a * k + (s-1) * i + s * (k+1-i);
        ans = min(ans, cand);
      }
    }
  }
  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    int hh[108][108];
    int n,m,u,v;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            hh[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        cin>>u>>m;
        for(int j=1;j<=m;j++)
        {
            cin>>v; hh[u][v]=1;
        }


    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cout<<hh[i][j];if(j!=n)cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3116
import java.util.Arrays;
import java.util.Scanner;

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

        final int n = scanner.nextInt();
        final int x = scanner.nextInt();
        scanner.nextLine();
        final int[] l = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        final int[] hops = new int[n + 1];
        hops[0] = 0;
        for (int i = 1; i < n + 1; i++) {
            hops[i] = hops[i - 1] + l[i - 1];
        }

        int count = 0;
        for (int i = 0; i < n + 1; i++) {
            if (x < hops[i]) break;

            count++;
        }

        System.out.println(count);
    }
}

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

const int Max = 105;
int G[Max][Max];
int u, k, v[Max], n;

int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> u >> k;
        for(int j=0; j<k; j++)
        {
            cin >> v[j];
            G[i][v[j]-1] = 1;
        }
    }
    for(int i=0; i<n; i++)
    {
        cout << G[i][0];
        for(int j=1; j<n; j++)
        {
            cout << " " << G[i][j];
        }
        cout << endl;
    }
    return 0;
}



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

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

Measured memory_bytes: 512
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;

#define ull unsigned long long
#define ll long long
#define PI 3.141592654
#define N 105000
vector<int> s_n;
bool is_prime[N];

void sieve(){
	memset(is_prime,1,sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int ac = 0;
	for(int x=0;x<N;++x){
		if(is_prime[x]){
			ac += x;
			s_n.push_back(ac);
			for(int c=x+x;c<N;c+=x){
				is_prime[c] = false;	
			}
		}
	}
}

int main(){
	sieve();
	int n;
	while(cin>>n,n){
		cout<<s_n[n-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1424
#include<stdio.h>
int main(){
	int a[31]={0},b,i;
	for(i=1;i<=28;i++){
		scanf("%d",&b);
		a[b]=b;
	}
	for(i=1;i<=30;i++){
		if(a[i]==0)printf("%d\n",i);
	}
	return 0;
}


Measured memory_bytes: 2044
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  ll h[n];
  rep(i,n) cin >> h[i];
  bool chk[n];
  rep(i,n) chk[i] = true;
  int a,b;
  rep(i,m){
    cin >> a >> b;
    a -= 1;
    b -= 1;
    // printf("%d %d\n", a,b);
    if(h[a] < h[b]) chk[a] = false;
    else if(h[a] > h[b]) chk[b] = false;
    else{
      chk[a] = false;
      chk[b] = false;
    }
  }
  int cnt = 0;
  rep(i,n){
    if(chk[i] == true) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 4640
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N, M;
	cin >> N >> M;
	vector< int > sum(N+1, 0);
	for (int i=0; i<M; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		sum[L]++;
		sum[R+1]--;
	}
	for (int i=0; i<N; ++i) sum[i+1] += sum[i];
	int ans = 0;
	for (int i=0; i<N; ++i) if (sum[i] == M) ++ans;
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  //横の空行削除
  for(int i = 0; i < H; i++) {
    bool judge = true;
    for(int j = 0; j < W; j++) {
      if(data.at(i).at(j) == '#') {
        judge = false;
        break;
      }
      
    }
    if(judge) {
      for(int k = 0; k < W; k++) {
        data.at(i).at(k) = '0';
      }
    }
    
  }
  //縦の空列削除
  for(int i = 0; i < W; i++) {
    bool judge = true;
    for(int j = 0; j < H; j++) {
      if(data.at(j).at(i) == '#') {
        judge = false;
        break;
      }
      
    }
    if(judge) {
      for(int k = 0; k < H; k++ ) {
        data.at(k).at(i) = '0';
      }
    }
    
  }
  for(int i = 0; i < H; i++) {
    bool x = false;
    for(int j = 0; j < W; j++) {
      if(data.at(i).at(j) != '0') {
        cout << data.at(i).at(j);
        x = true;
      }
     
    }
    if(x) {
      cout << endl;
    }
    
  }
}

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

int main() {
  	string S;
  	cin >> S;
  	if (S[0]!=S[1] and S[1]!=S[2] and S[2]!=S[0]){
      cout << "Yes";
    }
  	else{
      cout << "No";
    }
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

vector<bool> seen;
vector<int> a;
int ans = 0;

bool dfs(int n)
{
	if(a[n-1] == 2) return true;
	if(seen[n-1]) return false;
	seen[n-1] = true;
	ans++;
	return dfs(a[n-1]);
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	seen.resize(n,false);
	a.resize(n);
	rep(i, n) cin >> a[i];

	cout << (dfs(1) ? ans+1 : NIL) << endl;
	return 0;
}

Measured memory_bytes: 640
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b, x = ns()
    tmp = 0
    if a % x == 0:
        tmp = 1
    ans = b // x - a // x + tmp
    if x == 0:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int ans=0;
  for(int i=100;i>=1;i--){
    if(a%i==0&&b%i==0)ans++;
    if(ans==k){cout<<i<<endl;
               break;
              }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n>> m >> k ;
  
  x = min(k,m-1);
  y = (n*x)/m;
  ans = y;
  for (ll i = 1; i*i <= m; ++i){
      if(m % i==0){

        c =i-1;

        x = min(c,k);
        y = (n*x)/m - n*(c/m);
        ans = max(y,ans);
        c =n/i-1;

        x = min(c,k);
        y = (n*x)/m - n*(c/m);
        ans = max(y,ans);
      }
  }
  c(ans);

  
 
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

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

Measured memory_bytes: 256
def r;gets.split.map &:to_i;end
def rr(n);n.times.map{r.map{|v|v-1}};end

N,M = r
A = rr(N)
C = Array.new(M,0)

N.times do |i|
  A[i].shift
  A[i].each do |j|
    C[j] += 1
  end
end

p C.grep(N).size



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

int main() {

  long N;
  std::vector<long> v;
  long temp;
  long ans;
  long total;

  for(;;) {
    v.clear();
    std::cin >> N;
    if( N == 0 ) break;
    for(int i = 0; i < N; ++i) {
      std::cin >> temp;
      v.push_back(temp);
    }
    std::sort(std::begin(v), std::end(v));
    total = 0;
    for(int i = 1; i < N-1; ++i) total += v[i];
    ans = total / (N-2);
    std::cout << ans << std::endl;
  }


  return 0;
}

Measured memory_bytes: 1216
N = int(input())
dict_s = {}
for var in range(N):
    s = input()
    if s in dict_s:
        dict_s[s] = dict_s[s] + 1
    else:
        dict_s[s] = 1

M = int(input())
dict_t = {}
for var in range(M):
    t = input()
    if t in dict_t:
        dict_t[t] = dict_t[t] + 1
    else:
        dict_t[t] = 1

tensu = []
for key in dict_s.keys():
    if key in dict_t:
        tensu.append(dict_s[key] - dict_t[key])
    else:
        tensu.append(dict_s[key])

tensu_max=max(tensu)
if tensu_max < 0:
    print(0)
else:
    print(tensu_max)


Measured memory_bytes: 3064
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int x;
	cin >> x;
	cout << 8 - (x - 400) / 200 << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int modi = 1e9+7;

void sub_mod(int &a, int b){
	a = a-b;
	if(a<0)
		a+=modi;
	if(a>=modi)
		a-=modi;

}

int binpow(ll a,ll b){
	ll res = 1;
	while(b>0){
		if(b&1)
			res = res*a%modi;
		a= a*a%modi;
		b>>=1;
	}
	return res;
}
	

void solve(){
	int n;
	cin >> n;
	int p = binpow(10,n);

	sub_mod(p,2*binpow(9,n));
	sub_mod(p,-binpow(8,n));


	cout << p << endl;

}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3648
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; 
    cin >> n;
    int m;
    cin >> m;
    long long s;
    cin >> s;
    vector<pair<int,int>> edges;
    vector<int> A(m);
    vector<int> B(m);
    vector<vector<int>> graph(n);

    for (int i = 0; i < m; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        edges.emplace_back(u, v);
        graph[u].push_back(i);
        graph[v].push_back(i);
        A[i] = a;
        B[i] = b;
    }

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

    int M = (n + 1) * 51;
    const long long INF = 1LL << 60;
    vector<vector<long long>> dis(n, vector<long long>(M + 1, INF));
    s = min(s, (long long)M);
    dis[0][s] = 0;

    using PPP = pair<long long, pair<int,int>>;
    priority_queue<PPP, vector<PPP>, greater<PPP>> que;
    que.emplace(0, make_pair(0, s));

    while (!que.empty()) {
        long long d = que.top().first;
        int u = que.top().second.first;
        int s = que.top().second.second;
        que.pop();
        if (dis[u][s] != d) {
            continue;
        }
        // cout << u << " " << s << endl;

        for (auto e : graph[u]) {
            int v = edges[e].first + edges[e].second - u;
            int a = A[e];
            long long b = B[e];

            if (s >= a) {
                int ns = s - a;
                if (dis[v][ns] > d + b) {
                    dis[v][ns] = d + b;
                    que.emplace(dis[v][ns], make_pair(v, ns));
                }
            }
        }

        {
            long long ns = s + C[u];
            ns = min(ns, (long long)M);
            long long nd = d + D[u];
            if (dis[u][ns] > nd) {
                dis[u][ns] = nd;
                que.emplace(dis[u][ns], make_pair(u, ns));
            }
        }
    }

    for (int i = 1; i < n; ++i) {
        long long mn = 1LL << 62;
        for (int j = 0; j <= M; ++j) {
            mn = min(mn, dis[i][j]);
        }
        cout << mn << '\n';
    }


    return 0;
}

Measured memory_bytes: 6288
//by Judge
#include<bits/stdc++.h>
#define Rg register
#define fp(i,a,b) for(Rg int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(Rg int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(Rg int i=head[u],v=e[i].to;i;v=e[i=e[i].nxt].to)
#define open(S) freopen(S".in","r",stdin),freopen(S".out","w",stdout)
#define ll long long
using namespace std;
const int M=305;
typedef int arr[M];
#ifndef Judge
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
char buf[1<<21],*p1=buf,*p2=buf;
template<class T>inline T Max(T x,T y){return x>y?x:y;}
template<class T>inline bool cmax(T& x,T y){return x<y?x=y,1:0;}
inline ll read(){ ll x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0'; return x*f;
} inline void sread(string& s){ char c=getchar();
	for(;!isalpha(c);c=getchar()); s=" ";
	for(;isalpha(c);c=getchar()) s+=c;
} int n,k,f[M][M][M]; string s;
int dfs(int l,int r,int k){ int &res=f[l][r][k];
	if(l==r) return res=1; if(l>r||res) return res;
	res=Max(dfs(l+1,r,k),dfs(l,r-1,k));
	if(s[l]==s[r]) cmax(res,dfs(l+1,r-1,k)+2);
	else if(k) cmax(res,dfs(l+1,r-1,k-1)+2); return res;
}
int main(){
	sread(s),n=s.length()-1,k=read();
	return !printf("%d\n",dfs(1,n,k));
}

Measured memory_bytes: 112512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int num=n;
  int sum=0;
  int dig;
  while(num){
    dig=num%10;
    sum+=dig;
    num/=10;
  }
  if(n%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 110;
typedef long long ll;
bool cmp(double a, double b)
{
    return a>b;
}
int main(void)
{
    const double eps = 1e-9;
    int N;
    double M;
    double a[MAXN];
    double sum = 0.0;
    cin>>N>>M;
    for(int i = 0;i <N;i ++)
    {
        cin>>a[i];
        sum += a[i];
    }
    sort(a,a+N,cmp);
    int i = 0;
    sum = sum / (4*M);
    while(i<M && i < N)
    {
        if(a[i]>sum || fabs(a[i]-sum)<eps)
            i ++;
        else break;
    }
    if(i == M)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> vvll;
typedef pair<ll, ll> pii;
typedef pair<string, ll> psi;
typedef pair<ll, string> pis;
typedef pair<ll, vll> plv;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define REP(i, a, b) for(ll i=ll(a);i<=ll(b);++i)
#define REPR(i, a, b) for(ll i=ll(a);i>=ll(b);--i)
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()

template<typename T>
T absolute(T a, T b) { return a >= 0 ? a : -a; }

template<typename T>
T sqr(T a) { return a * a; }

int main() {
    fastio
    char s[4];
    cin>>s;
    ll a=atoi(s);
    if(a<1300 && a>=100){
        if(a%100<13 && a%100>=1)cout<<"AMBIGUOUS";
        else cout<<"MMYY";
    }
    else if(a%100<13 && a%100>=1)cout<<"YYMM";
    else cout<<"NA";
    cout<<endl;
    return 0;
}

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

int main() {
  int n, m, x; cin>>n>>m>>x;
  int ans1 = 0,	ans2 = 0;
  for(int i = 0; i < m;	i++) {
    int	a; cin>>a;
    if(a < x) ans1++;
    else if(a >	x) ans2++;
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i).sort
max = arr[n - 1]
center = (max + 1) / 2
r = max + 1
(0...(n - 1)).each do |i|
  if (r - center).abs > (arr[i] - center).abs
    r = arr[i]
  end
end
puts "#{max} #{r}"

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> b(n, 0);
    for (int i = 0; i < n; i++) {
        b[i] = (s[i] - '0');
    }

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

    vector<int> mod = {popcnt - 1, popcnt + 1};
    vector<int> a(2, 0);
    auto f = [&](int a, int b) {
        if (b == 0) return -1;
        return a % b;
    };
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < 2; k++) {
            a[k] = f((a[k] * 2) + b[i], mod[k]);
        }
    }

    vector<int> t(2, 1);
    vector<int> cur(n, 0);
    for (int i = n - 1; i >= 0; i--) {
        int p = b[i] ^ 1;
        int sgn = 1;
        if (b[i]) sgn = -sgn;
        if (b[i] && popcnt - 1 == 0) {
            cur[i] = -1;
        } else {
            cur[i] = f(a[p] + t[p] * sgn + mod[p], mod[p]);
        }
        for (int k = 0; k < 2; k++) t[k] = f(t[k] * 2, mod[k]);
    }

    for (int i = 0; i < n; i++) {
        if (cur[i] < 0) {
            cout << 0 << endl;
            continue;
        }
        int ans = 1;
        while (cur[i] > 0) {
            ans++;
            cur[i] %= __builtin_popcount(cur[i]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5120
N, M = [int(n) for n in input().split()]
S = [[int(n) for n in input().split()][1:] for _ in range(M)]
P = [int(n) for n in input().split()]

F = [0 for _ in range(N)]

def inc(i):
    if i == N:
        return False
    F[i] += 1
    if F[i] == 2:
        F[i] = 0
        return inc(i + 1)
    return True

def check(i):
    f_cnt = 0
    for j in S[i]:
        f_cnt += F[j-1]
    if f_cnt % 2 == P[i]:
        return True
    return False

cnt = 0
while True:
    flag = True
    for i in range(M):
        if not check(i):
            flag = False
            break
    if flag:
        cnt += 1
    if not inc(0):
        break

print(cnt)


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

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

	int result = 0;
	if(n > 1) {
		for(int i = 1; i < n;) {
			n--;
			result += n;
		}
	}
	if(m > 1) {
		for(int i = 1; i < m;) {
			m--;
			result += m;
		}
	}

	cout << result << endl;

    return 0;
}


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


using namespace std;

int main()
{
	int dx[7][3] = 
	{
		{ 1, 0, 1 },
		{ 0, 0, 0 },
		{ 1, 2, 3 },
		{ -1, 0, -1 },
		{ 1, 1, 2 },
		{ 0, 1, 1 },
		{ 1, -1, 0 }
	};
	int dy[7][3] =
	{
		{ 0, 1, 1 },
		{ 1, 2, 3 },
		{ 0, 0, 0 },
		{ 1, 1, 2 },
		{ 0, 1, 1 },
		{ 1, 1, 2 },
		{ 0, 1, 1 },
	};

	char bb[256];
	char* next = (char*)1;
	while (next)
	{
		char buf[8][8];
		int i;

		for (i = 0; i < 8; ++i)
		{
			if (fgets(bb, 256, stdin) ==NULL)
				break;
			for (int j = 0; j < 8; ++j)
				buf[i][j] = bb[j];
		}
		next = fgets(bb, 256, stdin);
		if (i != 8)
			break;

		int x, y;
		for (y = 0; y < 8; ++y)
		{
			bool found = false;
			for (x = 0; x < 8; ++x)
			{
				if (buf[y][x] == '1')
				{
					found = true;
					break;
				}
			}
			if (found)
				break;
		}

		for (i = 0; i < 7; ++i)
		{
			int j;
			for (j = 0; j < 3; ++j)
			{
				int tx = x+dx[i][j];
				int ty = y+dy[i][j];
				if (tx < 0 || ty < 0 || tx >= 8 || ty >= 8
					|| buf[ty][tx] == '0')
					break;
			}
			if (j == 3)
			{
				printf("%c\n", 'A' + i);
				break;
			}
		}
	}

	return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)

#pragma comment(linker, "/STACK:16777216")

typedef long long int64;
typedef unsigned long long uint64;

int64 a[100005], s[100005];

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

	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1,a+n+1);
	s[0] = 0;
	for (int i = 1; i <= n; i++) s[i] = s[i-1]+a[i];

	int res = 1;
	for (int i = n-1; i >= 1; i--)
	{
		int64 cur = s[i];
		if ((s[i] * 2) >= a[i+1]) res++;
		else break;
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
/*
Rathin Bhargava
IIIT Bangalore

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

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

const int N = 1e5+10;
vector<int> adj[N] = {};
vector<int> path(N);
vector<int> vis(N);

void dfs(int u = 0, int p = -1)
{
  if(vis[u]) return;
  vis[u] = 1;
  for(auto v : adj[u])
  {
    dfs(v,u);
    path[u] = max(path[u],path[v]+1);
  }
}

int main()
{
  __;
  int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin >> a >> b;
    a--; b--;
    adj[a].pu(b);
  }

  for(int i=0;i<n;i++)
  {
    if(!vis[i]) dfs(i);
  }

  int max1 = -1;
  for(int i=0;i<n;i++) max1 = max(max1,path[i]);

  cout << max1 << endl;

  return 0;
}



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

int main(){
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=1;i<=n;i++){
		int a1,b1,c1;
		cin>>a1>>b1>>c1;
		a[i]=a1;
		b[i]=b1;
		c[i]=c1;
	}
	int da[n],db[n],dc[n];
	da[1]=a[1];
	db[1]=b[1];
	dc[1]=c[1];
	for(int i=2;i<=n;i++){
		da[i]=a[i]+max(db[i-1],dc[i-1]);
		db[i]=b[i]+max(da[i-1],dc[i-1]);
		dc[i]=c[i]+max(db[i-1],da[i-1]);
	}
	cout<<max(da[n],max(db[n],dc[n]))<<"\n";
}


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <set>

using namespace std;

int main(void)
{
    string s,t;
    cin >>s >>t;

    map<char, set<char> > mm;
    map<char, set<char> > tt;
    for(int i = 0; i < s.size(); i++){
        mm[t[i]].insert(s[i]);
        tt[s[i]].insert(t[i]);
    }

    bool possible = true;
    for(map<char, set<char> >::iterator it = mm.begin(); it != mm.end(); it++){
        if((*it).second.size() > 1){
            possible = false;
        }
    }
    for(map<char, set<char> >::iterator it = tt.begin(); it != tt.end(); it++){
        if((*it).second.size() > 1){
            possible = false;
        }
    }

    if(possible){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
ll mod = 1000000007;
ll fac[200100];
ll inv[200100];
ll facinv[200100];
void C_init(){
    fac[0] = 1;
    for(int i = 1;i < 200100;i++)fac[i] = (fac[i-1] * i)%mod;
    inv[1] = 1;
    for(int i = 2;i < 200100;i++)inv[i] = ((-(mod/i)*inv[mod%i])%mod+mod)%mod;
    facinv[0] = 1;
    for(int i = 1;i < 200100;i++)facinv[i] = (facinv[i-1] * inv[i])%mod;
    return;
}
ll nCr(ll n, ll r){
    return max((ll)0,((fac[n] * facinv[n-r])%mod * facinv[r])%mod);
}
int main(){
  ll n, k;
  cin >> n >> k;
  C_init();
  for (ll i = 1; i <= k; i++) {
    if (i <= n-k+1) {
      ll ans = nCr(k-1, i-1);
      ans %= mod;
      ll x = nCr(n-k+1, i);
      x %= mod;
      ans *= x;
      ans %= mod;
      cout << ans << endl;
    }
    else {
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 4992
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    long sum = 0;
    for (int i = 1; i <= n; i++) {
      if (i % 3 == 0 || i % 5 == 0) {
        continue;
      }
      sum += i;
    }
    pw.println(sum);
  }
}


Measured memory_bytes: 35656