akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int N, K;
    int a[60];  // 最大 100 個ですが余裕をもたせます
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
    int sum = 0;
    for (int i = 0; i < K; ++i) {
        sum += a[i];
    }
    cout << sum << endl;
}

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

int gcd(int x, int y){
	
	if (y == 0){
		return (x);
	}
	
	return (gcd(y, x % y));
}

int main()
{
	int x, y;
	
	cin >> x >> y;
	
	cout << gcd(x, y) << endl;
	
	return (0);
}

Measured memory_bytes: 1164
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int const N=1e5+5;
int n,cunt=0;
long long arr[N];
int diff[N];
int main()
{
   cin >> n;
   for(int i=0;i<n;i++){
    cin >> arr[i];
   }
   int j=0,i=0;
   for(i=0,j=0;i<n;i++){
        if(arr[i]<=arr[i-1]){
            cunt++;
        }else{
            diff[j]=cunt;
            cunt=0;
            j++;
        }
   }
   diff[j]=cunt;
   int *sum;
   //for(int i=0;i<n;i++) cout << diff[i];
   sum=max_element(diff,diff+N);
   cout << *sum;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define LL long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m;
vector<bool> v[60];
bool visit[60];
int res=0;
bool bfs()
{
	queue<int> q;
	fill(visit,visit+n,0);
	q.push(0);
	while (!q.empty())
	{
		int x=q.front();
		q.pop();
		for (int i=0;i<n;i++)
		{
			if (!v[x][i]) continue;
			if (visit[i]) continue;
			visit[i]=1;
			q.push(i);
		}
	}
	//cout <<count(visit,visit+n,0)<<" ##\n";
	return (count(visit,visit+n,0) ? 0 : 1);
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) v[i]=vector<bool>(n);
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		v[x][y]=v[y][x]=1;
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<i;j++)
		{
			if (!v[i][j]) continue;
			v[i][j]=v[j][i]=0;
			if (!bfs()) res++;
			v[i][j]=v[j][i]=1;
		}
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, raw_input().split())
S = raw_input()

if C < B:
    if S[A-1:C].find('##') < 0 and S[B-1:D].find('##') < 0: print 'Yes'
    else: print 'No'
elif C < D:
    if S[B-1:D].find('##') >= 0: print 'No'
    elif S[A-1:C].find('##') >= 0: print 'No'
    else:
        print 'Yes'
else:
    if S[B-1:D].find('##') >= 0: print 'No'
    else:
        if S[A-1:C].find('##') >= 0: print 'No'
        else:
            list_s = list(S)
            list_s[B-1] = '#'
            list_s_1 = list(S)
            list_s_1[D-1] = '#'
            S_1 = ''.join(list_s)
            S_2 = ''.join(list_s_1)
            if S_1[A-1:C].find('##') >= 0 and S_2[A-1:C].find('##') >= 0:
                if S[B-1:D].find('...') >= 0: print 'Yes'
                else: print 'No'
            else: print 'Yes'


Measured memory_bytes: 6376
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    internal static void Main(string[] args)
    {
        var inp = ReadLine().Split(' ').Select(s => double.Parse(s)).ToList();
        WriteLine(Math.Ceiling((inp[0] + inp[1]) / 2));
    }
}


Measured memory_bytes: 11220
import java.util.*;
import java.lang.*;
public class Main{
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int apple = sc.nextInt();
    int piece_apple = sc.nextInt();
    int applePie;
    applePie = (apple * 3 + piece_apple)/2;
        System.out.println(applePie);













    }
}



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

int main(){
    ios_base::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string c;
    vector<string> a;
    for(int i=0;i<h;i++){
        cin >> c;
        a.push_back(c);
    }
    for(int i=0;i<h;i++){
        cout << a[i] << endl;
        cout << a[i] << endl;
    }
    return 0;
}

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

int main() {
  int a;
  cin >> a;
  int b;
  cin >> b;
  if (a >= 13) {
    cout << b << endl;
  } else if (a <= 5) {
    cout << 0 << endl;
  } else {
    cout << b/2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextInt();
		long b=sc.nextInt();
		long c=sc.nextInt();
		String k=sc.next();

		String s ="";
		s = String.valueOf(k.charAt(k.length()-1));
		int num = Integer.parseInt(s);


		if(num%2==0) {
			System.out.print(a-b);
		}
		else {
			System.out.print(b-a);
		}
	}


}


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

using namespace std;


int main()
{
    int n,y;
    cin>>n>>y;
    int a=y/10000;
    int b=y/5000;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
    {
          if(10000*i+5000*j+1000*(n-i-j)==y&&n>=i+j)
          {
              cout<<i<<" "<<j<<" "<<n-i-j<<" "<<endl;
              return 0;
          }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 500;
bool vis[N][N];
char m[N][N];
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};
int cnt;

void dfs(int r,int c,int y,int x){
  if (vis[y][x])return;
  vis[y][x]=true;
  cnt++;
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (nex == -1 || ney == -1 || nex == c || ney == r ||
	m[ney][nex] == '#')continue;
    dfs(r,c,ney,nex);
  }


}

main(){
  int c,r;
  while(cin>>c>>r){
    if (c == 0 && r == 0)break;
    int sy=0,sx=0;
    cnt=0;
    rep(i,r)rep(j,c)vis[i][j]=false;
    rep(i,r){
      cin>>m[i];
      rep(j,c)if (m[i][j] == '@')sy=i,sx=j;
    }
    dfs(r,c,sy,sx);
    cout << cnt << endl;
  }
  return false;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
const int maxn = 10;
double a[maxn], b[maxn], g[maxn][maxn], book[maxn];
double c[maxn] = {1,2,6,24,120,720,5040,40320};
double dis(double a, double b, double x, double y)
{
	return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}
double sum = 0.0;
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lf %lf", a + i, b + i);
	}
	for(int i = 1;  i <= n; i++){
		for(int j = 1; j <= n; j++){
			sum += 1.0 * c[n - 2] * dis(a[i], b[i], a[j], b[j]);
		}
	}
	printf("%.10lf", sum / c[n - 1]);
	return 0;
 } 

Measured memory_bytes: 256
#aが最大で10**9ということは、各整数も10**9以下と仮定していい。二進数になおしたときの桁数は、30くらい
N = int(input())
A = list(map(int,input().split()))

digit = "0"+str(30)+"b"
memo = [None]*(N)

#総和からAiを引くと、A番目の数がもとまる
#どうやって総XORを求める？

#まず、aを二進数に直せばよさそう
a = A[0]
for i in range(1,N):
    a = a^A[i]

for i in range(N):
    print(a^A[i])

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

using namespace std;

struct point{
    double  x,y;
    point(){};
    point(double x,double y):x(x),y(y){}
    point operator + (point p){
        return point(x+p.x,y+p.y);
    }
    point operator - (point p){
        return point(x-p.x,y-p.y);
    }
    point operator * (double k){
        return point(x*k,y*k);
    }
    point operator / (double k){
        return point(x/k,y/k);
    }
};

double dot(point a,point b)
{
    return a.x*b.x+a.y*b.y;
}
double cross(point a,point b)
{
    return a.x*b.y-a.y*b.x;
}

double norm(point p)
{
    return p.x*p.x+p.y*p.y;
}
double ABS(point p)
{
    return sqrt(norm(p));
}

point project(point a,point b,point c)
{
    point base=b-a;
    double r=dot(base,c-a)/norm(base);
    return a+(base*r);
}

double arg(point p){return atan2(p.y,p.x);}
point polar(double a,double r)
{
    return point(cos(r)*a,sin(r)*a);
}

pair<point,point>getcrosspoints(point a1,double r1,point a2,double r2)
{
    double d=ABS(a2-a1);
    double a=acos((r1*r1+d*d-r2*r2)/(2*r1*d));
    double t=arg(a2-a1);
    return make_pair(a1+polar(r1,t+a),a1+polar(r1,t-a));
}

int main()
{
    point a1;
    double r1;
    point a2;
    double r2;
    cin>>a1.x>>a1.y>>r1;
    cin>>a2.x>>a2.y>>r2;
    pair<point,point>res=getcrosspoints(a1,r1,a2,r2);
    if(res.first.x>res.second.x){
        swap(res.first,res.second);
    }else if(res.first.x==res.second.x){
        if(res.first.y>res.second.y){
            swap(res.first,res.second);
        }
    }
    printf("%.7f %.7f %.7f %.7f\n",res.first.x,res.first.y,res.second.x,res.second.y);
    return 0;
}



Measured memory_bytes: 3688
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a; i < b; i++)

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

	vector<string> s(n);
	int ac = 0, wa = 0, tle = 0, re = 0;

	rep(i, 0, n) {
		cin >> s[i];
		if (s[i] == "AC") ac++;
		else if (s[i] == "WA") wa++;
		else if (s[i] == "TLE") tle++;
		else re++;
	}

	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;

	return 0;
}

Measured memory_bytes: 6420
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

int prime[500000] = { 0 };
int idx;

//numまでの素数を求める
void getPrime(int num) {
	if (num < 2) {
		idx = -1;
		return;
	}
	prime[0] = 2;
	if (num < 3) {
		idx = 0;
		return;
	}
	idx = 1;
	prime[0] = 2;
	prime[1] = 3;
	int i, j;
	int flag;
	for (i = prime[idx] + 2; i <= num; i += 2) {
		flag = 1;
		for (j = 0; prime[j] <= (int)sqrt(i); j++) {
			if (i%prime[j] == 0) {
				flag = 0;
				break;
			}
		}
		if (flag)prime[++idx] = i;
	}
}

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

	int x;
	cin >> x;

	int p = 1;
	while ((x*p) % 360 != 0) {
		p++;
	}
	cout << p << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> nw(n), last(200001, -1);
  nw[0] = 1;
  last[a[0]] = 0;
  for (int i = 1; i < n; ++i) {
    nw[i] = nw[i - 1];
    if (last[a[i]] != -1 && last[a[i]] != i - 1) {
      nw[i] = (nw[i] + nw[last[a[i]]]) % MOD;
    }
    last[a[i]] = i;
  }
  cout << nw[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
//const ll MOD = 1000000007ll;
const ll MOD = 998244353ll;
const dou pi=3.141592653589793;

//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    int n,k;
    std::cin >> n>>k;
    set<int> s;
    rep(i,k){
        int m;
        std::cin >> m;
        rep(j,m){
            int d;
            std::cin >> d;
            s.insert(d);
        }
    }
    std::cout << n-s.size() << std::endl;
}



Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector <vector<int> >A(N,vector<int>(2));
    for (int i = 0;i<N;i++){
        cin>>A[i][0];
        A[i][1]=i+1;
    }
    sort(A.begin(),A.end());
    for (int i = 0;i<N;i++){
     cout<<A[i][1]<<endl;
    }
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
using ll = long long;

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

	rep(i, 1, 10) {
		rep(j, 1, 10) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
dp = [N]*100001
dp[0]=0
for i in range(1,N+1):
    temp = 1
    while temp <= i:
        dp[i]=min(dp[i], dp[i-temp] + 1)
        temp *= 6

    temp = 1
    while temp <= i:
        dp[i]=min(dp[i], dp[i-temp] + 1)
        temp *= 9

print(dp[N])

Measured memory_bytes: 3828
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
  int cnt = 0;
  char s[10];
  char t[10];
  int i;

  scanf("%s %s", s, t);

  for(i = 0;i < 3;i++) if(s[i] == t[i]) cnt++;

  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
#define fixed(n) fixed<<setprecision((n))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<int> a(300,INF);
vector<int> b(30);
vector<int> c(30);

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int sum = 0;
	reps(i,n-1){
		cin >> a[i];
		sum += a[i];
	}
	int ans = 0;
	int j = 1;
	for(int i = 1;i <= n;++i){
		ans += min(a[i],a[i-1]);
	}
	cout << ans << '\n';

	return 0;
}


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

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

  vector<int> h(n+1);
  rep(i,n) cin >> h[i+1];

  vector<int> dp(n+1,0);
  dp[1] = 0;

  for(int i = 2; i <= n; i++){
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    for(int j = 1; j <= k; j++){
      if(i-j<1) break;
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
  }

  cout << dp[n] << endl;

  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
int N,K;
int A[200001];

int32_t main(){
	fast;
	cin>>N>>K;
	FOR(i,1,N) cin>>A[i];
	
	FOR(i,K+1,N){
		if (A[i] > A[i - K]) cout<<"Yes\n";
		else cout<<"No\n";
	}
}


Measured memory_bytes: 5208
#include <stdio.h>

int main(void){
	int a,b,c;
	scanf("%d %d",&a,&b);
	if(a==1&&b==1){
		printf("Draw\n");
	}else if(a==1){
		printf("Alice\n");
	}else if(b==1){
		printf("Bob\n");
	}else if(a>b){
		printf("Alice\n");
	}else if(a<b){
		printf("Bob\n");
	}else{
		printf("Draw\n");
	}
	return 0;
}


Measured memory_bytes: 128
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1], reverse=True)
ans = []
s = []
for k, v in dic_sorted:
    s.append(v)
pre = s[0]
for k, v in dic_sorted:
    if v == pre:
        ans.append(k)
    else:
        break
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 116644
#include <iostream>

int main() {
    int cnt[4] = {};
    for (int i = 0; i < 6; i++) {
        int val;
        std::cin >> val;
        cnt[val - 1]++;
    }

    int p1 = 0, p2 = 0;
    for (int i = 0; i < 4; i++) {
        if (cnt[i] == 1) {
            p1++;
        } else if (cnt[i] == 2) {
            p2++;
        }
    }

    if (p1 == 2 && p2 == 2) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


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

N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]
ab.sort(key=lambda t: t[1])
ans = 0
now_r = 0

for a, b in ab:
    if now_r<=a:
        ans += 1
        now_r = b

print(ans)

Measured memory_bytes: 56924
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct{
  int a,b;
}dat;
main(){
  int n,s=0;
  cin>>n;
  vector<dat> v(n);
  for(int i=0;i<n;++i)cin>>v[i].a>>v[i].b;
  sort(v.begin(),v.end(),[](dat x,dat y){return x.b==y.b?x.a<y.a:x.b<y.b;});
  for(int i=0;i<n;++i){
    s+=v[i].a;
    if(s>v[i].b){cout<<"No";return 0;}
  }
  cout<<"Yes";
}

Measured memory_bytes: 1792
import math
a, b, x = [ int(v) for v in input().split() ]
v = a*a*b

if x < v/2:
    print(math.atan(b*b*a/(2*x))*(180/math.pi))
else:
    print(math.atan(2*(v-x)/(a**3))*(180/math.pi))

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

using namespace std;

int main(){
    int k,x;
    cin >> k >> x;
    
    int s = (x - k + 1) > -1000000 ? (x - k + 1) : -1000000;
    int e = (x + k - 1) < 1000000 ? (x + k - 1) : 1000000;
    for(int i =  s; i <= e; i++) {
        cout << i << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define fi first
#define se second
const int N = 2e6 + 500;

void solve()
{
	ll n;
	cin>>n;
	cout<<(n/2+n%2);
}

int main()
{




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

}




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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll q,h,s,d,n; cin>>q>>h>>s>>d>>n;
    ll ans = n/2 * min({8*q,4*h,2*s,d});
    ans += n%2 * min({4*q,2*h,s});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long n = sc.nextInt(), m = sc.nextInt();
		long ans = 0;
		if(n == 1 || m == 1) {
			if(n == m) {
				ans = 1;
			}else {
				ans = Math.max(n, m) - 2;
			}
		}else {
			ans = (n-2)*(m-2);
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32936
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b;
    bool f=1;
    while (cin>>a>>b && (a&&b))
    {
        for(int i=0;i<a;i++){
            f = !(i%2);
            for(int j=0;j<b;j++){
                if(f) cout<<'#';
                else  cout<<'.';
                f = !f;
            }
            cout<<'\n';
        }
        cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3008
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a, b, c, d;
		char is;
		int aid, bid, cid;
		
		while (true) {
			a = sc.next();
			if (a.equals("-")) {
				break;
			}
			
			b = sc.next();
			c = sc.next();
			d = "";

			aid = bid = cid = 0;
			is = b.charAt(bid++);
			while (true) {
				if (aid == a.length() && bid == b.length()) {
					d += Character.toString(is);
					break;
				}
				if (aid < a.length() && cid < c.length() && is == c.charAt(cid)) {
					is = a.charAt(aid++);
					cid++;
				} else {
					d += Character.toString(is);
					is = b.charAt(bid++);
				}
			}
			
			System.out.println(d);
		}
	}
}

Measured memory_bytes: 17216
n = int(input())
b = list(map(int, input().split()))
ans = []
while(len(b) != 1):
    count = 0
    for i in range(len(b) - 1, -1, -1):
        if b[i] == i + 1:
            b.pop(i)
            ans.append(i + 1)
            count = 0
            break
        else:
            count += 1
    if count == len(b):
        print(-1)
        exit()
if b[0] == 1:
    ans.append(1)
    ans = list(reversed(ans))
    for i in range(len(ans)):
        print(ans[i])
else:
    print(-1)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define p pair<int, int>
using namespace std;
  
int main(){
  int n, m, x, y;
  cin >> n >> m;
  p box[n];
  for(int i = 0; i < n; i++){
    box[i].first = i == 0 ? 1 : 0;
    box[i].second = 1;
  }
  for(int i = 0; i < m; i++){
    cin >> x >> y;
    x--; y--;
    if(box[x].first == 1){
      if(box[x].second == 1) box[x].first = 0;
      box[y].first = 1;
    }
    box[y].second++; box[x].second--;
  }
  int sum = 0;
  for(int i = 0; i < n; i++){
    if(box[i].first == 1) sum++;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  int n;
  cin >> n;
  string ret = "";
  for (int i = 0; i < n; ++i) {
    ret += "ACL";
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
  int a,b;
  cin>>a>>b;
  int max = a>b?a:b;
  int answer = (max+max-1)>(a+b)?(max+max-1):(a+b);
  cout<<answer;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.SoundHound2018.B
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            var S = sc.Next ();
            var w = sc.Nextint ();
            for (int i = 0; i < S.Length; i += w)
            {
                Console.Write (S[i]);
            }
            Console.WriteLine ();
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll N;
	cin >> N;
	ll F[N][10]={};
	FOR(i,0,N){
		FOR(j,0,10){
			cin >> F[i][j];
		}
	}
	ll P[N][11];
	FOR(i,0,N){
		FOR(j,0,11){
			cin >> P[i][j];
		}
	}
	ll ans = -INF;
	FOR(i,1,(1LL<<10)){
		ll ansp = 0;
		FOR(n,0,N){
			ll c = 0;
			FOR(j,0,10){
				if( (i&(1LL<<j)) && F[n][j] )c++;
			}
			ansp += P[n][c];
		}
		ans = max(ans,ansp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    A, B = map(int, input().split())
    ans = 10001
    for x in range(1, 10001):
        if 0 <= 8*x - 100*A < 100 and 0 <= 10*x - 100*B < 100:
            ans = min(ans, x)
    if ans == 10001:ans = -1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38512
open Str
       
let () =
  let _ = read_line () in
  let s = split (regexp "") (read_line ()) in
  let f (l, st) x =
    match st with
      [] -> if x = ")" then (l+1, []) else (l, ["("])
    | y :: ys -> if x = ")" && y = "(" then (l, ys) else (l, "("::y::ys) in
  let (l, r) = List.fold_left f (0,[]) s in
  String.make l '(' ^ String.concat "" s ^ String.make (List.length r) ')' |> print_endline


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<limits>
#include<iomanip>
using namespace std;


typedef pair<int,int> pi;
typedef pair<double,pi> pdi;
#define MK make_pair
#define F first
#define S second
const int MX=1e9+7;
vector<int> a[16000];
bool done[20000]={};

double dis(pi c,pi b){
    return (double)pow((c.F-b.F)*(c.F-b.F)+(c.S-b.S)*(c.S-b.S),1.0/2);
}

int DFS(int s,int g){
    done[s]=true;
    int count=0;
    for(int i=0;i<a[s].size();i++){
        if(!done[a[s][i]]){
            if(a[s][i]==g){count++; continue;}
            count+=DFS(a[s][i],g);
            if(count>=2){break;}
        }
    }
    return count;
}

int main(){
    cout<<fixed<<setprecision(12);
    int n,m;
    vector<pi> point;
    
    priority_queue<pdi> q;
    point.push_back(MK(0,0));
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int s,g;
        cin>>s>>g;
        point.push_back(MK(s,g));
    }
    for(int i=0;i<m;i++){
        int s,g;
        cin>>s>>g;
        a[s].push_back(g);
        a[g].push_back(s);
        q.push(MK(-1.0*dis(point[s],point[g]),MK(s,g)));
    }
    double count=0;
    
    while(!q.empty()){
        pdi di=q.top();
        q.pop();
        int l=DFS(di.S.F,di.S.S);
        fill(&done[0],&done[15000],false);
        for(int i=0;i<a[di.S.F].size();i++){
            if(a[di.S.F][i]==di.S.S){a[di.S.F].erase(a[di.S.F].begin()+i);}
        }
        for(int i=0;i<a[di.S.S].size();i++){
            if(a[di.S.S][i]==di.S.F){a[di.S.S].erase(a[di.S.S].begin()+i);}
        }
        if(l<2){continue;}
        //cout<<count<<" + "<<di.F<<" "<<di.S.F<<" "<<di.S.S<<endl;
        count-=di.F;
    }
     
    cout<<count<<endl;
    
    return 0;
}



Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 1e9 + 7;

ll dp[2005][2005];

int main()
{
	fastInp;

	ll n;
	cin >> n;
	vector<ll> vec(n);
	vector<pair<ll, ll>> vec2;
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
		vec2.push_back({ vec[i], i });
	}

	sort(vec2.rbegin(), vec2.rend());

	ll ans = 0;
	for (int x = 0; x <= n; x++) {
		for (int j = 1; j <= n; j++) {
			if (j - x < 0) continue;

			ll y = j - x, ind = (x + y) - 1, k = 0, k2 = 0;
			if (x + y > n) continue;
			ll vl = 0, vl2 = 0;
			if (x > 0) vl = dp[x - 1][y];
			if (y > 0) vl2 = dp[x][y - 1];

			if (x != 0) k = abs(vec2[ind].second - (x - 1)) * vec2[ind].first;
			if (y != 0) k2 = abs(vec2[ind].second - (n - y)) * vec2[ind].first;
			dp[x][y] = max(vl + k, vl2 + k2);
			if (x + y == n) ans = max(ans, dp[x][y]);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 26376
#include<iostream>
using namespace std;
#define INF 2<<29;
int S[500000];
int merge(int left, int mid, int right) {
	int count = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1], R[n2+1];
	for (int i = 0; i < n1; i++) {
		L[i] = S[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = S[mid + i];
	}
	L[n1] = INF;
	R[n2] = INF;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		count++;
		if (L[i] <= R[j]) {
			S[k] = L[i];
			i++;
		}else {
			S[k] = R[j];
			j++;
		}
	}
	return count;
}
int mergeSort(int left,int right) {
	int count = 0;
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		count += mergeSort(left, mid);
		count += mergeSort(mid,right);
		count += merge(left, mid, right);
	}
	return count;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	int count = mergeSort(0,n);
	for (int i = 0; i < n-1; i++) {
		cout << S[i] << " ";
	}
	cout << S[n - 1] << endl;
	cout << count <<endl;
	return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    V<int> v(3);
    for(int i = 0; i < 3; i++) cin >> v[i];

    sort(ALL(v));

    cout << v[0] + v[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int min(int a,int b){ return a>b?b:a; }

int main(){
    int a,b,c,d,e,f;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int up = 0, down = 1;
    int x = 100*a, y = 0;
    for(int i = 0; i*a*100<=f; i++){
        for(int j = 0; i*a*100+j*b*100<=f; j++){
            int water = i*a*100+j*b*100;
            int left = f-water; 
            int upper = min(left,(i*a+j*b)*e);
            for(int k = 0; k*c<=upper; k++){
                for(int l = 0; k*c+l*d<=upper; l++){
                    int sugar = k*c+l*d;
                    int all = sugar+water;
                    if(sugar!=0){
                        if(sugar*down>=up*all){
                            x = all, y = sugar;
                            up = sugar, down = all;
                        }
                    }
                }
            }
        }
    }
    printf("%d %d\n",x,y);
    return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n;
  cout.precision(11);
  cout << 2 * pi * n << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 3796
#include<cstdio>
#include<map>
using namespace std;int mp[144],m,n,hs,ch;int dir[]={-12,-1,1,12};map<int,int>memo;int func(int p,int d,int u){while(1){int h=mp[p];if(h>=0){int s=0;mp[p]=-1;hs^=1<<h;if(u>12){for(int i=0;i<4;i++)s+=func(p+dir[i],dir[i],u-1);}else{int mi=h<<23|hs;map<int,int>::iterator it=memo.find(mi);if(it==memo.end()){for(int i=0;i<4;i++)s+=func(p+dir[i],dir[i],u-1);memo[mi]=s;}else{s=it->second;}}hs|=1<<h;mp[p]=h;return s;}if(h==-9)break;p+=d;}return 0;}int main(){int i,j,p,t;for(;scanf("%d%d",&m,&n),m;memo.clear()){hs=0;for(i=0;i<144;i++)mp[i]=-9;for(i=1;i<=n;i++)for(j=1;j<=m;j++){p=i*12+j;scanf("%d",&t);switch(t){case 2:ch=p;case 0:mp[p]=-1;break;case 1:memo[hs<<23]=0;mp[p]=hs++;break;}}for(i=0;i<4;){t=dir[i++];for(j=ch;mp[j+=t]!=-9;mp[j]>=0?memo[mp[j]<<23]=1:0);}j=hs;hs=(1<<hs)-1;t=0;for(i=-1;++i<4;)t+=func(ch+dir[i],dir[i],j);printf("%d\n",t);}}

Measured memory_bytes: 32000
N = int(input())
 
li = [list(map(int,input().split())) for _ in range(N)]

k = 0
while li[k][2] == 0:
    k += 1
 
for x in range(101):
    for y in range(101):

        H = li[k][2]+abs(li[k][0]-x)+abs(li[k][1]-y)
        f = True

        for i in range(N):
            # CxとCyを決め打ちした後の十分性の確認は、問題文の式を利用
            if li[i][2] != max(H-abs(li[i][0]-x)-abs(li[i][1]-y),0):
                f = False
                break
        if f:
            print(x,y,H)
            break
    else:
        continue
    break
 

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
		cin >> x[i];
	int min_d = 10e9, d;
	for (int i = 0; i < n - k + 1; i++) {
		if (x[i] <= 0 && x[k - 1 + i] <= 0)
			d = -x[i];
		else if (x[i] >= 0 && x[k - 1 + i] >= 0)
			d = x[k - 1 + i];
		else
			d = min(-x[i], x[k - 1 + i]) * 2 + max(-x[i], x[k - 1 + i]);
		if (min_d > d)
			min_d = d;
	}
	cout << min_d << endl;
	return 0;
}


Measured memory_bytes: 640
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
use std::collections::HashMap;
fn main() {
    let n: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut sum: Vec<i64> = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i] + a[i];
    }
    let mut ans: i64 = 0;
    let mut mp: HashMap<i64, i64> = HashMap::new();
    for i in 0..n {
        let _a = sum[i + 1];
        if _a == 0 {
            ans += 1;
        }
        if mp.contains_key(&_a) {
            let k = mp[&_a];
            mp.insert(_a, k + 1);
        } else {
            mp.insert(_a, 1);
        }
    }
    for (key, value) in &mp {
        ans += value * (value - 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 11728
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  int k = 0;
  string str;
  cin >> k >> str;
  
  int cnt = 0;
  for(int i=0;i<k;i++){
    if(str.substr(i,3) == "ABC"){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin n,k;
lin a[1001];

int main(void)
{
    cin >> n >> k;
    rep(i,n)
    {
        cin >> a[i];
    }

    vector<lin> totals;
    rep(i,n)
    {
        lin val = 0;
        loop(j, i, n)
        {
            val += a[j];
            totals.push_back(val);
        }
    }
    sort(totals.begin(), totals.end());
    
    vector<lin> values;
    values.push_back(totals[0]);
    loop(i, 1, totals.size())
    {
        if(totals[i-1] != totals[i])
            values.push_back(totals[i]);
    }

    lin p = 1;
    while(p < values[values.size()-1])
    {
        p *= 2;
    }
    p /= 2;

    lin res = 0;
    while(p > 0)
    {
        lin count = 0;
        vector<lin> newValues;

        rep(i, values.size())
        {
            //cout << values[i] << " " << (p & values[i]) << endl;
            if((p & values[i]) > 0)
            {
                count++;
                newValues.push_back(values[i]);
            }
        }

        if(count >= k)
        {
            res += p;
            values = newValues;
            //cout << "#### " << res << endl;
        }
        else
        {
            newValues.clear();
        }

        p /= 2;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 11756
a,b,c,d=map(int, raw_input().split())
x,y=c-a,d-b
f='R'*(x) + 'U'*(y) + 'L'*(x) + 'D'*(y)
s='D' + 'R'*(x+1) + 'U'*(y+1) + 'L' + 'U' + 'L' * (x+1) + 'D'*(y+1) + 'R'
print f+s


Measured memory_bytes: 2692
open Printf open Scanf
open Array

let calc c =
  init 40 (fun i ->
    let pw = 1 lsl i in
    let pairs = (c+1) / 2 / pw in
    let left = c+1 - pairs * 2 * pw in
    (if i=0 then pairs mod 2 else 0) lxor (if left > pw then (left-pw) mod 2 else 0)
  )
  |> mapi (fun i v -> i,v)
  |> fold_left (fun sum (i,v) -> sum + v * 1 lsl i) 0

let () = scanf " %d %d" @@ fun a b ->
  print_int @@ (calc b) lxor (calc (a-1))




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
int main()
{
    string s;
    cin>>s;
    lli sum=0;
    lli n=s.size();
    frr(i,n)
    {
        sum=(sum+(s[i]-'0'))%9;
    }
    if(sum>0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3720
N, K = map(int, input().split())
ans = 0
for b in range(K+1, N+1):
    q, r = divmod(N, b)
    ans += q * (b-K) + max(r - K + 1, 0)
    if K == 0:
        ans -= 1 #a != 0
    #print(ans)

print(ans)

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, sum;
vi v;

void read() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x % 10 != 0)
      v.pb(x);
    sum += x;
  }
}

void solve() {
  if (sum % 10 != 0) {
    cout << sum << "\n";
  } else {
    sort(v.begin(), v.end());
    if (!v.empty())
      cout << sum - v[0] << "\n";
    else cout << "0\n";
  }
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t;           // PLEASE REMOVE IT IF NEEDED
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


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

int partition(int *A,int p,int r){
  int x,i,t;
  x=A[r];
  i=p-1;
  
  for (int j=p;j<r;j++){
    if (A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }

  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;

  return i+1;
}

int main(){
  int i,n,A[100005],q;

  cin >> n;
  for(i=0;i<n;i++)
    cin >> A[i];

  q=partition(A,0,n-1);

  for (i=0;i<q;i++)
    cout << A[i] << " ";
  
  cout << "[" << A[q] << "]";
  
  for (i=q+1;i<n;i++)
    cout << " " << A[i];
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3448
import Control.Monad                                                                                                       
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [h,w] <- map read . words <$> getLine                                                                                    
  ss <- replicateM h getLine                                                                                               
  let ss1 = [replicate (w+2) '.'] ++ map (("."++) . (++".")) ss ++ [replicate (w+2) '.']                                   
                                                                                                                           
  putStrLn $ if and [f ss1 x y | x <- [2..h+1], y <- [2..w+1]] then "Yes" else "No"                                        
                                                                                                                           
f :: [String] -> Int -> Int -> Bool                                                                                        
f xs i j                                                                                                                   
  | (xs!!(i-1))!!(j-1) == '#' &&                                                                                           
    (xs!!i)!!(j-1)     == '.' &&                                                                                           
    (xs!!(i-2))!!(j-1) == '.' &&                                                                                           
    (xs!!(i-1))!!j     == '.' &&                                                                                           
    (xs!!(i-1))!!(j-2) == '.' = False                                                                                      
  | otherwise = True

Measured memory_bytes: 1020
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,A[maxn],k;
const ll mod=1000000007;
  
inline ll mx() 
{ 
    sort(A, A + n); 
    ll product = 1; 
    if (A[n - 1] == 0 && (k & 1))  return 0; 
  
    if (A[n - 1] <= 0 && (k & 1))
	{ 
        for (int i = n - 1; i >= n - k; i--)  product=(product*A[i])%mod;
        return product; 
    } 
    ll i = 0;  ll j = n - 1; 
    if (k & 1)
	{ 
        product=(product*A[j])%mod;
        j--; k--; 
    } 
    k >>= 1; 
    for (ll itr = 0; itr < k; itr++)
	{ 
  
        ll lp = (A[i] * A[i + 1]); 
        ll rp = (A[j] * A[j - 1]); 
        if (lp > rp)
		{ 
            lp%=mod; rp%=mod;
			product=(product * lp)%mod;
            i += 2; 
        } 
        else
		{ 
            lp%=mod; rp%=mod;
			product=(product * rp)%mod;
            j -= 2; 
        } 
    } 
    return product;
} 
  
int main() 
{
	n=read(); k=read(); rep(i,0,n-1) A[i]=read();
    ll Q=mx();
  	if(Q<0) Q=mod+Q; cout<<Q<<endl;
    return 0; 
} 

Measured memory_bytes: 5144