akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int gcd(int a,int b){
    if(b == 0){
        return a;
    }
    return gcd(b,a%b);
}

int main(){
    int K,sum;
    sum = 0;
    scanf("%d",&K);
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                sum += gcd(gcd(i,j),k);
            }
        }
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 1692
#include<iostream>
#include<sstream>
using namespace std;
int main(){
  string s;
  while(cin >> s) {
    for(int i=0;i<s.size();i++) if(s[i]==',') s[i]=' ';
    stringstream ss(s);
    int id;double w,h;
    ss >> id >> w >> h;
    double bmi=w/(h*h);
    if(bmi>=25.0) cout << id << endl;
  }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> x(m);
  for (int i = 0; i < m; i++) cin >> x[i];
  sort(x.begin(), x.end());
  vector<int> x_dif(m - 1);
  for (int i = 0; i < m - 1; i++) {
    x_dif[i] = x[i + 1] - x[i];
  }
  sort(x_dif.begin(), x_dif.end());
  ll ans = 0;
  for (int i = 0; i < m - n; i++) {
    ans += x_dif[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
n, *a = map(int, open(0).read().split())

def get_color(rate):
    if 1<=rate<400:
        return 'gray'
    elif rate<800:
        return 'brown'
    elif rate<1200:
        return 'green'
    elif rate<1600:
        return 'rb'
    elif rate<2000:
        return 'blue'
    elif rate<2400:
        return 'yellow'
    elif rate<2800:
        return 'orange'
    elif rate<3200:
        return 'red'
    else:
        return 'free'

c = set()
free_cnt = 0
for i in range(n):
    if get_color(a[i]) == 'free':
        free_cnt += 1
    else:
        c.add(get_color(a[i]))

min_ans = max(len(c),1)
max_ans = len(c)+free_cnt

print(min_ans, max_ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

template < typename K, typename V, typename A>
void  map_count (map<K, V> &mapBuff, A a){
    for(auto c : a) {
        if (mapBuff.count(c) == 0 ) {
            mapBuff.insert(make_pair(c, 1));
        } else {
            auto it = mapBuff.find(c);
            mapBuff.insert(make_pair(c, it->second++));
        }
    }
}


/*
void  map_count(map<char, int> &mapBuff, string s){
    for(char c : s) {
        if (mapBuff.count(c) == 0 ) {
            mapBuff.insert(make_pair(c, 1));
        } else {
            auto it = mapBuff.find(c);
            mapBuff.insert(make_pair(c, it->second++));
        }
    }
}
*/

int main() {
    string s;
    string ans = "Yes";
    cin >> s;
    map<char, int> m;

    map_count(m,s);
    
    for(auto i = m.begin(); i != m.end(); ++i){
        if ( i->second != 2 ) {
            ans = "No";
        }
        //cout << i->first << " " << i->second << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

std::vector<int> G(100001);
vvi rev = vv(100001, 0, 0, int);
int ans = 0;
priority_queue<pair<int, int> > q;
std::vector<int> ok(100001, 0);
void dfs(int now, int d){
  if(rev[now].size()==0) q.push(make_pair(d, now));
  for(int i=0;i<rev[now].size();i++){
    if(rev[now][i]==now) continue;
    dfs(rev[now][i], d+1);
  }
}
void check(int now, int m, int d, int d2){
  if(ok[now]==1||now==1) return;
  if(d==0){
    ans++,q.push(make_pair(m-d2, now));
    return;
  }
  ok[now] = 1;
  check(G[now], m, d-1, d2);
}
int main(int argc, char const *argv[]) {
  int N, K, a;
  std::cin >> N >> K;
  for(int i=1;i<=N;i++){
    std::cin >> a;
    if(i==1&&a!=1) ans++, a=1;
    G[i]=a;
    rev[a].push_back(i);
  }
  dfs(1, 0);
  while(!q.empty()){
    int x = q.top().first, y=q.top().second;
    //std::cout << x << " " << y << '\n';
    q.pop();
    check(y, x, K, K);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11136
#include <math.h>
#include <stdio.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  int xs[15][15] = {{}};
  int ys[15][15] = {{}};
  int cs[15] = {};
  int As[15] = {};
  unsigned int max = 0;
  for (int i = 0; i < N; i++) {
    cin >> As[i];
    for (int j = 0; j < As[i]; j++) {
      cin >> xs[i][j] >> ys[i][j];
    }
  }
  for (int bit = 0; bit < (1 << N); bit++) {
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        cs[i] = 1;
      } else {
        cs[i] = 0;
      }
    }
    bool check = true;
    for (int i = 0; i < N; i++) {
      if (cs[i] == 0) {
        continue;
      }
      for (int j = 0; j < As[i]; j++) {
        if (cs[xs[i][j] - 1] != ys[i][j]) {
          check = false;
        }
      }
    }
    if (check) {
      int count = 0;
      for (int i = 0; i < N; i++) {
        if (cs[i] != 0) {
          count++;
        }
      }
      if (max <= count) {
        max = count;
      }
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;

int N;
int ABC[100100][3];
int dp[100100][3];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> ABC[i][j];
        }
    }

    for (int i = 0; i < N; i++) {
        dp[i + 1][0] = max(dp[i][1] + ABC[i][0], dp[i][2] + ABC[i][0]);
        dp[i + 1][1] = max(dp[i][0] + ABC[i][1], dp[i][2] + ABC[i][1]);
        dp[i + 1][2] = max(dp[i][0] + ABC[i][2], dp[i][1] + ABC[i][2]);
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] str = br.readLine().split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        int tmp;
        if(x<y){
        	tmp=x;
        	x=y;
        	y=tmp;
        }
        while(x%y>0) {
        	tmp=y;
        	y=x%y;
        	x=tmp;
        }
        out.println(y);
        out.flush();
    }

    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}

Measured memory_bytes: 24480
def main():
    N,W = [int(x) for x in input().split()]
    vl,wl = [],[]
    for _ in range(N):
        v,w = [int(x) for x in input().split()]
        vl.append(v)
        wl.append(w)

    dp = []
    for i in range(N+1):
        dp.append([0]*(W+1))

    for i in range(N):
        for j in range(W+1):
            # print(i,j)
            if j < wl[i]:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = max(dp[i][j],dp[i][j-wl[i]]+vl[i])
            # print(dp)
    print(int(dp[N][W]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 25516
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

const int maxn = 105;

int a[maxn][maxn];
bool f[maxn][maxn],g[maxn][maxn];
int n;

int main()
{
    while (scanf("%d",&n)!=EOF)
    {
        if (n==0) break;
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
                scanf("%d",&a[i][j]);

        memset(f,false,sizeof(f));
        memset(g,false,sizeof(g));
        for (int i=1;i<=n;i++)
        {
            int Min=a[i][1]; int id;
            for (int j=1;j<=n;j++)
                if (a[i][j] < Min)
                {
                    Min=a[i][j];
                    id=j;
                }
            for (int j=1;j<=n;j++) if (a[i][j] == Min) f[i][j] = true;
        }

        for (int j=1;j<=n;j++)
        {
            int Max=a[1][j]; int id;
            for (int i=1;i<=n;i++)
            {
                if (a[i][j] > Max)
                {
                    Max = a[i][j];
                    id = i;
                }
            }
            for (int i=1;i<=n;i++) if (a[i][j] == Max) g[i][j] = true;
        }


        int cnt=0;
        for (int i=1;i<=n;i++)
        {
            for (int j=1;j<=n;j++)
                if (f[i][j] && g[i][j]) cnt++;
        }
        if (cnt!=0)
        {
            bool flag=false;
            for (int i=1;i<=n;i++)
            {
                for (int j=1;j<=n;j++)
                    if (f[i][j] && g[i][j])
                    {
                        printf("%d\n",a[i][j]);
                        flag=true;
                        break;
                    }
                if (flag) break;
            }
        }
        else puts("0");
    }
    return 0;
}

Measured memory_bytes: 0
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	char a,b;
	cin>>a>>b;
	if(a>b)cout<<">"<<endl;
	else if(a==b)cout<<"="<<endl;
	else cout<<"<"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)












int main(){
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    ll sum = 0;
    REP(i, n){
        a[i] = l + i;
        sum += a[i];
    }
    ll d = INF, ans = 0;
    REP(i, n){
        ll s = 0;
        REP(j, n){
            if(i == j) continue;
            s += a[j];
        }
        if(d > abs(sum - s)){
            d = abs(sum - s);
            ans = s;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>p(n);
  rep(i,n){
    cin>>p[i];
    p[i]++;
  }
   
 
  int q=0;
  

  rep(i,k) q+=p[i];
  int mx=q;

  rep(i,n-k){
    q-=p[i];
    q+=p[i+k];
    if(q>mx)mx=q;
  }
  
  
  double ans=mx;
  ans/=2;
  //cout << fixed << setprecision(6) << ans << endl; 
  //cout<<ans<<endl;
  printf("%.8f\n",ans);
  
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;



int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	unsigned n;
	cin >> n;
	vector<unsigned> v(n * 2);
	for (unsigned i = 0; i < n * 2; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	unsigned s = 0;
	for (unsigned i = 0; i < v.size(); i += 2)
		s += v[i];
	cout << s << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int n,z,w; cin>>n>>z>>w;
    int a[2000];
    FOR(i,0,n) cin>>a[i];
    if(n>1)co(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])));
    else co(abs(a[0]-w));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int n, i, tab[N], nww, d, k, m;

int nwd(int a, int b) {
	if (b == 0) return a;
	return nwd(b, a % b);
}

int main() {
scanf("%d %d", &n, &m);
for (i=0;i<n;i++) {
	scanf("%d", &tab[i]);
	tab[i] /= 2;
}
nww = tab[0];
for (i=1;i<n;i++) {
	d = nwd(nww, tab[i]);
	if (nww * 1LL * tab[i] / d > m) {
		printf("0\n");
		return 0;
	}
	nww = nww * 1LL * tab[i] / d;
}
for (i=0;i<n;i++) if ((nww / tab[i]) % 2 == 0) {
	printf("0\n");
	return 0;
}
k = m / nww;
printf("%d\n", k / 2 + k % 2);
return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int N;
  scanf("%d", &N);
  int count = 0;
  for(int i = 1; i < N + 1; i += 2){
    int c = 0;
    int j = 1;
    while(j*j <= i){
      if(j*j == i) c++;
      else if(i % j == 0) c += 2;
      j++;
    }
    if(c == 8) count++;
  }
  printf("%d\n", count);
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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

const int INF = 100000000; // 十分大きな値
ll dp[(1<<17) + 1][18];
int n;
int rec(ll bit, ll v, VVLL&cost)
{
    // すでに探索済みだったらリターン
    if (dp[bit][v] != -1) return dp[bit][v];

    // 初期値
    if (bit == (1<<v)) {
        return dp[bit][v] = cost[v][0];
    }

    // 答えを格納する変数
    ll res = INF;

    // bit の v を除いたもの
    ll prev_bit = bit & ~(1<<v);

    ll minCost = cost[v][0];
    rep(i,n){
      if(!!(prev_bit & (1<<i))) minCost = min(minCost,cost[v][i+1]);
    }

    // v の手前のノードとして u を全探索
    rep(i,n){
        if (!(prev_bit & (1<<i))) continue; // i が prev_bit になかったらダメ
        // 再帰的に探索
        if (res > rec(prev_bit, i, cost) + minCost) {
            res = rec(prev_bit, i, cost) + minCost;
        }
    }

    return dp[bit][v] = res; // メモしながらリターン
}
void solve(VVLL & cost){
  memset(dp,0,sizeof(dp));
  //cout << n << endl;
  rep(bit,(1<<n)) rep(x,n) dp[bit][x] = -1;
  rep(i,n) dp[0][i] = 0;
  // 探索
    ll res = INF;
    rep(x,n) {
        if (res > rec((1<<n)-1, x , cost)) {
            res = rec((1<<n)-1, x , cost);
        }
    }
    // rep(bit,(1<<n)){
    //   rep(x,n) cout << dp[bit][x] << ' ';
    //   cout << endl;
    // }
    cout << res << endl;
}


int main(){
  while(true){
    cin >> n;
    if(n == 0) break;
    VVLL cost(n,VLL(n+1));
    rep(i,n)rep(j,n+1) cin >> cost[i][j];
    solve(cost);
  }
  return 0;
}



Measured memory_bytes: 21516
#include<cstdio>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int main()
{
	int n;
	vector<int> arr;
	vector<int> sol;
	int input;
	int i;
	bool valid;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &input);

		arr.push_back(input);
	}

	while (!arr.empty())
	{
		valid = false;

		for (i = arr.size()-1; i >= 0; i--)
		{
			if (arr[i] == i + 1)
			{
				sol.insert(sol.begin(), arr[i]);

				arr.erase(arr.begin() + i);

				valid = true;

				break;
			}
		}
		
		if (!valid)
		{
			printf("-1\n");

			return 0;
		}
	}

	for (i = 0; i < n; i++)
	{
		printf("%d\n", sol[i]);
	}

	return 0;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  double a,b;
  double A;
  cin >> a >> b;
  cin >> A;


  int cand1,cand2;
  cand1 = ceil(A/a);
  cand2 = ceil(A/b);
  cout << min(cand1,cand2) << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

vector<bitset<100>> p;
vector<vector<pair<i64, i64>>> G;

bool dfs(i64 v, i64 f, i64 g, i64 i) {
  if(v == g) {
    return true;
  }
  for(auto e: G[v]) {
    i64 t = e.first;
    i64 ei = e.second;
    if(t == f) continue;
    if(dfs(t, v, g, i)) {
      p[i] |= (1ll << ei);
      return true;
    }
  }
  return false;
}


int main() {
  i64 N;
  cin >> N;
  G.resize(N);
  rep(i,0,N - 1) {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back({ b, i });
    G[b].push_back({ a, i });
  }
  i64 M;
  cin >> M;
  p.resize(M);
  vector<i64> U(M), V(M);
  rep(i,0,M) {
    cin >> U[i] >> V[i];
    U[i]--;
    V[i]--;
    dfs(U[i], -1, V[i], i);
  }

  i64 ans = 0;
  vector<i64> cnt(N);
  for(auto s = 1; s < (1 << M); s++) {
    bitset<100> bit;
    rep(i,0,M) {
      if(s & (1 << i)) {
        bit |= p[i];
      }
    }
    if(__builtin_popcountll(s) & 1)
      cnt[N - 1 - bit.count()]++;
    else 
      cnt[N - 1 - bit.count()]--;
  }
  for(i64 i = 0;i < N;i++) {
    ans += (1ll << i) * cnt[i];
  }
  cout << (1ll << (N - 1)) - ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main(){
int n,k;
cin>>n>>k;
int a[101];
rep(i,0,n) cin>>a[i];

int total;
rep(i,0,n){
    total+=2*min(a[i],k-a[i]);
}
cout<<total<<endl;
return 0;
}

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

int main(){
  string s;
  cin >> s;
  int q;
  cin >> q;
  
  vector<int> t(q), f(q);
  vector<string> c(q);
  
  for(int i=0; i<q; i++){
    cin >> t.at(i);
    if(t.at(i)==2) cin >> f.at(i) >> c.at(i);
  }

  bool rev=false;
  bool f1;

  string st, sb;
    
  rep(i, q){
    if(t.at(i)==1){
      rev=!rev; //反転
    }
    else{
      if((rev==false && f.at(i)==1) || (rev==true && f.at(i)==2)){
        st.append(c.at(i));
      }
      else{
        sb.append(c.at(i));
      }
//      cout << s << " " << rev << endl;
    }
  }
  
  if(rev){
    reverse(s.begin(), s.end());
    reverse(sb.begin(), sb.end());
    s=sb+s+st;
  }
  else{
    reverse(st.begin(), st.end());
    s=st+s+sb;
  }
  
  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 13852
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	struct deer { 
		int t, x, y; 
		deer(int t, int x, int y) :t(t), x(x), y(y) {}
		deer() :t(0), x(0), y(0) {}
	};

	vector<deer> plan(N+1);
	for (int i = 1; i <= N; i++) cin >> plan[i].t >> plan[i].x >> plan[i].y;

	int cost, time;
	bool flag = true;
	for (int i = 1; i <= N; i++) {

		cost = abs(plan[i].x - plan[i - 1].x) + abs(plan[i].y - plan[i - 1].y);
		time = plan[i].t - plan[i - 1].t;
		if (cost > time || ((cost ^ time) & 1)) flag = false;
	}

	if (flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


void solve(long long N, long long X, long long D){
    if(D == 0){
        if(X == 0){
            cout << 1 << endl;
        }else{
            cout << N + 1 << endl;
        }
        return;
    }else if(D < 0){
        X *= -1;
        D *= -1;
    }

    map<ll, vector<pair<ll, ll>>> event;
    REP(k, N + 1){
        const ll m = (k * X) % D;
        ll L = (k * X - m) / D + (k - 1) * k / 2;
        ll R = (k * X - m) / D + (2 * N - k - 1) * k / 2;
        event[m].emplace_back(L, 1);
        event[m].emplace_back(R + 1, -1);
    }

    ll ans = 0;
    ll cur_num = 0;
    ll prev_pos = 0;
    for(auto it = event.begin(); it != event.end(); ++it){
        sort(it->second.begin(), it->second.end());
        for(auto& evt : it->second){
            const ll pos = evt.first;
            const ll val = evt.second;
            if(cur_num == 1 && val == -1){
                ans += pos - prev_pos;
            }else if(cur_num == 0 && val == 1){
                prev_pos = pos;
            }
            cur_num += val;
        }
    }
    assert(cur_num == 0);
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long D;
    scanf("%lld",&D);
    solve(N, X, D);
    return 0;
}


Measured memory_bytes: 25216
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = sum(A)
    q = sum([a ** 2 for a in A])
    ans = (((s * s) - q)) // 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()


Measured memory_bytes: 31436
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));


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

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a < c){
        a = c;
    }
    if(b > d){
        b = d;
    }
    int ans = b-a;
    if(ans <= 0) cout << 0 << endl;
    else cout << ans << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
DP = [[0 for _ in range(len(prime))] for _ in range(N+1)]
for ind,i in enumerate(DP):
    num = ind
    if(ind == 0):
        continue
    for p_ind,j in enumerate(prime):
        DP[ind][p_ind]=DP[ind-1][p_ind]
        if(j>num or num==1):
            continue
        while(num%j == 0):
            DP[ind][p_ind]+=1
            num//=j
cnt_74 = 0
cnt_24 = 0
cnt_14 = 0
cnt_4 = 0
cnt_2 = 0
cnt_1 = 0
ans = 0
for i in DP[N]:
    if(i>=74):
        cnt_74+=1
    if(i>=24):
        cnt_24+=1
    if(i>=14):
        cnt_14+=1
    if(i>=4):
        cnt_4+=1
    if(i>=2):
        cnt_2+=1
    if(i>=1):
        cnt_1+=1

ans+=cnt_74
if(cnt_24>=1):
    ans+=cnt_24*(cnt_2-1)
if(cnt_14>=1):
    ans+=cnt_14*(cnt_4-1)
if(cnt_4>=2):
    ans+=combinations_count(cnt_4,2)*(cnt_2-2)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

int main() {
    int a, b, c, d;
    int e, f, result;
    cin >> a >> b >> c >> d;
    if(a > c){
        e = a;
    }else{
        e = c;
    }
    if(b > d){
        f = d;
    }else{
        f = b;
    }
    result = f-e;
    if(result > 0){
        cout << result << endl;
    }else{
        cout << 0 << endl;
    }
    //cout << e << " " << f << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int n;
string name[40];
vector<string> neighbor[40];
map<string,int> name2id;
int a[40],b[40],c[40];
int G[40][40];

const int N=1<<20;
int dp[N];
int NG[40],OK[40];

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

    while(cin >>n,n)
    {
        // initialize
        name2id.clear();
        rep(i,40) neighbor[i].clear();
        memset(G,0,sizeof(G));
        memset(dp,0,sizeof(dp));
        memset(NG,0,sizeof(NG));
        memset(OK,0,sizeof(OK));

        // input
        rep(i,n)
        {
            cin >>name[i] >>b[i] >>c[i];
            neighbor[i].resize(c[i]);
            rep(j,c[i]) cin >>neighbor[i][j];

            a[i] = i;
            name2id[name[i]] = i;
        }

        rep(i,n)rep(j,c[i]) G[i][name2id[neighbor[i][j]]] = 1;

        int X=n/2, Y=n-X;

        // make NG mask
        rep(i,X)rep(j,X)if(G[i][j]) NG[i] |= 1<<j;
        rep(i,Y)rep(j,Y)if(G[X+i][X+j]) NG[X+i] |= 1<<j;

        // make OK mask
        rep(i,X)rep(j,Y)if(G[i][X+j]==0) OK[i] |= 1<<j;

        // ?????????????????????????????¶
        rep(mask,1<<Y)
        {
            bool ok=true;
            rep(i,Y)if(mask>>i&1) ok &= ((NG[X+i]&mask) == 0);

            if(ok)
            {
                rep(i,Y)if(mask>>i&1) dp[mask] += b[X+i];
            }
        }

        rep(mask,1<<Y)rep(i,Y)if(!(mask>>i&1))
        {
            int nmask = mask|(1<<i);
            dp[nmask] = max(dp[nmask],dp[mask]);
        }

        int ans=0;
        // ?????????????????????????????¶
        for(int mask=1; mask<(1<<X); mask+=2)
        {
            bool ok=true;
            int val = 0;
            rep(i,X)if(mask>>i&1)
            {
                ok &= ((NG[i]&mask) == 0);
                val += b[i];
            }
            if(!ok) continue;

            int t=(1<<Y)-1;
            rep(i,X)if(mask>>i&1) t&=OK[i];

            ans = max(ans, val+dp[t]);
        }

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

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

int yi(int y) {
	int ans=0;
	for(int i=1; i<=y; i++) {
		if(y%i==0) ans++;
	}
	return ans;
}

int main() {
	int N,ans=0;
	cin>>N;
	for(int i=1; i<=N; i+=2) {
		if(yi(i)==8&&i%2==1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
	int a, b, t;
	cin >> a >> b >> t;
	int ans = t/a*b;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void) {
	int n,m,i;cin>>n>>m;
	vector<int>zyn;
	vector<vector<int>>go(n+1);
	vector<vector<int>>rev(n+1);
	vector<int>zi(n+1);
	for(i=0;i<m+n-1;i++){
		int u,v;cin>>u>>v;
		go[u].pub(v);
		rev[v].pub(u);
		zi[v]++;
	}
	queue<int>que;
	for(i=1;i<=n;i++){
		if(zi[i]==0){que.push(i);}
	}
	while(que.size()){
		int t=que.front();
		que.pop();
		zyn.pub(t);
		for(auto it:go[t]){
			zi[it]--;
			if(zi[it]==0){que.push(it);}
		}
		//cerr<<"de";
	}
	vector<int>ban(n+1,-1);
	for(i=0;i<n;i++){ban[zyn[i]]=i;}
	for(i=1;i<=n;i++){
		if(rev[i].size()==0){cout<<0<<endl;}
		else{
			int x=rev[i][0];
			for(auto it:rev[i]){
				if(ban[it]>ban[x]){x=it;}
			}
			cout<<x<<endl;
		}
	}
	
	return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

const MAX : usize = 100001;
const MOD : usize = 1e9 as usize + 7;

fn init_fact() -> (Vec<usize>, Vec<usize>, Vec<usize>) {
  let mut fac = vec![0; MAX];
  let mut inv = vec![0; MAX];
  let mut finv = vec![0; MAX];
  fac[0] = 1;
  fac[1] = 1;
  finv[0] = 1;
  finv[1] = 1;
  inv[1] = 1;
  for i in 2..MAX {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
  return (fac, inv, finv)
}

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let (fac, inv, _) = init_fact();
    let mut sum = vec![1; n];
    for i in 1..n {
        sum[i] = (sum[i-1] + inv[i+1]) % MOD;
    }

    let mut ans = 0;
    for i in 0..n {
        let a = aa[i];
        let s = (sum[i] + sum[n-i-1] - sum[0]) % MOD;
        ans = (ans + a * s % MOD) % MOD;
    }
    println!("{}", (fac[n] * ans) % MOD);
}


Measured memory_bytes: 8444
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%d",&i)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define 	mapp 	    map<char,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>s
#define 	set_it 	    set<int>::iterator si
#define     map_it      map<char,int> :: iterator mi
#define 	yes 	    cout<<"Yes"<<endl
#define 	no 	        cout<<"No"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          iNT_MAX
#define     lmx         LLONG_MAX
#define     mn          iNT_MiN
#define     lmn         LLONG_MiN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  // freopen ("(input).txt" , "r",  stdin) ;
   string st,stt ;
  // int low=0,high=0;
  // int l,r;
    int n,k,t,b,c,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>st;  ; vect v ,a  ; sett ; set_it ; mapp m,mp; pairr p; map_it;
    loop(i,st.size())
    {
        m[st[i]]++;
    }
    for(mi=m.begin();mi!=m.end();mi++)
    {
        temp=mi->ss;
        if(temp&1)
            cnt=1;
    }
    if(cnt==0)
        yes;
    else
        no;


}

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

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

int main(){
    int num_prob, num_ans;
    scanf("%d %d%*c", &num_prob, &num_ans);
    std::vector<bool> numAC(num_prob, false);
    std::vector<int> numWA(num_prob, 0);

    for(int i = 0; i < num_ans; i++){
        int target_prob;
        char ans;
        scanf("%d %c%*c", &target_prob, &ans);
        if(ans == 'A'){
            numAC[target_prob - 1] = true;
        }else{
            if(!numAC[target_prob - 1]) numWA[target_prob - 1]++;
        }
    }

    // calc
    int ACs = 0;
    int WAs = 0;
    for(int i = 0; i < num_prob; i++){
        if(numAC[i]){
            ACs++;
            WAs += numWA[i];
        }
    }

    printf("%d %d\n", ACs, WAs);

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
template <class T> int size(const T &x) { return x.size(); }
const int INF = 2147483647;
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)

vi adj[3000];

int n;
int count(int a, int k, ii bad) {
    vi dist(n,INF);
    dist[a] = 0;
    queue<int> Q;
    Q.push(a);
    while (!Q.empty()) {
        int cur = Q.front();
        Q.pop();
        iter(it,adj[cur]) {
            int nxt = *it;
            if (dist[nxt] != INF)
                continue;
            ii e(min(cur,nxt), max(cur,nxt));
            if (e == bad) continue;
            dist[nxt] = 1 + dist[cur];
            Q.push(nxt);
        }
    }
    int cnt = 0;
    rep(i,0,n) {
        if (dist[i] != INF && dist[i] > k) {
            cnt++;
        }
    }
    return cnt;
}

int main() {
    int k;
    cin >> n >> k;
    vii es;
    rep(i,0,n-1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
        es.push_back(ii(min(a,b),max(a,b)));
    }
    int mn = INF;
    if (k % 2 == 0) {
        rep(i,0,n) {
            mn = min(mn, count(i, k/2, ii(-1,-1)));
        }
    } else {
        iter(it,es) {
            mn = min(mn, count(it->first, k/2, *it) +
                         count(it->second, k/2, *it));
        }
    }
    cout << mn << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e15;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


signed main(){
  int n;
  cin>>n;
  map<int,int> mp;
  set<int> s;
  rep(i,n){
    int a;cin>>a;
    mp[a]++;
    s.insert(a);
  }
  int res=0;
  for(auto x:s){
    if(mp[x]%2==0){
      mp[x]=2;
    }else{
      mp[x]=1;
      res++;
    }
  }
  //cout<<res<<endl;
  // for(auto x:mp){
  //   cout<<x.first<<' '<<x.second<<endl;
  // }
  int two=0;
  for(auto x:s){
    if(mp[x]==2)two++;
  }
  //cout<<two<<endl;
  if(two%2==0){
    res+=two;
  }else{
    res+=(two/2)*2;
  }
  cout<<res<<endl;

 return 0;
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int N;

  cin >> N;
  if(N % 2 == 0){
cout << N / 2;
  }else{
    cout << N / 2 + 1;
  }
  cout << endl;
return 0;
}

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




typedef long long LL;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s; cin >> s;
  int a = stoi(s.substr(0, 2));
  int b = stoi(s.substr(2, 2));
  auto isM = [=](int a) { return a > 0 and a <= 12; };
  if (isM(a) and isM(b)) cout << "AMBIGUOUS\n";
  else if (isM(a)) cout << "MMYY\n";
  else if (isM(b)) cout << "YYMM\n";
  else cout << "NA\n";
}


Measured memory_bytes: 256
N, M = map(int, input().split())
km = []
for i in range(M):
    tmp = list(map(int, input().split()))
    kk = tmp[0]
    mm = [x-1 for x in tmp[1:]]
    km.append((kk, mm))
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    L = list(map(int, list(format(i, '0'+str(N)+'b'))))
    if all([sum([x for i, x in enumerate(L) if i in m[1]]) % 2 == p for m, p in zip(km, P)]):
        ans += 1
print(ans)

Measured memory_bytes: 46044
#include<iostream>
#include<cstdio>
#include<cstring>
#define INF 1000000000
using namespace std;
int v1[101000],v2[101000],val[100100],ans[101000];
int dep[101000];
int h[101000],nxt[201000],K=0,to[201000];
void ins(int u,int v){nxt[++K]=h[u];h[u]=K;to[K]=v;}
void dfs2(int x,int f)
{
	if(val[x]>=0)v1[x]=val[x],v2[x]=val[x];
	else v1[x]=-INF,v2[x]=INF;
	for(int i=h[x];i;i=nxt[i])
	{
		if(to[i]==f)continue;
		dfs2(to[i],x);
		if(v1[to[i]]==-INF)continue;
		if(v1[x]==-INF&&v2[x]==INF)
		{
			v1[x]=v1[to[i]]-1;
			v2[x]=v2[to[i]]+1;
		}
		else if(!((v1[x]^v1[to[i]])&1)){puts("No");exit(0);}
		else
		{
			v1[x]=max(v1[x],v1[to[i]]-1);
			v2[x]=min(v2[x],v2[to[i]]+1);
		}
	}
	if(v1[x]>v2[x]){puts("No");exit(0);}
}
void dfs3(int x,int f,int c)
{
	ans[x]=c;
	for(int i=h[x];i;i=nxt[i])
	{
		if(to[i]==f)continue;
		if(v1[to[i]]<=c-1&&c-1<=v2[to[i]])dfs3(to[i],x,c-1);
		else dfs3(to[i],x,c+1);
	}
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int a,b;scanf("%d%d",&a,&b);ins(a,b);ins(b,a);
	}
	int k;scanf("%d",&k);
	memset(val,-1,sizeof(val));
	for(int i=1;i<=k;i++)
	{
		int a,b;scanf("%d%d",&a,&b);val[a]=b;
	}
	dfs2(1,0);
	dfs3(1,0,v1[1]);
	puts("Yes");
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	int list[13];
};


signed main() {
	int i, j, n, sum = 0, cnt = 0;
	string s, s1, s2;
	bool flag = false;
	vector<int>list(26,0);

	int sum1 = 0, sum2 = 0;


	cin >> n;


	for (i = 0; i < n; i++) {
		string ss1, ss2;
		cin >> ss1 >> ss2;

		bool flag1 = false;

		for (j = 0; j < ss1.length() && j < ss2.length(); j++) {
			if (ss1[j] < ss2[j]) {
				sum2 += 3;
				flag1 = true;
				break;
			}
			else if (ss1[j] > ss2[j]) {
				sum1 += 3;
				flag1 = true;
				break;
			}
		}

		if (flag1 == false && ss1.length() > ss2.length()) {
			sum1 += 3;
		}
		else if (flag1 == false && ss1.length() < ss2.length()) {
			sum2 += 3;
		}
		else if (flag1 == false) {
			sum1++;
			sum2++;
		}

	}

	cout << sum1 << " " << sum2 << endl;





	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        int ans = 0;
        
        for (int i=1; i <= n; i++) {
            ans = i + ans;
        }
        System.out.print(ans);
    }

}


Measured memory_bytes: 21844
fun main(args: Array<String>) {

    /**
     * to:向き先
     * id:辺のID
     */
    data class Edge(val to: Int, val id: Int)


    // 頂点数
    val n = readLine()!!.toInt()

    /**
     * 次のようなグラフを作る
     * 1:[2]
     * 2:[1,3,4]
     * 3:[2]
     * 4:[2]
     */
    val graph: Array<MutableList<Edge>> = Array(n) {
        mutableListOf<Edge>()
    }

    // 頂点数-1回繰り返す
    repeat(n - 1) { i ->
        var (a, b) = readLine()!!.split(" ").map(String::toInt)
        a--
        b--
        graph[a].add(Edge(b, i))
        graph[b].add(Edge(a, i))
    }

    val ans = IntArray(n - 1)

    /**
     * v:頂点
     * p:どこからきたか
     */
    fun dfs(v: Int, color: Int, parent: Int) {
        var k = 1
        for (i in graph[v].indices) {
            val (to, edgeId) = graph[v][i]
            // 辺の向き先が親だった場合は、スキップする
            if (to == parent) {
                continue
            }

            // 親と同じ色だったらインクリメントする
            if (k == color) {
                k++
            }

            // idのところに解答を設定する
            ans[edgeId] = k
            k++
            dfs(to, ans[edgeId], v)
        }
    }

    dfs(0, -1, -1)
    ans.max()!!.let(::println)
    ans.forEach(::println)
}



Measured memory_bytes: 83436
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m // gcd(n,m)


n,m = LI()
a = LI()
b = [i//2 for i in a]

lb = 1
for i in b:
    lb = lcm(lb,i)
    if lb > m:
        print(0)
        quit()

for i in b:
    if lb//i % 2 == 0:
        ans = 0
        break
else:
    if lb > m:
        ans = 0
    else:
        ans = (m//lb + 1)//2
print(ans)


Measured memory_bytes: 60004
N,K=map(int,input().split())
MOD=10**9+7

def main():
  t=0
  for k in range(K,N+2):
    s=k*~-k//2
    m=k*(2*N-k+1)//2
    t=(t+m-s+1)%MOD

  print(t%MOD)

main()


Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
using ll = long long;
using ld = long double;

int main()
{
    ll N;
    cin >> N;

    if ( N < 10 )
    {
        cout << "Yes" << endl;
        return 0;
    }

    ll n = N;
    int sum = 0;

    while ( n > 0 )
    {
        sum += n % 10;
        n /= 10;
    }

    cout << ( N % sum == 0 ? "Yes" : "No" ) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys


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


def resolve():
    n, k = map(int, input().split())
    from itertools import accumulate
    A = list(map(int, input().split()))
    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成
    num=0
    val=0
    # この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り
    for i in range(k, n + 1):
        if B[i]-B[i-k]>val:
            val=B[i]-B[i-k]
            num=i

    ans = 0
    for j in A[num-k:num]:
        ans += (0.5 * j * (1 + j)) / j
    print(ans)
resolve()

Measured memory_bytes: 75204