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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main()
{
    int N;
    scanf("%d",&N);
    
    int a[N];
    
    int MAX_OF_A=0;
    
    for(int i=0;i<N;i++)
    {
        scanf("%d",&a[i]);
    }
    
    bool answer_key = false;
    
    int key = 1;
    
    for(int i=0;i<N;i++)
    {
        if(a[i] == key)
        {
            key++;
        }
    }
    
    if(key==1)
    {
        printf("-1");
    }
    else
    {
        printf("%d",N-key+1);
    }
    
    return 0;
}

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

int main() {
    int orders[5];
    rep(i, 5) cin >> orders[i];

    int last = 0;
    int min = 10;
    for(int i=0; i<5; i++) {
        int temp;
        if(!(orders[i]%10)) continue;
        temp = orders[i] - int(orders[i]/10)*10;
        if(temp < min) {
            last = i;
            min = temp;
        }
    }

    int sum = 0;
    rep(i, 5) {
        if(i == last) continue;
        int temp;
        if(orders[i]%10) {
            temp = int(orders[i]/10 + 1) * 10;
        } else {
            temp = orders[i];
        }
        sum += temp;
    }
    sum += orders[last];

    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 100005
using namespace std;
char A[M];
int Ans[M],sum1[M],sum2[M];
int main(){
	scanf("%s",A+1);
	int n=strlen(A+1);
	for(int i=1;i<=n;i++){
		if(A[i]=='L')sum1[i]++;
		if(A[i]=='R')sum2[i]++;
		sum1[i]+=sum1[i-1];
		sum2[i]+=sum2[i-1];
	}
	for(int i=1;i<=n;i++){
		if(A[i]=='L'){
			int l=1,r=i,ans=1;
			while(l<=r){
				int mid=(l+r)>>1;
				if(sum2[i]-sum2[mid-1]>0)ans=mid,l=mid+1;
				else r=mid-1;
			}
			if((i-ans)&1)Ans[ans+1]++;
			else Ans[ans]++;
		}
		else {
			int l=i,r=n,ans=n;
			while(l<=r){
				int mid=(l+r)>>1;
				if(sum1[mid]-sum1[i]>0)ans=mid,r=mid-1;
				else l=mid+1;
			}
			if((ans-i)&1)Ans[ans-1]++;
			else Ans[ans]++;
		}
	}
	for(int i=1;i<=n;i++)printf("%d ",Ans[i]);
	return 0;
}

Measured memory_bytes: 1664
import numpy as np
n = int(input())
v = np.array([int(i) for i in input().split()])
c = np.array([int(i) for i in input().split()])

v_list = v - c
v_list = np.array(sorted(v_list, reverse=True))

ans = sum(v_list[v_list > 0])
print(ans)

Measured memory_bytes: 21508
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<map>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    int n, d;
    cin >> n >> d;
    int ans = 0;
    llong a, b;
    REP(i, n) {
        cin >> a>>b;
        double dis = sqrt(a * a + b * b);
        if (dis <= d)
            ans++;
    }
    cout << ans << endl;;
    return 0;
    
}


Measured memory_bytes: 3716
import math

def isprime(n):
    if(n == 1):
        return True
    if(n == 2):
        return True
    if(n%2 == 0):
        return False
    for i in range(3, int(math.sqrt(n))+1, 2):
        if(n%i == 0):
            return False
        
    return True

def yakusuu(n):
    l = []
    u = []
    i = 1
    while(i*i <= n):
        if(n%i == 0):
            l.append(i)
            if(i != n//i):
                u.append(n//i)
        i += 1
    return l+u[::-1]
        
A, B = map(int, input().split())
a = set(yakusuu(A))
b = set(yakusuu(B))

lst = []
for i in a:
    if(i in b):
        lst.append(i)
   
cnt = 0
for i in range(len(lst)):
    if(isprime(lst[i])):
        cnt += 1
    
print(cnt)

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

#define rectget(a, x1, y1, x2, y2) \
  (a[x2][y2] + a[x1][y1] - a[x1][y2] - a[x2][y1])

int N, M, Q;
char S[2000][2000];
int n[2001][2001];
int h[2000][2001], v[2001][2000];

int main() {
  cin >> N >> M >> Q;
  for(int x = 0; x < N; ++x) for(int y = 0; y < M; ++ y) {
    cin >> S[x][y]; S[x][y] -= '0';
    n[x + 1][y + 1] = n[x][y + 1] + n[x + 1][y] - n[x][y]
      + S[x][y];
  }
  for(int x = 0; x < N - 1; ++x) for(int y = 0; y < M; ++ y) {
    h[x + 1][y + 1] = h[x + 1][y] + h[x][y + 1] - h[x][y]
      + (S[x][y] && S[x + 1][y]);
  }
  for(int x = 0; x < N; ++x) for(int y = 0; y < M - 1; ++ y) {
    v[x + 1][y + 1] = v[x + 1][y] + v[x][y + 1] - v[x][y]
      + (S[x][y] && S[x][y + 1]);
  }
  for(int q = 0; q < Q; ++q) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; --x1; --y1;
    int x = rectget(n, x1, y1, x2, y2),
      y = rectget(h, x1, y1, x2 - 1, y2),
      z = rectget(v, x1, y1, x2, y2 - 1);
    cout << x - y - z << endl;
  }
}


Measured memory_bytes: 52608
L = input()

N = len(L)
mod = int(1e9 + 7)

# 桁DP
# a+b <= N 確定
dp1 = [0] * N
# a+b <= N 未確定
dp2 = [0] * N

# L[0] == 1なので、初期値が決まる（はず）
dp1[0] = 1 # (A0,B0) = (0,0)
dp2[0] = 2 # (A0,B0) = (0,1), (1,0)

for i in range(1,N):
  dp1[i] += dp1[i-1] * 3 # (1,1)以外の3パターン
  dp1[i] %= mod
  if L[i] == '1':
    dp1[i] += dp2[i-1] # (0,0)
    dp2[i] += dp2[i-1] * 2 # (1,0),(0,1)
  else:
    # L[i] == '0'
    dp2[i] += dp2[i-1] # (0,0)
  dp1[i] %= mod
  dp2[i] %= mod
  
print((dp1[N-1] + dp2[N-1]) % mod)

Measured memory_bytes: 16808
n=gets.to_i
a=gets.split.map(&:to_i)
h=Hash.new(0)
a.each{|i|h[i]+=1}

total=0
h.each do |k,ci|
  total+=ci*(ci-1)/2
end

a.each do |i|
  puts total - h[i]*(h[i]-1)/2 + ((h[i]-1)*(h[i]-2)/2)
end

Measured memory_bytes: 36976
import sys

l = [int(i) - 1 for i in sys.stdin]

N = l[0] + 1

a = l[1:]

done = [False] * N

i = 0

ans = 0

while True:
    if done[i] == False:
        done[i] = True
        ans += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        ans = -1
        break

print(ans)

Measured memory_bytes: 72544
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;

#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)

struct greaterr
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};

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

ll lcm(ll a, ll b) {
	return a /gcd(a, b) *b;
}
typedef pair<int,int> pii;
const int mod = 1e9+7;

ll xorr(ll n){

    if(n%4==0)
        return n;

    else if(n%4==1)
        return 1;

    else if(n%4==2)
        return n+1;

    else
        return 0;



}

int main() {

   int n;
   cin>>n;

   int arr[n];
   fo(i,n)
    cin>>arr[i];

   fo(i,n-1){
   if(arr[i]<0){
    arr[i]*=-1;
   arr[i+1]*=-1;
   }
   }

 ll res = 0;

 if(arr[n-1]>=0)
    res = accumulate(arr,arr+n,0LL);
 else{
        arr[n-1]*=-1;
    res = accumulate(arr,arr+n,0LL) - 2* (*min_element(arr,arr+n));
 }
 cout<<res;
























    return 0;

      }


Measured memory_bytes: 640
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    int K = scanner.nextInt();

    PriorityQueue<String> queue = new PriorityQueue<>();
    for (int l = 1; l <= s.length() && l <= K; l++) {
      for (int i = 0; i <= s.length() - l; i++) {
        String sb = s.substring(i, i + l);
        if (!queue.contains(sb)) {
          queue.add(sb);
        }
      }
    }
    String val = "";
    for (int i = 0; i < K; i++) {
      val = queue.remove();
    }
    System.out.println(val);
  }
}


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

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> vec;
    for (int i = 0; i < n; i++) {
        vector<int> v(d);
        for (int j = 0; j < d; j++) {
            cin >> v[j];
        }
        vec.push_back(v);
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int sum = 0;
            for (int k = 0; k < d; k++) {
                sum += (vec[i][k] - vec[j][k]) * (vec[i][k] - vec[j][k]);
            }
            for (int l = 0; l < 200; l++) {
                if (sum == l * l) res++;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int x, y;
  cin >>x >> y;
  cout << (x + y / 2);
}
#endif


Measured memory_bytes: 3596
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

ll f(string &S){
	ll c = 0;
	int i = 1;
	while(i < S.size()){
		if(S[i-1] == S[i]){
			i++;
			c++;
		}
		i++;
	}
	// cout<<c<<" "<<S<<"\n";//
	return c;
}

int main(){
	string S;
	ll K;

	cin>>S;
	cin>>K;

	string S2 = S + S;
	string S3 = S2 + S;

	ll s1 = f(S);
	ll s2 = f(S2);
	ll s3 = f(S3);

	ll d1 = s2 - s1;
	ll d2 = s3 - s2;


	ll ans = 0;
	if(K == 1) ans = s1;
	else if(K == 2) ans = s2;
	else if(K == 3) ans = s3;
	if(K <= 3){
		ote(ans);
		return 0;
	}

	if(d1 == d2){
		ans = s1 + d1 * (K-1);
	}
	else{
		if(K % 2){
			ans = s1 + (d1+d2) * ((K+2-1)/2-1);
		}
		else{
			ans = s2 + (d1+d2) * (K/2-1);
		}
	}
	ote(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll A[N + 1], B[N + 1];
    vector<pair<ll, ll> > p;
    REP(i, N){
        cin >> A[i] >> B[i];
        p.push_back(make_pair(B[i], A[i]));
    }
    sort(p.begin(), p.end(), greater<pair<ll, ll> >());

    ll t = p[0].first - p[0].second;
    bool ifSuccess = true;
    REP(i, N - 1){
        t = min(p[i].first - p[i].second, t - p[i].second);
    }
    if(t < 0){
        ifSuccess = false;
    }
    if(ifSuccess){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 9664
from math import gcd
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int,input().split()))
    dic = defaultdict(bool)
    pairW = True
    setW = a[0]
    for i in a:
        t = 1
        while t**2 <= i:
            if i % t == 0:
                if (t != 1 and dic[t]) or (i//t != 1 and dic[i//t]):
                    pairW = False
                    break
                else:
                    dic[t] = True
                    dic[i//t] = True
            t += 1
        setW = gcd(setW,i)
    

    if pairW:
        print("pairwise coprime")
        return
    elif setW == 1:
        print("setwise coprime")
        return
    else:
        print("not coprime")


if __name__ == "__main__":
    main()

Measured memory_bytes: 206228
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll ans;
	cin >> ans;
	ans = 1 - ans;


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

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

const int MAX_N = 1010;
const int INF = 1e9;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
int h, w;
queue<pair<int, int>> que;
char board[MAX_N][MAX_N];
int dist[MAX_N][MAX_N];

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

    memset(dist,-1, sizeof(dist));
    cin >> h >> w;
    rep(i,h) {
        rep(j,w){
            cin >> board[i][j];
            if(board[i][j] == '#'){
                que.push(make_pair(i,j));
                dist[i][j] = 0;
            }
        }
    }

    while(!que.empty()){
        int x = que.front().first;
        int y = que.front().second;

        que.pop();
        for(int i = 0; i < 4; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx >= 0 && nx < h && ny >= 0 && ny < w && dist[nx][ny] == -1){
                dist[nx][ny] = dist[x][y] + 1;
                que.push(make_pair(nx,ny));
            }
        }
    }

    int ans = 0;
    rep(i,h){
        rep(j,w){
            ans = max(ans,dist[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 13456
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    
    int num[10]={INT_MAX,2,5,5,4,5,6,3,7,6};
    
    vector<int> dp(n+1);//dp[i]:=(i本のマッチで作れる最大桁数)
    dp[0]=0;
    for(int i=1;i<=n;i++){
        dp[i]=INT_MIN;
        for(int j=0;j<m;j++){
            if(i<num[a[j]]) continue;
            dp[i]=max(dp[i],dp[i-num[a[j]]]+1);
        }
        //cout << i << " " << dp[i] << endl;
    }

    //dp[n-num[a[i]]]=dp[n]-1のときはa[i]が使える
    vector<int> ans(10);
    fill(ans.begin(),ans.end(),0);
    ans[0]=INT_MIN;

    int N=n;
    for(int i=0;i<m;i++){
        while(N>=num[a[i]]&&dp[N-num[a[i]]]==dp[N]-1){
            ans[a[i]]++;
            N-=num[a[i]];
        }
        if(dp[N]==0&&N!=0){
            ans[a[i]]--;
            N+=num[a[i]];
        }
    }

    for(int i=9;i>=1;i--){
        for(int j=0;j<ans[i];j++){
            cout << i;
        }
    }
    cout << endl;
    return 0;
}


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

template<typename t>inline t min_(t a,t b){return a<=b?a:b;}
template<typename t>inline t max_(t a,t b){return a>=b?a:b;}
template<typename t>inline void chkmin(t&a,t b){if(a>b)a=b;}
template<typename t>inline void chkmax(t&a,t b){if(a<b)a=b;}

typedef long long ll;
const int maxn=1e5+10;
int n,m,a[maxn],fa[maxn],need;
bool vis[maxn];
priority_queue<int,vector<int>,greater<int> > q1,q2;
ll ans;

int findfa(int x){
	if(fa[x]==x)return x;
	return fa[x]=findfa(fa[x]);
}

int main(){
	cin>>n>>m;
	if(m==n-1){
		puts("0");
		return 0;
	}
	for(int i=0;i<n;++i){
		cin>>a[i];
		fa[i]=i;
	}
	for(int i=0,u,v;i<m;++i){
		cin>>u>>v;
		u=findfa(u);v=findfa(v);
		if(a[u]<=a[v])
			fa[v]=u;
		else
			fa[u]=v;
	}
	for(int i=0;i<n;++i)
		if(findfa(i)==i)
			q1.push(a[i]);
		else
			q2.push(a[i]);
	need=(n-m-1)*2;
	for(int i=0;i<n-m;++i)
		ans+=q1.top(),q1.pop(),--need;
	while(!q1.empty())
		q2.push(q1.top()),q1.pop();
	while(need)
		if(q2.empty()){
			puts("Impossible");
			return 0;
		}
		else
			ans+=q2.top(),q2.pop(),--need;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1916
#include <stdio.h>
#include <math.h>

#define PI  3.141592653589793
//円周率の宣言

int main(int argc, const char * argv[]) {
    double r;
    
    scanf("%lf", &r);
    printf("%lf %lf\n", PI*r*r, 2*PI*r);
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef pair<int,int> P;
int n,u,v,m,a[500][500],b[500][500];
P x[1000001],y[1000001];
int ar[500],ac[500],br[500],bc[500],a1,a2,b1,b2,xx,yy;
void inc(int &s,int r){
	s++;
	if(s==n){
		if(r==1) xx++;
		else yy++;
	}
}
int main(){
	cin>>n>>u>>v>>m;
	if(n==1){
		int o,s;
		cin>>o>>s;
		rep(i,m){
			int c;
			cin>>c;
			if(o==c&&s==c&&u==1&&v==1){
				puts("DRAW");
				return 0;
			}else if(o==c&&u==1){
				puts("USAGI");
				return 0;
			}else if(s==c&&v==1){
				puts("NEKO");
				return 0;
			}
		}
		puts("DRAW");
		return 0;
	}
	rep(i,1000001){
		x[i]=y[i]=P(-1,-1);
	}
	rep(i,n) rep(j,n){
		cin>>a[i][j];
		x[a[i][j]]=P(i,j);
	}
	rep(i,n) rep(j,n){
		cin>>b[i][j];
		y[b[i][j]]=P(i,j);
	}
	rep(i,m){
		int c;
		cin>>c;
		if(x[c].fs>=0){
			int X=x[c].fs,Y=x[c].sc;
			inc(ar[X],1);
			inc(ac[Y],1);
			if(X==Y) inc(a1,1);
			if(X+Y==n-1) inc(a2,1);
		}
		if(y[c].fs>=0){
			int X=y[c].fs,Y=y[c].sc;
			inc(br[X],2);
			inc(bc[Y],2);
			if(X==Y) inc(b1,2);
			if(X+Y==n-1) inc(b2,2);
		}
		if(xx>=u&&yy>=v){
			puts("DRAW");
			return 0;
		}
		if(xx>=u){
			puts("USAGI");
			return 0;
		}
		if(yy>=v){
			puts("NEKO");
			return 0;
		}
	}
	puts("DRAW");
	return 0;
}

Measured memory_bytes: 18236
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    string n;
    lli i,l,k;
    cin>>n;
    if(n.find('7')!=string::npos){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3592
object Main extends App {
  val n = readLine.toInt
  val arr = readLine.split(" ").map(_.toInt)
  val sorted = arr.sorted.reverse
  
  var alice = 0
  var bob = 0
  
  for (i <- 0 to n-1)
  	if (i % 2 == 0) alice += sorted(i)
  	else bob += sorted(i)
  
  println(alice - bob)
}

Measured memory_bytes: 25556
sa = list(input())
sb = list(input())
sc = list(input())
turn = 0

while 1:
    if turn == 0:
        if sa == []:
            print('A')
            break
        elif sa[0] == 'b':
            turn += 1
        elif sa[0] == 'c':
            turn += 2
        del sa[0]
        

    if turn == 1:
        if sb == []:
            print('B')
            break
        elif sb[0] == 'a':
            turn -= 1
        elif sb[0] =='c':
            turn += 1
        del sb[0]
    
    if turn == 2:
        if sc == []:
            print('C')
            break
        elif sc[0] == 'a':
            turn -= 2
        elif sc[0] == 'b':
            turn -= 1
        del sc[0]

Measured memory_bytes: 3064
import fractions
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return(a)


A, B = map(int, input().split())
G = fractions.gcd(A, B)
c = collections.Counter(prime_factorize(G)).keys()

print(len(list(c)) + 1)


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

int main() {
  priority_queue<int> q;
  while (1) {
    string que; cin >> que;
    if (que == "end") break;

    if (que == "insert") {
      int num; cin >> num;
      q.push(num);
    } else {
      cout << q.top() << endl;
      q.pop();
    }
  }
}



Measured memory_bytes: 6936
a, b, x = map(int,input().split())
s = x/a
import math
if s == a * b:
  print(0)
elif (a*b / 2 >= s):
  h = 2*s/b
  rad = math.atan(h/b)
  print(90.0 - math.degrees(rad))
else:
  l = 2*(b - s/a)
  rad = math.atan(a/l)
  print(90.0 - math.degrees(rad))

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        long[] A = new long[K];
        for(int i=0;i<K;++i){
            A[i]=scan.nextLong();
        }

        long left=2;
        long right=2;
        for(int i=K-1;i>=0;--i){
            long kleft = (left-1)/A[i] + 1;
            long kright= right/A[i];
            if(kleft > kright){
                System.out.println(-1);
                return;
            }
            left = A[i]*kleft;
            right=A[i]*kright+(A[i]-1);
        }
            System.out.println(left+" "+right);
    }
}

Measured memory_bytes: 57824
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
int n;
int sum(int *a){
	int X = 0;
	for(int i = 0; i < n; i++){
		X += a[i];
	}
	return X;
}
int main(){
	while(scanf("%d",&n),n){
		vector < int > taro;
		vector < int > hanako;
		int stage;
		for(int i = 0; i < n; i++){
			int tmp;
			scanf("%d",&tmp);
			taro.push_back(tmp);
		}
		sort(taro.begin(),taro.end());
		for(int i = 1; i <= 2*n; i++){
			if(find(taro.begin(),taro.end(),i) == taro.end())hanako.push_back(i);
		}
		int taro_f[128]={0};
		int hanako_f[128]={0};
		bool state = false;//true = taro false = hanako
		stage = taro[0];
		taro_f[0] = 1;
		while(true){
			bool ok = false;
			if(!state){
				for(int i = 0; i < n; i++){
					if(hanako_f[i] == 0 && hanako[i] > stage){
						stage = hanako[i];
						hanako_f[i] = 1;
						ok = true;
						break;
					}
				}
				if(!ok){
					stage = 0;
				}
				state = true;
			}
			else if(state){
				for(int i = 0; i < n; i++){
					if(taro_f[i] == 0 && taro[i] > stage){
						stage = taro[i];
						taro_f[i] = 1;
						ok = true;
						break;
					}
				}
				if(!ok){
					stage = 0;
				}
				state = false;
			}
			if(sum(taro_f) == n){
				printf("%d\n0\n",n-sum(hanako_f));
				break;
			}
			if(sum(hanako_f) == n){
				printf("0\n%d\n",n-sum(taro_f));
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

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

    switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    default:
        cout << "bon" << endl;
        break;
    }
    
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string> 
#include <stdio.h>
#include <math.h>
using namespace std; 
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long int
#define REPI(a, b, i, inc) for(ll i = a; i < b; i = i + inc)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define F first
#define S second
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define testi ll t; cin>>t; REP(tc,1,t+1)
#define vec vector
#define veci vector<ll>
#define pi pair<ll,ll>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define uset unordered_set
#define umap unordered_map

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("op.txt","w",stdout);
    #endif
    ll n,d;
    cin>>n>>d; int co=0;
    while(n--)
    {
    	ll x,y;
    	cin>>x>>y;

    	  ll d1= x*x;
    	  //cout<<d1<<" ";

          ll d2= y*y;
          //cout<<d2<<endl;
          ll d4= d*d;
   
    	if (d1<=d4-d2){
         
    		co++;
    	}
    	
    }
    cout<<co;
	
	


	
	return 0;


}

Measured memory_bytes: 3652
import java.util.Scanner;


public class Main {
        public static void main(String[] args){
                Scanner sn = new Scanner(System.in);
                int n = sn.nextInt();
                for(int i = 0; i < n; i++){
                        System.out.println( decode(sn.next(),  sn.next()));
                }
        }

        static Message decode(String order, String msg){
        	Message m = new Message(msg);
        	order = shorterOrder(order);
            for(int i = order.length()-1; i >= 0; i--){
                    switch(order.charAt(i)){
                        case 'J': m = m.c(); break;
                        case 'C': m = m.j(); break;
                        case 'E': m = m.e(); break;
                        case 'A': m = m.a(); break;
                        case 'P': m = m.m(); break;
                        case 'M': m = m.p(); break;
                    }
            }
            return m;
        }
        
        static String shorterOrder(String order){
        	return order.replaceAll("JC|CJ|PM|MP|AA", "");
        }
}

class Message{
        private String s;
        private static char[] updigits = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
        private static char[] lowdigits = {'9', '0', '1', '2', '3', '4', '5', '6', '7', '8'};
        public String toString(){
                return s;
        }

        Message(String s){
                this.s = s;
        }

        Message j(){
                return new Message(s.substring(1)+s.charAt(0));
        }

        Message c(){
                return new Message(s.charAt(s.length()-1)+s.substring(0, s.length()-1));
        }

        Message e(){
                int half = s.length()/2;
                return  (s.length()%2==0)? new Message( s.substring(s.length()-half, s.length()) + s.substring(0, half)):
                        new Message( s.substring(s.length()-half, s.length()) + s.charAt(half) + s.substring(0, half));
        }

        Message a(){
                return new Message(new StringBuffer(s).reverse().toString());
        }

        Message p(){
                String ns = "";
                for(int i = 0; i < s.length(); i++){
                        ns += (s.charAt(i) >= '0' && s.charAt(i) <= '9')? updigits[s.charAt(i)-'0']:
                                s.charAt(i);
                }
                return new Message(ns);
        }

        Message m(){
                String ns = "";
                for(int i = 0; i < s.length(); i++){
                        ns += (s.charAt(i) >= '0' && s.charAt(i) <= '9')? lowdigits[s.charAt(i)-'0']:
                                s.charAt(i);
                }
                return new Message(ns);
        }
}

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

using namespace std;

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    long long ans = 2 * min(b, c);
    long long cur = min(b, c);
    b -= cur; c -= cur;
    if (c == 0) cout << ans + b;
    else {
        ans += min(c, a + 1);
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 256
$<.each_line do |l|
  stack = []
  l.split.each do |s|
    case s
    when /\d+/
      stack << s.to_f
    when ?+
      b = stack.pop
      a = stack.pop
      stack << a + b
    when ?-
      b = stack.pop
      a = stack.pop
      stack << a - b
    when ?*
      b = stack.pop
      a = stack.pop
      stack << a * b
    when ?/
      b = stack.pop
      a = stack.pop
      stack << a / b
    end
  end
  p stack.pop
end

Measured memory_bytes: 8724
#include<stdio.h>
main(){
	unsigned long a[1000],b[1000],tmp_a[1000],tmp_b[1000];
	int i,j;
	for(j=0;scanf("%ld %ld",&a[j],&b[j])!=EOF;j++);
	
	for(i=0;i<j;i++){
		tmp_a[i]=a[i];
		tmp_b[i]=b[i];
	}
	//gcd
	unsigned long r[1000],tmp,gcd[1000],lcm[1000];
	for(i=0;i<j;i++){
		while(abs(a[i]-b[i])!=0){
			//aとbの大小判定
			if(a[i]<b[i]){
				tmp=a[i];
				a[i]=b[i];
				b[i]=tmp;
			}
			//ユークリッド
			r[i]=a[i]-b[i];
			a[i]=b[i];
			b[i]=r[i];
		}
		gcd[i]=b[i];
	}
	//lcm
	for(i=0;i<j;i++){
		lcm[i]=(tmp_a[i]*tmp_b[i])/gcd[i];
	}
	
	for(i=0;i<j;i++){
		printf("%ld %ld\n",gcd[i],lcm[i]);
	}
	return 0;
}

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

int main () {
  int N, b;
  b = 1;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < N - 1; i++) {
    if (a.at(i) < a.at(i + 1)) {
      b++;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 3620
S = input()
kuri = False
ans = 0
for i in range(len(S)-1, -1, -1):
    K = int(S[i])
    if kuri:
        K += 1
    kuri = False
    if K < 5:
        ans += K
    elif K > 5:
        ans += (10-K)
        kuri = True
    elif K == 5:
        if i > 0:
            M = int(S[i-1])
            if i != 0 and M >= 5:
                kuri = True
        ans += 5
    if i == 0 and kuri:
        ans += 1
print(ans)


Measured memory_bytes: 53868
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }

int main() {
    // input
    int n; scanf("%d", &n);
    vector<ll> x(n), s(n); repeat (i, n) scanf("%lld%lld", &x[i], &s[i]);
    // solve
    ll result = s[0];
    ll acc = s[0];
    repeat (i, n - 1) {
        acc -= x[i + 1] - x[i];
        setmax(acc, 0ll);
        acc += s[i + 1];
        setmax(result, acc);
    }
    // output
    printf("%lld\n", result);
    return 0;
}


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

using namespace std;

int main() {
    long long N,A,B; 
    cin >>N>>A>>B;
    long long ans=B*(N-1)+A-A*(N-1)-B+1;
    if((N==1&&A!=B)||(A>B))ans=0;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main() {
    
    ll l , r, d;
    cin >> l >> r>>d;
    ll res = 0;
    for (int i=l; i <= r; i++) {
        if (i % d == 0) res ++;
    }
    
    
    
    
    cout << res;

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int dp[200010];

signed main(){
  int n;
  cin>>n;
  string s;
  int acnt=0,bcnt=0;
  int sing=0,doub=0;
  int ans=0;
  lp(i,n){
    string s;
    cin>>s;
    if(s[0]=='B'&&s[s.size()-1]=='A') doub++;
    else{
    if(s[0]=='B')bcnt++;
    if(s[s.size()-1]=='A')acnt++;
    }
    lp(i,s.size()){
      if(i==0)continue;
      if(s[i]=='B'&&s[i-1]=='A')ans++;
    }
  }
  if(acnt==0&&bcnt==0&&doub!=0){
    ans+=doub-1;
  }
  else{
    acnt+=doub;
    bcnt+=doub;
    ans+=min(acnt,bcnt);
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int n,x=1;
    cin>>n;
    vector<int>a(44);
    for(int i=1;i<=31;i++){
      a.at(i-1)=i*i;
      }
    for(int i=2;i<=10;i++){
      a.at(29+i)=i*i*i;
      }
    a.at(40)=32;//2^5
    a.at(41)=128;
    a.at(42)=512;
    a.at(43)=243;
    
    for(int i=0;i<44;i++){
    if(n>=a.at(i))x=max(x,a.at(i));
      }
      cout<<x<<endl;
       
return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N)
{

    string s = to_string(N);

    string ans = NO;
    if (s.find("7") != string::npos)
    {
        ans = YES;
    }

    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

using namespace std;

int main(){

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

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

    int a,b;

    cin >> a >> b;

    cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3652
#ランレングス圧縮
def rle_comp(S):
    rle = []
    pre = 'X'
    chain = 1
    for c in S:
        if c == pre:
            chain += 1
        else:
            if pre != 'X':
                rle.append([pre,chain])
            
            pre = c
            chain = 1
    rle.append([pre,chain])

    #print(rle)
    return rle

N,A,B,C,D = map(int,input().split())
S = input()
#S = S[:A-1] + 'A' + S[A:]
#S = S[:B-1] + 'B' + S[B:]
#print(S)
ans = "Yes"
#すぬけ君がふぬけ君を2マスジャンプで追い越しが不要な場合
if C < D:
    rle = rle_comp(S[A-1:D])
    for i in range(len(rle)):
        #2マスジャンプで岩をやりすごせるか判定
        if rle[i][0] == '#' and rle[i][1] >= 2:
            ans = "No"
#すぬけ君がふぬけ君を2マスジャンプで追い越しが必要な場合
else:
    rle = rle_comp(S[A-1:C])
    for i in range(len(rle)):
        #2マスジャンプで岩をやりすごせるか判定
        if rle[i][0] == '#' and rle[i][1] >= 2:
            ans = "No"

    space = False
    #ふぬけ君がスタート地点またはゴール地点にいる状態で追い越しをする場合を考慮するため
    #範囲を1つずつ広げる
    rle = rle_comp(S[B-2:D+1])
    for i in range(len(rle)):
        #追い越しができるか判定
        if rle[i][0] == '.' and rle[i][1] >= 3:
            space = True
    
    if space == False:
        ans = "No"

print(ans)

Measured memory_bytes: 27484
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] a = new int[H][W];
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				a[i][j] = sc.nextInt() % 2;
			}
		}

		ArrayList<String> ans = new ArrayList<>();
		for (int j = 0; j < W; ++j) {
			for (int i = 0; i < H; ++i) {
				if (a[i][j] == 0 || i == H - 1)
					continue;
				ans.add((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1));
				a[i + 1][j] ^= 1;
				a[i][j] ^= 1;
			}
			for (int i = 0; i < H; ++i) {
				if (a[i][j] == 0 || j == W - 1)
					continue;
				ans.add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
				a[i][j] ^= 1;
				a[i][j + 1] ^= 1;
			}
		}
		System.out.println(ans.size());
		for (String str : ans) {
			System.out.println(str);
		}
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 58096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll b=0;
    ll c=0;
    rep(i,0,n-1){
        b+=a[i];
        c+=a[i]*a[i];
        b=mod(b);
        c=mod(c);
    }
    ll ans=mod(b*b-c);
    if(ans%2==0){
        cout<<mod(ans/2)<<endl;
    }else{
        cout<<mod((ans+i_7)/2)<<endl;
    }

    return 0;
}





Measured memory_bytes: 5192
n = int(input())

ans = []
for i in range(1, n + 1):
    x = i
    for j in range(100):
        if x % 2 == 0:
            x = int(x // 2)
            #ans.append(j)
        else:
            #ans.append(j)
            break
    ans.append(j)

#print(ans)
print(ans.index(max(ans)) + 1)


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<int,int> P;


int main(){
    int n; cin >> n;
    vector<int>a(n+1),b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    
    ll sum=0;
    rep(i,n){
        if(b[i]-a[i]>=0){
            sum+=a[i];
            b[i]-=a[i];
            if(b[i]-a[i+1]>=0){
                sum+=a[i+1];
                a[i+1]=0;
            }else{
                sum+=b[i];
                a[i+1]-=b[i];
            }
        }else{
            sum+=b[i];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}
use input::*;

fn main() {
    let mut s = str2vec(&input_line_str());
    let mut t = str2vec(&input_line_str());
    let mut flag: Option<bool> = None;
    s.sort();
    t.sort();
    t.reverse();
    let mut i = 0;
    while i < s.len() && i < t.len() {
        if s[i] < t[i] {
            flag = Some(true);
            break;
        }
        if s[i] > t[i] {
            flag = Some(false);
            break;
        }
        i += 1;
    }
    match flag {
        Some(x) => {
            if x {
                println!("Yes");
            } else {
                println!("No");
            }
        }
        None => {
            if s.len() >= t.len() {
                println!("No");
            } else {
                println!("Yes");
            }
        }
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main() { 
    // freopen("charnum.in","r",stdin);
    // freopen("charnum.out","w",stdout);
	int n;
	cin>>n;
	cout<<setiosflags(ios::fixed)<<setprecision(2)<<n*2*3.141<<endl;
	return 0; 
}

Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
long long pow_mod(long long base,long long exp,long long mod){
    long long res = 1;
    while(exp>0){
        if(exp & 1) {
          res = res * base % mod;
        }
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}
long long comb_mod(long long n,long long r,long long mod){
    long long nf=1;
    long long mf = 1;
    for(int i=1;i<=n;i++) {
      nf *= i;
      nf %=mod;
    }
    for(int i=1;i<=n-r;i++) {
      mf *= i;
      mf %= mod;
    }
    for(int i=1;i<=r;i++) {
      mf *= i;
      mf %= mod;
    }
    mf = pow_mod(mf,mod-2,mod);
    return mf * nf % mod;
}
const int mod = 1e9+7;


int main() {
  int X;
  int Y;
  int flag = 0;
  int64_t sum = 1;
  std::cin >> X >> Y;
  if ((2*X - Y) % 3 != 0 || (-1*X + 2*Y) % 3 != 0 || (2*X - Y) < 0 || (-1*X + 2*Y) < 0) {
    std::cout << "0" << std::endl;
  }
  else {
    int a = (2*X - Y)/3;
    int b = (-1*X + 2*Y)/3;
    int temp_num;
    if (a < b) {
      temp_num = a;
    }
    else {
      temp_num = b;
    }
    
    std::cout << comb_mod(a+b,b,mod) << std::endl;
  }
}


Measured memory_bytes: 256
N = int(input())

def digit(x, base):
    if x == 0:
        return 0
    return digit(x // base, base) + x % base

def calc(six, nine):
    return digit(six, 6) + digit(nine, 9)

ans = 10**18
for six in range(N + 1):
    ans = min(ans, calc(six, N - six))
print(ans)

Measured memory_bytes: 3064