akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m,tot,cnt;
int a[100005],v[200005],nxt[200005],id[200005],h[100005],du[100005];
bool used[100005],vis[100005];

void addedge(int x,int y,int z){
	v[++tot]=y; nxt[tot]=h[x]; id[tot]=z; h[x]=tot;
	v[++tot]=x; nxt[tot]=h[y]; id[tot]=z; h[y]=tot;
}

void dfs(int u){
	for(int &p=h[u];p;p=nxt[p]){
		int t=p;
		if(used[id[t]]) continue;
		used[id[t]]=1;
		dfs(v[t]);
		a[++cnt]=v[t];
	}
}

int main(){
	n=readint(); m=readint();
	int x,y;
	for(int i=1;i<=m;i++){
		x=readint(); y=readint();
		du[x]++,du[y]++;
		addedge(x,y,i);
	}
	for(int i=1;i<=n;i++) if(du[i]&1) return printf("No\n"),0;
	int rt=0,maxa=0;
	for(int i=1;i<=n;i++) if(chkmax(maxa,du[i])) rt=i;
	if(du[rt]>=6) return printf("Yes\n"),0;
	if(du[rt]==2) return printf("No\n"),0;
	dfs(rt);
	reverse(a+1,a+cnt+1);
	int lst=1;
	for(int i=1;i<=cnt;i++){
		if(a[i]==rt) memset(vis,0,sizeof(vis));
		else if(vis[a[i]]) return printf("Yes\n"),0;
		else vis[a[i]]=1;
	}
	int pl=0,kcnt=0;
	memset(vis,0,sizeof(vis));
	for(int i=1;i<cnt;i++) if(a[i]==rt) pl=i;
	for(int i=1;i<pl;i++) vis[a[i]]=1;
	for(int i=pl+1;i<cnt;i++) if(vis[a[i]]) kcnt++;
	if(kcnt>=2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 7040
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

sys.setrecursionlimit(10**9)

#メモ化再帰
def rec(x):
    global dp
    if dp[x]!=-1:
        return dp[x]
    num = 0
    for a in adj[x]:
        num = max(num, rec(a)+1)
    dp[x] = num
    return num

#入力受け取り
N, M = mi()
x = li2(M)

#隣接リスト作成
adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])

#メモ化再帰を実行
dp = [-1]*N
for i in range(N):
    rec(i)

print(max(dp))

Measured memory_bytes: 143752
#include<bits/stdc++.h>
using namespace std;
int n;
long i,j,w;
long long F[200][100005],v[200],W[200];
int main()
{
   cin>>n>>w;

  for (i=1;i<=n;i++)
    cin>>W[i]>>v[i];
    for (i=1;i<=n;i++)
       for (j=1;j<=w ;j++)
          if (W[i]<=j)
             F[i][j]=max(F[i-1][j],(F[i-1][j-W[i]]+v[i]));
          else
             F[i][j]=F[i-1][j];
   cout<<F[n][w];


}


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

int main() {
    int N,cnt = 0;
    cin >> N;

    long long  L[N+1];

    for (int i = 1 ; i<=N ; i++) {
        cin >> L[i];
    }

    for (int i = 1 ; i<=N; i++) {
        for (int j = 2; j<=N ; j++) {
            for (int k =3 ; k<=N ; k++) {
                if (L[i] != L[j] && L[j] != L[k] && L[i] != L[k]
                    && k > j && j > i) {
                    if (L[i] > L[j] && L[i] > L[k]) {
                        if (L[i] < L[j] + L[k]){
                            cnt++;
                        }
                    }
                    else if (L[j] > L[i] && L[j] > L[k]) {
                        if (L[j] < L[i] + L[k]){
                            cnt++;
                        }
                    }
                    else if (L[k] > L[i] && L[k] > L[j]) {
                        if (L[k] < L[i] + L[j]){
                            cnt++;
                        }
                    }
                }
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3616
n = int(input())
s = 0
x = []
y = []
if n == 2:
  l = 1
elif n == 3:
  l = 3
else:
  l = n*(n-1)/2
for i in range(0,n):
	a, b = map(int, input().split())
	x.append(a)
	y.append(b)
for i in range(0,n):
	for j in range(i,n):
		s += ((x[i] - x[j])**2 + (y[i] - y[j])**2)**(1/2)
ans = (n - 1)*s/l
print(ans)

Measured memory_bytes: 3188
import sys

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


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M, *AB = map(int, read().split())
uf = UnionFind(N)
ans = [N * (N - 1) // 2]

for a, b in zip(AB[-2:0:-2], AB[-1:1:-2]):
    a -= 1
    b -= 1
    if uf.same(a, b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - uf.parents[uf.find(a)] * uf.parents[uf.find(b)])
        uf.union(a, b)

print(*reversed(ans), sep='\n')


Measured memory_bytes: 25076
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto & e : v) cin >> e;
    int cnt = v.front();
    for(size_t i = 1; i < v.size(); ++i){
        if(i % 2) cnt -= v[i];
        else cnt += v[i];
    }
    vector<int>ans;
    ans.push_back(cnt / 2);
    cnt /=2;
    for(size_t i = 0; i < v.size() - 1; ++i){
        ans.push_back((v[i] - cnt));
        cnt = ans.back();
    }
    int t = 0;
    for(auto e : ans){
        if(t++)cout << " ";
        cout << e * 2;
    }
    cout << endl;
}


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

using ll = long long;

int X, Y, Z, K;
vector<ll> A, B, C;

void solve1() {
    vector<ll> E(X*Y);
    int e = 0;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            E[e++] = A[i] + B[j];
        }
    }
    sort(E.begin(), E.end(), greater<ll>());
    int lim = min((int)E.size(), K);
    vector<ll> EC(lim*Z);
    int ec = 0;
    for (int i = 0; i < lim; i++) {
        for (int j = 0; j < Z; j++) {
            EC[ec++] = E[i] + C[j];
        }
    }
    sort(EC.begin(), EC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << EC[i] << endl;
    }
}

void solve1a() {
    if (X > K) {
        sort(A.begin(), A.end(), greater<ll>());
    }
    if (Y > K) {
        sort(B.begin(), B.end(), greater<ll>());
    }
    int lim_a = min(K, X);
    int lim_b = min(K, Y);
    vector<ll> E(lim_a * lim_b);
    int e = 0;
    for (int i = 0; i < lim_a; i++) {
        for (int j = 0; j < lim_b; j++) {
            E[e++] = A[i] + B[j];
        }
    }
    sort(E.begin(), E.end(), greater<ll>());
    int lim_e = min((int)E.size(), K);
    vector<ll> EC(lim_e*Z);
    int ec = 0;
    for (int i = 0; i < lim_e; i++) {
        for (int j = 0; j < Z; j++) {
            EC[ec++] = E[i] + C[j];
        }
    }
    sort(EC.begin(), EC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << EC[i] << endl;
    }

}

void solve2() {
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> E;
    for (int i = 0; i < X; i++) {
        int j_lim = min(Y, K / (i+1));
        for (int j = 0; j < j_lim; j++) {
            int k_lim = min(Z, K / ((i+1) * (j+1)));
            for (int k = 0; k < k_lim; k++) {
                E.push_back(A[i] + B[j] + C[k]);
            }
        }
    }

    sort(E.begin(), E.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << E[i] << endl;
    }
}

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    
    cin >> X >> Y >> Z >> K;
    A.resize(X); for (auto& a : A) cin >> a;
    B.resize(Y); for (auto& b : B) cin >> b;
    C.resize(Z); for (auto& c : C) cin >> c;

    solve2();
}


Measured memory_bytes: 1404
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

#define ull unsigned long long
void solve() {
  int n;cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  int min_ = 100000000;
  for (auto&&a: A) {
    int count=0;
    while (a%2==0) count++,a/=2;
    min_ = min(min_, count);
  }
  cout << min_ << endl;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}


// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main(){
    char c;
    cin >> c;
    
    if(c=='A'){
        cout << "T" <<endl;
    }else if(c=='T'){
        cout << "A" <<endl;
    }else if(c=='C') {
        cout << "G" << endl;
    }else{
        cout << "C" <<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
#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 rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

signed main()
{
	set<string> se;
	int n;cin>>n;
	rep(_,n){
		string s;cin>>s;
		se.insert(s);
	}
	cout<<se.size()<<endl;
}



Measured memory_bytes: 15672
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int unsigned long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;

int power(int x, int y, int p)
{
    int res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
         y = y>>1; 
        x = (x*x) % p;
    }
    return res;
}

int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
 


void solve()
  {

	int n;
	cin>>n;
	int a[n];
	int sum[n],ans=0LL;
	rep(i,n){cin>>a[i];sum[i]=0LL;sum[i]+=a[i];if(i)sum[i]+=sum[i-1];}
	rep(i,n)
	{
		int val=((a[i]%hell)*(long long)((sum[n-1]-sum[i])%hell))%hell;
		ans+=val;
		ans%=hell;
	}
	
	cout<<ans;
  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}
	

Measured memory_bytes: 6788
import java.util.*;

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

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] -= sc.nextInt();
            if (x[i] > 0) sum += x[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
//package atcoder.beginner144;

import java.io.*;
import java.util.*;

public class Main {
    private static List<Integer>[] paths;
    private static double[] dp;
    private static int N, M;
    private static double ans;

    public static void main(String[] args) {
       // try {
        //    FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
         //   PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

            solve(in, out);

       // }
       // catch (IOException e) {
         //   e.printStackTrace();
        //}
    }

    private static void input(FastScanner in, PrintWriter out) {
        N = in.nextInt();
        M = in.nextInt();
        paths = new List[N + 1];
        dp = new double[N + 1];

        for(int i = 1; i <= N; i++) {
            paths[i] = new ArrayList<>();
        }
        for(int i = 0; i < M; i++) {
            int s = in.nextInt(), t = in.nextInt();
            paths[s].add(t);
        }
    }

    private static void f(int block) {
        dp[N] = 0;
        for(int i = N - 1; i >= 1; i--) {
            double sum = 0.0;
            double maxAdj = 0.0;
            int num = paths[i].size();
            for(int j : paths[i]) {
                sum += dp[j];
                maxAdj = Math.max(maxAdj, dp[j]);
            }
            if(i == block && num > 1) {
                num--;
                sum -= maxAdj;
            }
            dp[i] = sum / num + 1;
        }
        ans = Math.min(ans, dp[1]);
    }

    private static void solve(FastScanner in, PrintWriter out) {
        input(in, out);
        ans = Double.MAX_VALUE;
        for(int i = 0; i < N; i++) {
            f(i);
        }
        out.println(ans);
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




Measured memory_bytes: 50928
#include <iostream>

using namespace std;

int main() {
  int W, H;
  int N;
  int p;
  cin >> W >> H;
  cin >> N;
  int outer = 0;
  int inner = 0;
  int border = 0;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    cin >> p;
    if (p == 0) {
      outer += 1;
    } else {
      inner += 1;
    }
    if (outer >= W * 2 + H - 6) {
      continue;
    }
    if (inner >= W * 2 + H - 6) {
      continue;
    }
    if (border == 0 && outer == W - 1) {
      border = 1;
      outer -= 2;
    }
    if (border == 1 && outer == W + H - 4) {
      border = 2;
      outer -= 2;
    }
    if (inner == outer && (border == 0 || border == 1 && inner >= W - 2 || border == 2 && inner >= W + H - 5)) {
      cnt += 1;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3100
function Main(input) {
    const N = parseInt(input[0]);
    const Q = parseInt(input[1]);
    const S = input[2];
    
    var ctArr = Array(N);
    ctArr[0] = 0;
    for(var i = 1; i < N+1; i++) {
        ctArr[i] = ctArr[i-1] + ((S[i-1] == 'A' && S[i] == 'C') ? 1 : 0);
    }

    var ret = "";
    for(var i = 0; i < Q; i++) {
        var l = input[i*2+3];
        var r = input[i*2+4];
        ret += ctArr[r-1] - ctArr[l-1] + "\n";
    }
    console.log(ret);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));


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

int main()
{
	int a1,a2,a3,ans;
	
	cin >> a1 >> a2 >> a3;
	
	ans= abs(a1-a2)+abs(a2-a3);
	if(ans > abs(a1-a3)+abs(a2-a3)) ans= abs(a1-a3)+abs(a2-a3);
	if(ans > abs(a1-a2)+abs(a1-a3)) ans= abs(a1-a2)+abs(a1-a3);
	
	cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define alp "abcdefghijklmnopqrstuvwxyz"

int main() {
	string A;
	cin >> A;
	ll l = A.length();
	ll ans = l * (l - 1) / 2 + 1;
	for (auto c : alp) {
		ll count = 0;
		for (auto a : A) count += a == c ? 1 : 0;
		ans -= count * (count - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
using System;

namespace abc123
{
    class A
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());

            if (e - a > k)
            {
                Console.WriteLine(":(");
                return;
            }
            Console.WriteLine("Yay!");

        }
    }
}


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

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

using namespace std;
using ll = long long;

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

    ll a,b,c;
    ll d;
    cin >> a >> b >> c;
    d = c-a-b;
    if(d > 0 && 4*a*b < d*d ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

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

int div_times(ll a, int n) {
    int count = 0;
    while (a % n == 0) {
        a /= n;
        count += 1;
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += div_times(a[i], 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

int main(void){
    ll a,b,c;
    cin>>a>>b>>c;
    ll ngo = a%b;
    while(ngo != c && ngo != 0){
        ngo = (ngo+a)%b;
    }
    if(ngo==c) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split(" ")))
denkyus = []
for _ in range(M):
    denkyus.append(list(map(int,input().split(" ")[1:])))

ps  = list(map(int,input().split(" ")))
ans = 0
for i in range(2 ** N):
    temp = [0] * M
    for j in range(0,N): #スイッチを押していく
        if ((i >> j) & 1): #スイッチjが押されている状態ならスイッチを押す
            for di,denkyu in enumerate(denkyus):
                if j+1 in denkyu:
                    temp[di] +=1

    for pind,p in enumerate(ps):
        flag = True
        if temp[pind] %2 != p:
            flag = False
            break
    if flag:
        ans += 1
print(ans)










Measured memory_bytes: 42480
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

struct t{
  double x;
  double y;
};

int main(){

  int n,i,count=1;
  struct t v[55];

  while(scanf("%d", &n), n!=0){

    double ans = 0.0;
    for(i = 0; i < n; i++){
      cin >> v[i].x >> v[i].y;
    }

    v[n].x = v[0].x;
    v[n].y = v[0].y;

    for(i = 0; i < n; i++){
      ans += (v[i].x*v[i+1].y - v[i+1].x*v[i].y);
    }
    printf("%d %.1f\n", count++, fabs(ans/2));
  }
  return 0;
}


Measured memory_bytes: 3224
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define FR first
#define SE second
using namespace std;
typedef pair<int,int> pr;
typedef long long ll;
const int maxn = 300 + 10;
const int MOD = 1000000007;

int n, m;
vector<pr> a[maxn];
ll dp[maxn][maxn][maxn];

inline int check(int x, int y, int z) {
  int k = max(x,max(y,z));
  int Sz = a[k].size();
  for(int i = 0;i < Sz;i ++) {
    int l = a[k][i].FR, tmp = a[k][i].SE, now = 0;
    if(x >= l) now ++;
    if(y >= l) now ++;
    if(z >= l) now ++;
    if(now != tmp) return 0;
  }
  return 1;
}

int main() {
  scanf("%d%d", &n, &m);
  for(int i = 1;i <= m;i ++) {
    int x, y, z; scanf("%d%d%d", &x, &y, &z);
    a[y].push_back(make_pair(x,z));
  }
  ll ans = 0;
  dp[0][0][0] = 1;
  for(int x = 0;x <= n;x ++) {
    for(int y = 0;y <= n;y ++) {
      for(int z = 0;z <= n;z ++) {
      	if(dp[x][y][z] == 0) continue;
      	if(!check(x,y,z)) {
      	  dp[x][y][z] = 0;
      	  continue;
		}
		int k = max(x,max(y,z)) + 1;
		if(k == n + 1) ans = (ans + dp[x][y][z]) % MOD;
		dp[k][y][z] = (dp[k][y][z] + dp[x][y][z]) % MOD;
		dp[x][k][z] = (dp[x][k][z] + dp[x][y][z]) % MOD;
		dp[x][y][k] = (dp[x][y][k] + dp[x][y][z]) % MOD;
      }
	}
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  ll a, b, n; cin >> a >> b >> n;
  ll ans = (a * min(n, b - 1)) / b;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
h,w,d=map(int,input().split())
k=[[[]]*((h*w)//d+1 if (h*w)%d>i else (h*w)//d )for i in range(d)]
r=[[0]*((h*w)//d+1 if (h*w)%d>i else (h*w)//d )for i in range(d)]
for i in range(h):
    s=list(map(int,input().split()))
    for j in range(w):
        p=s[j]
        k[d-1 if p%d==0 else p%d-1][(p-1)//d]=[i,j]
for i in range(d):
    for s in range(1,len(k[i])):
        r[i][s]=r[i][s-1]+abs(k[i][s][1]-k[i][s-1][1])+abs(k[i][s][0]-k[i][s-1][0])
for i in range(int(input())):
    s,t=map(int,input().split())
    print(r[d-1 if t%d==0 else t%d-1][(t-1)//d]-r[d-1 if s%d==0 else s%d-1][(s-1)//d])

Measured memory_bytes: 30580
#include<bits/stdc++.h>
#define int long long int
const int mod=1e9+7;
#define fastinout     ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int imod(int a, int m)
{
    return power(a, m - 2, m);
}

void myfun()
{
	int n,i,a,b,c,d,m;
	int arr[4];
	cin>>a>>b>>c>>d;
	arr[0]=a*c;
	arr[1]=a*d;
	arr[2]=b*c;
	arr[3]=b*d;
	sort(arr,arr+4);
	cout<<arr[3];
	
}

signed main()
{
	 fastinout;
	int t=1;
	//cin>>t;
	while(t--)
	myfun();
	return 0;
}

Measured memory_bytes: 3652
a=input()
for op1 in ["+","-"]:
  for op2 in ["+","-"]:
    for op3 in ["+","-"]:
      if eval(a[0]+op1+a[1]+op2+a[2]+op3+a[3])==7:
        ans=a[0]+op1+a[1]+op2+a[2]+op3+a[3]+"=7"
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  cin >> N;
  int d[N];
  rep(i,N) cin >> d[i];
  int ans=0;
  for(int i=0;i<N;i++) for(int j=i+1;j<N;j++) ans+=d[i]*d[j];
  cout << ans << endl;
}

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

const int N = 1e5 + 5;
int n, x[N], y[N], t[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i] >> x[i] >> y[i];
		long long a = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		long long b = t[i] - t[i - 1];
		if (a <= b && b % 2 == a % 2) {
			continue;
		}
		cout << "No\n"; return 0;
	}
	cout << "Yes\n";
}

Measured memory_bytes: 1408
#include<stdio.h>

int n,A[100000];

int main() {
  int i,q,key,answer=0;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++) {
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i = 0 ; i < q ; i++) {
    scanf("%d",&key);
    if(binarySearch(key))
      answer++;
  }
  printf("%d\n",answer);
  return 0;
}

int binarySearch(int key) {
  int left=0,right=n,mid=0;

  while(left < right) {
    mid = (left + right) / 2;
    if(A[mid] == key) return 1;
    else if(key < A[mid]) right = mid;
    else left = mid +1;
  }
  return 0;
}



Measured memory_bytes: 2152
/*  ex3_3
    B30095    */
#include <stdio.h>
 
int main(void){
    int num, base, numOfDigits = 0;
    scanf("%d %d", &num, &base);
 
    while(num != 0){  // ends when it has reached the most significant digit
        num /= base;
        numOfDigits++;
    }
 
    printf("%d", numOfDigits);
 
    return 0;
}

Measured memory_bytes: 128
T = str(input())
T=list(T)
if not T[0]=='?':
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)-1]=='?':
        T[len(T)-1]='D'
else:
    T[0]='D'
    for i in range(1,len(T)-1):
        if T[i]=='?':
            if T[i-1]=='D' and T[i+1]=='D':
                T[i]='P'
            else:
                T[i]='D'
    if T[len(T)-1]=='?':
        T[len(T)-1]='D'

print(''.join(T))

Measured memory_bytes: 10640
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const int MOD = 1000000007;
    ll n; 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 
vector<ll> reis(100010);
 

int main() {

    std::cin >> n;
    vector<ll> x(n);
    COMinit();
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
    }
    
    ll sum = 0;
    
    ll tmp = 0;
    
    for (int i = 0; i < n; i++) {
        reis[i] = fac[n-1]*inv[i]%MOD+tmp;
        reis[i]%=MOD;
        tmp = reis[i];
    }
    
    for (int i = 0; i < n-1; i++) {
        sum+=(x[i+1]-x[i])%MOD*reis[i+1]%MOD;
        sum%=MOD;

        // std::cout << sum << std::endl;
    }
    
    std::cout << sum%MOD << std::endl;
}

Measured memory_bytes: 13824
#include<iostream>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;


int main()
{
	int X, A, B;

	cin >> X >> A >> B;

	if (B <= A) {
		cout << "delicious" << endl;
	}
	else if (B <= A + X) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>

#define ELIF else if
#define FOR(iterator, limit, adder) for(int iterator=0; iterator<limit; iterator+=adder)
#define PI 3.1415926535897932384626433832795
#define PB push_back

typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef long long ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, y, tc=0, fc=0, oc= 0;
    cin>> n>> y;
    if(n*1000>y || n*10000<y)
    {
        tc= -1;
        oc= -1;
        fc= -1;
    }
    else
    {
        int tem= y/1000;
        int p= tem-n;
        while(1)
        {
            if(!(p%4) && (p/4)+tc<=n) break;
            p-=9;
            tc++;
            if(p<0)
            {
                tc= -1;
                oc= -1;
                fc= -1;
                break;
            }
        }
        if(!fc && n-tc) fc= p/4;
        if(!oc && n-tc-fc) oc= n-tc-fc;
    }
    cout<< tc<< " "<< fc<< " "<< oc<< "\n";
    
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int N, i, j, alt;
	float v[50];
	
	scanf("%d", &N);
	lop(i, N){
		scanf("%f", &v[i]);
	}
	
	lop(i, N){
		for(j=N-1; j>i; j--){
			if(v[j]<v[j-1]){
			alt=v[j-1];
			v[j-1]=v[j];
			v[j]=alt;
			}
		}
	}
	
	lop(i, N-1){
		v[i+1]=(v[i]+v[i+1])/2;
	}
	
	printf("%f", v[N-1]);
	
return 0;
}

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

int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> v;
  
  int maxval = min(a, b);
  for(int i=1; i<=maxval; i++)
  {
    if(a % i == 0 && b % i == 0)
      v.push_back(i);
  }
  
  cout << v[v.size()-k] << endl;
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long H,W;
  cin>>H>>W;
  long long ans;
  if(H==1 || W==1){
    cout<<1<<endl;
      return 0;
  }
  if(H%2==0 || W%2==0){
    ans=H*W/2;
  }else{
    ans=(H*W+1)/2;
  }
  cout<<ans<<endl;
}

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

int main() {
  int a;
  cin >> a;
  if (a < 1200) {
    cout << "ABC" << endl;
  }
  else if (a < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
class SegTree:
    def __init__(self, init_val, n, ide_ele, seg_func):
        self.segfunc = seg_func
        self.num = 2**(n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg=[self.ide_ele]*2*self.num
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i]    
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        # k+1ではなくkでは？
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res

import sys;input=sys.stdin.readline
N, K = map(int, input().split())
X = []
for _ in range(N):
    a, = map(int, input().split())
    X.append(a)
mX = max(X)
ss = SegTree([0] * (mX+1), mX+1, -1, max)
for i in range(N):
    x = X[i]
    t = ss.query(max(x-K, 0), min(x+K+1, mX+1))
#    print(x, 1+t, max(x-K, 0), min(x+K+1, mX))
    ss.update(x, 1+t)
print(ss.query(0, mX+1))


Measured memory_bytes: 121836
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;

const int N = 5000 + 3;
const int inf = 1e9;


bool d1[N][N], d2[N][N];
int n, k;
int cnt;
int a[N];
int sum[N];
bool ok(int fr, int to)
{
    if(fr == 0){
        return sum[to];
    }
    else return sum[to] - sum[fr-1];
}
int main()
{


    SCC(n, k); int big = 0;
    FF(i, 1, n)
    {
        int x; SC(x);
        if(x >= k) ++big;
        else a[++cnt] = x;
    }
    d1[0][0] = 1;
    FF(i, 1, cnt)
    {
        FF(j, 0, k)
        {
            d1[i][j] = d1[i-1][j];
            if(j>=a[i]) d1[i][j] = d1[i][j] || d1[i-1][j-a[i]];
        }
    }
    d2[cnt+1][0] = 1;
    RR(i, cnt, 1)
    {
        FF(j, 0, k)
        {
            d2[i][j] = d2[i+1][j];
            if(j>=a[i]) d2[i][j] = d2[i][j] || d2[i+1][j-a[i]];
        }
    }
    ///
    int nece = 0;
    FF(i, 1, cnt)
    {
        int l = k-a[i], r = k-1;
        sum[0] = 1;
        FF(j, 1, k){
            int add = 0;
            if(d2[i+1][j]) add = 1;
            sum[j] = sum[j-1]+add;
        }
        FF(j, 0, k-1)
        {
            if(!d1[i-1][j]) continue;
            int fr = max(l-j, 0), to = r-j;
            if(ok(fr, to)){
                ++nece;
                break;
            }
        }
    }
    PR(n-big-nece);
    return 0;
}


Measured memory_bytes: 49152
#include <iostream>
#include <climits>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	int m,n,a,b,cost;
	while(cin >> m >> n) {
		if(m==0 && n==0) break;
		int adj[110][110] = {};
		rep(i,m) {
			rep(j,m) {
				if(i==j) continue;
				adj[i][j] = INT_MAX;
			}
		}
		rep(i,n) {
			cin >> a >> b >> cost;
			adj[a][b] = cost;
			adj[b][a] = cost;
		}
		bool used[100] = {};
		int cost[100];
		fill(cost,cost+100,INT_MAX);
		cost[0] = 0;
		int ret = 0;
		while(1) {
			int v = -1;
			rep(i,m) {
				if(!used[i] && (v == -1 || cost[v] > cost[i])) {
					v = i;
				}
			}
			if(v == -1) break;
			used[v] = true;
			ret += cost[v];
			rep(i,m) {
				cost[i] = min(cost[i], adj[v][i]);
			}
		}
		cout <<  ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N >> K;
  ans = 0;
  if (K%2==1) {
  	cout << (N/K) * (N/K) *(N/K) << endl;
    return 0;
  }
  else {
  	ans += (N/K)*(N/K)*(N/K);
    ans += ((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K);
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<sstream>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include <type_traits>
using namespace std;
typedef long long unsigned llu;
int main()
{
    llu x;
    cin >> x;
    llu m = 100;
    int n = 0;
    while(m < x)
    {
        m += m / 100;
        n++;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

const int MAX = 501;
bool data[MAX];

vector<int> V[MAX];

void solve(){
  for(int i = 0; i < V[1].size(); i++){
    data[V[1][i]] = true;
    for(int j = 0; j < V[V[1][i]].size(); j++)
      data[V[V[1][i]][j]] = true;
  }

  int ans = 0;

  for(int i = 2; i < MAX; i++)
    if(data[i]) ans++;
  cout << ans << endl;
}


void init(){
  fill(data,data+MAX,false);
  for(int i = 0; i < MAX; i++)
    V[i].clear();
}
int main(){

  int n,m;
  while(cin >> n >> m && n+m){
    init();

    while(m--){
      int a,b;
      cin >> a >> b;
      V[a].push_back(b);
      V[b].push_back(a);
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

//int tx[] = {0,1,0,-1};
//int ty[] = {-1,0,1,0};

const int tx[] = {0,1,1,0};
const int ty[] = {0,0,1,1};

static const double EPS = 1e-8;

void flipStage(int px,int py,int stage[5][5],int _count=1){
	//px:0,1,2,3
	//py:0,1,2,3
	//px:0,py:0
	if(py < 0) return;

	for(int c=0;c<_count;c++){
		for(int i=0;i<4;i++){
			int dx = px + tx[i];
			int dy = py + ty[i];
			if(stage[dy][dx] == 0) continue;

			stage[dy][dx] %= 4;
			stage[dy][dx]++;
		}
	}
}

int calcStage(int stage[5][5]){
	const int point[] = {0,60,70,80};

	int sum = 0;
	for(int y=0;y<5;y++){
		for(int x=0;x<5;x++){
			if(stage[y][x] == 0) continue;
			sum += point[stage[y][x]-1];
		}
	}
	return sum;
}

int calcLine(int stage[5][5],int y){
	const int point[] = {0,60,70,80};

	int sum = 0;
	for(int x=0;x<5;x++){
		if(stage[y][x] == 0) continue;
		sum += point[stage[y][x]-1];
	}
	return sum;
}

int dp[6][256];

int main(){
	int N;
	while(~scanf("%d",&N)){
		if(N==0) break;
		for(int i=0;i<N;i++){
			int stage[5][5];
			memset(stage,0,sizeof(stage));

			for(int y=0;y<5;y++){
				for(int x=0;x<5;x++){
					int num;
					scanf("%d",&num);
					stage[y][x] = num;
				}
			}

			memset(dp,0,sizeof(dp));

			for(int y=0;y<4;y++){

				for(int S1=0;S1<256;S1++){
						int tmp1 = S1;
						int pos1 = 0;
						int tmp1_stage[5][5];
						memcpy(tmp1_stage,stage,sizeof(stage));

						while(tmp1 > 0){
							int c = tmp1 % 4;
							tmp1 /= 4;
							int x = pos1++;
							flipStage(x,y-1,stage,c);
						}

					for(int S2=0;S2<256;S2++){
						int tmp2 = S2;
						int pos2 = 0;
						int tmp2_stage[5][5];
						memcpy(tmp2_stage,stage,sizeof(stage));

						while(tmp2 > 0){
							int c = tmp2 % 4;
							tmp2 /= 4;

							int x = pos2++;
							flipStage(x,y,stage,c);
						}

						int score = calcLine(stage,y);
						if(y==3) score+=calcLine(stage,y+1);

						dp[y+1][S2] = max(dp[y][S1]+score,dp[y+1][S2]);

						memcpy(stage,tmp2_stage,sizeof(tmp2_stage));
					}
					memcpy(stage,tmp1_stage,sizeof(tmp1_stage));
				}
			}

			int res = 0;
			for(int S=0;S<256;S++){
				res = max(dp[4][S],res);
			}

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

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

int main()
{
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }
}

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

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

    int out = 0;
    int tmp = 0;
    int now; cin >> now;
    for (int i = 1; i < n; i++) {
        int next; cin >> next;
        if (now >= next) {
            if (++tmp > out) out = tmp;
        } else {
            tmp = 0;
        }
        now = next;
    }

    cout << out << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int n,m;
int main(){
	in(n);
	out(24-n+24);
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int n,p[200005],q[200005];
long long a[200005],f[200005],ans=1000000000000000;
long long solve(int l,int r){return f[r]-f[l-1];}
long long make(int k1,int k2,int k3)
{
	if (!((1<=k1)&&(k1<k2)&&(k2<k3)&&(k3<n))) return 1000000000000000;
	long long xx=std::max(std::max(std::max(solve(1,k1),solve(k1+1,k2)),solve(k2+1,k3)),solve(k3+1,n));
	long long yy=std::min(std::min(std::min(solve(1,k1),solve(k1+1,k2)),solve(k2+1,k3)),solve(k3+1,n));
	return xx-yy;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++) f[i]=f[i-1]+a[i];
	int k=1;
	p[1]=1;
	for (int i=2;i<=n;i++)
	{
		while (solve(1,k)<solve(k+1,i)) ++k;
		p[i]=k;
	}
	k=n;
	q[n]=n;
	for (int i=n-1;i>=1;i--)
	{
		while (solve(k,n)<solve(i,k-1)) --k;
		q[i]=k;
	}
	for (int i=1;i<=n;i++)
	{
		ans=std::min(ans,make(p[i],i,q[i+1]-1));
		ans=std::min(ans,make(p[i]-1,i,q[i+1]-1));
		ans=std::min(ans,make(p[i],i,q[i+1]));
		ans=std::min(ans,make(p[i]-1,i,q[i+1]));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6420