akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back

int n, m, a, b, bl, wh, col[705];
bool mat[705][705];
vector<int> adj[705];
set <int> s, ss;

inline void fail() {
	cout << -1;
	exit(0);
}

void co(int x, int par, int c) {
	if (col[x] != -1 and col[x] != c) fail();
	else if(col[x] != -1) return;
	if (c) bl++; else wh++;
	col[x] = c;
	for(auto it:adj[x]) {
		if (it == par) continue;
		co(it, x, !c);
	}
}

int main() {
	memset(mat, 0, sizeof 0);
	memset(col, -1, sizeof col);
	s.clear(); s.insert(0);
	cin >> n >> m;
	FOR(i, 1, m) {
		cin >> a >> b;
		mat[a][b] = 1;
		mat[b][a] = 1;
	}
	FOR(i, 1, n) FOR(j, 1, n) {
		if (i == j) continue;
		if (!mat[i][j]) adj[i].pb(j);
	}
	FOR(i, 1, n) if (col[i] == -1) {
		bl = 0; wh = 0;
		co(i, -1, 0);
		ss = s;
		s.clear();
		for(auto it:ss) {
			s.insert(it+wh);
			s.insert(it+bl);
		}
	}
	auto it = s.lower_bound(n/2);
	a = *it; b = n - a;
	cout << (a*(a-1))/2 + (b*(b-1))/2;
}


Measured memory_bytes: 3072
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

cnt = 0
res = 0

for i in range(N):
    if A[i] >= res:
        cnt += res
        A[i] -= res
    else:
        cnt += A[i]
        A[i] = 0
        
    hit = min(A[i],B[i])
    cnt += hit
    res = B[i] - hit
    
cnt += min(A[N], res)

print(cnt)

Measured memory_bytes: 18476
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader((System.in)));
        StringTokenizer st = new StringTokenizer(br.readLine());
        char[] s = st.nextToken().toCharArray();
        if (s[2] == s[3] && s[4] == s[5]) System.out.println("Yes");
        else System.out.println("No");
//        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
//        bw.write("\n");
//        bw.close();
    }

}

Measured memory_bytes: 23252
n, l = map(int, input().split())
apples = list()
apple_total = 0
for i in range(1, n+1):
    apples.append(l+i-1)
    apple_total += l+i-1
if 0 in apples:
    print(apple_total)
else:
    if apple_total > 0:
        apple_total -= apples[0]
        print(apple_total)
    else:
        apple_total -= apples[-1]
        print(apple_total)


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

int main(){
  string s;
  REP(i,3){
    cin>>s;
    transform(s.begin(), s.end(), s.begin(), ::toupper);
    cout<<s.at(0);
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long
typedef pair<int, int>P;
int a[305][305];
P n[90001];
int ans[90001];

int dis(int a, int b) {
	int x = abs(n[a].first - n[b].first);
	int y = abs(n[a].second - n[b].second);
	return x + y;
}
signed main() {
	int h, w,d;
	cin >> h >> w>>d;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			n[a[i][j] - 1] = P(i, j);
		}
	}

	for (int i = d; i < h*w; i++) {
		ans[i] = ans[i - d] + dis(i - d, i);
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		cout << ans[r-1] - ans[l-1] << endl;
	}}

Measured memory_bytes: 3968
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,ans=0;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(ll i=1;i<n;i++)
    {
       if(a[i]<a[i-1])
       {
           ll p=a[i-1]-a[i];
           a[i]+=p;
           ans+=(p);
       }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5212
import java.io.*;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			int n = Integer.parseInt(br.readLine());
			for (int i=0;i<n;i++) {
				StringBuffer a = new StringBuffer(br.readLine());
				StringBuffer b = new StringBuffer(br.readLine());
				a.reverse();
				b.reverse();

				if (a.length()<=80&&b.length()<=80) {
					StringBuffer stb = new StringBuffer();
					for (int j=a.length();j<81;j++) a.append(0);
					for (int j=b.length();j<81;j++) b.append(0);

					int c = 0;
					for (int j=0;j<81;j++) {
						int s = partical_s(a.charAt(j),b.charAt(j))+c;
						stb.append(s%10);
						c = s/10;
					}
					int j = 0;
					stb.reverse();
					while (stb.charAt(j)=='0'&&j<stb.length()-1) j++;
					StringBuffer newsb = new StringBuffer();
					for (int d=j;d<stb.length();d++) newsb.append(stb.charAt(d));
					if (newsb.length()<=80) System.out.println(newsb);
					else System.out.println("overflow");
				} else {
					System.out.println("overflow");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static int partical_s(char a,char b) {
		return Integer.parseInt(""+a)+Integer.parseInt(""+b);
	}
}

Measured memory_bytes: 17132
#include <bits/stdc++.h>
using namespace std;
bool a[101];
int main(){
	int n,k,x,y;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>x;
		for(int i=1;i<=x;i++){
			cin>>y;
			a[y]=true;
		}
	}
	x=0;
	for(int i=1;i<=n;i++)
		if(!a[i]) x++;
	cout<<x;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	int i,N,c[1000],a[1000],n[1000],s[100]={0};
	scanf("%d",&N);
	for(i=0;i<	N;i++){
		scanf("%d %d %d",&c[i],&a[i],&n[i]);
		while(1){
			if(c[i]>0&&a[i]>0&&n[i]>0){
				s[i]++;
				c[i]--;
				a[i]--;
				n[i]--;
			}
			 else if(c[i]>1&&a[i]>0){
				 s[i]++;
				 c[i]-=2;
				 a[i]--;
			 }
			 else if(c[i]>2){
				 s[i]++;
				 c[i]-=3;
			 }
			 else break;
		}
	}
	for(i=0;i<N;i++){
	printf("%d\n",s[i]);
	}
	return 0;
}

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

#include<cstdio>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)


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

	vector<long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int answer = 0;
	while (1) {
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 != 0) {
				cout << answer << endl;
				return 0;
			}
			A[i] /= 2;
		}
		answer++;
	}
}

Measured memory_bytes: 256
/*
 *  ॐॐॐॐ
 *  मनुष्य के साहस से बड़ा कोई लक्ष्य नहीं, हारा वही जो लड़ा नहीं ।। 
 *          ---- स्वामी विवेकानंद जी
 */

#include <bits/stdc++.h>
#define debug1(x) cerr<<#x<<' '<<x<<'\n'
#define debug2(x,y) cerr<<#x<<' '<<x<<' '<<#y<<' '<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<'\n'
#define sbc __builtin_popcount
#define pb push_back
#define em emplace
#define emb emplace_back
#define ll long long
int mod = 1e9+7;
using namespace std;

class Timer {
chrono::high_resolution_clock::time_point start_t;
public:
    Timer() {
        start_t=chrono::high_resolution_clock::now();
    }
    ~Timer() {
        auto end_t = chrono::high_resolution_clock::now();
        auto duration = chrono::duration_cast<chrono::milliseconds>(end_t-start_t);
        cerr<<"\nRunTime: "<<duration.count()<<"ms"<<'\n';
    }
};

inline void solve() {
    // Timer timer;
 int n,x,y,i=0,j,d;
 cin>>n>>x>>y;
 int ans[n]={};
 while(++i<=n) {
  j=i;
  while(++j<=n) {
   d=min(j-i,abs(x-i)+abs(j-y)+1);
   ++ans[d];
  }
 }
 i=0;
 while(++i<n) {
  cout<<ans[i]<<'\n';
 }
}


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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

inline int read_int(void)
{
	int i;
	int c;
	i = 0;

	while(1) {
		c = getc(stdin);
		if (c >= '0' && c <= '9') {
			i = c - '0';
			break;
		}
	}
	while(1) {
		c = getc(stdin);
		if (c >= '0' && c <= '9') {
			i = i * 10 + (c - '0');
		} else {
			break;
		}
	}
	return i;
}

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

int main(int argc, char *argv[])
{
	int n, i, c;
	int j;
	int a[200000];
	
	int x, y;
	int min_sq, l_min_sq;
	
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
	//	scanf("%d", &a[i]);
		a[i] = read_int();
	}
	
	qsort(a, n, sizeof(int), compare_int);

	c = 0;

	l_min_sq = -1;
	for (i = 0; i < n; i++) {
		x = a[i];
		if (x == 0) {continue;}
		min_sq = pow(2, (int) log2(x) + 1);

		if (l_min_sq != min_sq) {
			j = n - 1;
		}
		for (;j > i; j--) {
			y = a[j];
			if (y == 0) {continue;}
			if (y == min_sq - x) {
				a[j] = 0;
				c++;
				break;
			}
			if (y > min_sq - x) {
				break;
			}
		}
		l_min_sq = min_sq;
	}

	printf("%d\n", c);
	
	return 0;
}

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = new String(in.readLine());
		String[] ss = s.split(" ");
		ArrayList<Integer> al = new ArrayList<Integer>();
		al.add(Integer.parseInt(ss[0]));
		al.add(Integer.parseInt(ss[1]));
		al.add(Integer.parseInt(ss[2]));
		Collections.sort(al);
		for(int i = 0;i < al.size();i++){
			System.out.print(al.get(i));
			if(i < al.size()-1){
				System.out.print(" ");
			}
		}
		System.out.println();
		
	}

}

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


ll N, Q;
vector<int> link[200000];
ll counter[200000];

void dfs( int i, int parent_i ){
	for ( auto it : link[i] ){
		if ( it != parent_i ){
			counter[it] += counter[i];
			dfs( it, i );
		}
	}
}

int main(){
	cin >> N >> Q;
	for ( int i = 0; i < N-1; i++ ){
		int a, b;
		cin >> a >> b;
		link[b-1].push_back(a-1);
		link[a-1].push_back(b-1);
	}
	for ( int i = 0; i < N; i++ )
		counter[i] = 0;
	
	for ( int i = 0; i < Q; i++ ){
		int p, x;
		cin >> p >> x;
		counter[p-1] += x;
	}
	
	dfs(0, -1);
	
	for ( int i = 0; i < N; i++ ){
		cout << counter[i] << " ";
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 24320
/**
*    author:  yuya1234
*    created: 10.07.2020 15:02:23
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int x;
  cin>>x;

  int sum=0,i=0;

  for(;;)
  {
    i++;
    sum+=i;
    if(sum>=x)break;
  }

  cout<<i<<endl;


  return 0;
}

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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;

    for (auto c: s) {
        if (c == '7') {
            cout << "Yes" << "\n";
            return 0;
        }
    }

    cout << "No" << "\n";
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll w, h, p, q;
	cin >> w >> h;
	
	priority_queue<P> que;
	rep(i, 0, w){cin >> p; que.push(P(-p, 0));}
	rep(j, 0, h){cin >> q; que.push(P(-q, 1));}
	
	ll ans = 0;
	while(!que.empty()){
		ll c = -que.top().first;
		ll f = que.top().second;
		que.pop();
		if(f == 0){
			ans += c*(h+1);
			w--;
		}
		else{
			ans += c*(w+1);
			h--;
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <cstdio>
#include <queue>
#define N 300005
using namespace std;

typedef long long ll;
ll n, ans = -1e19, a[N], mn[N], mx[N];
priority_queue<ll> qn, qx;
int main()
{
	ll i, t;
	cin >> n;
	for (i = 0; i < n * 3; i++) scanf("%lld", &a[i]);
	for (i = 0; i < n; i++) mx[n - 1] += a[i], qx.push(-a[i]);
	for (; i < n * 2; i++) {
		qx.push(-a[i]);
		t = qx.top(), qx.pop();
		mx[i] = mx[i - 1] + a[i] + t;
	}
	for (i = n * 3 - 1; i >= n * 2; i--) mn[n * 2] += a[i], qn.push(a[i]);
	for (; i >= n; i--) {
		qn.push(a[i]);
		t = qn.top(), qn.pop();
		mn[i] = mn[i + 1] + a[i] - t;
	}
	for (i = n - 1; i < 2 * n; i++) ans = max(ans, mx[i] - mn[i + 1]);
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  if (N%10 == 3)
    cout << "bon" << endl;
  else if ((N%10 == 0) || (N%10 == 1) || (N%10 == 6) || (N%10 == 8))
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
}

Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var N = Sarray()[0];
            var K = Sarray()[0];
            var Xi = Sarray();
            var ans = 0L;
            foreach(var xi in Xi)
                ans += 2 * Math.Min(xi, K - xi);
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
N, M = map(int, input().split())
from1 = [False] * N
toN = [False] * N
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        from1[b] = True
    if b == N:
        toN[a] = True
msg = "IMPOSSIBLE"
for i in range(N):
    if from1[i] and toN[i]:
        msg = "POSSIBLE"
        break
print(msg)


Measured memory_bytes: 6132
//In The Name Of God
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e5 + 5, Mod = 1e9 + 7, P = 727, Lg = 22, TOF = 1900, Inf = 3e18 + 10;


int Dp[N][5], A[N][5];
int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n; cin >> n;
      for(int i = 1; i <= n; i++){
            for(int j = 1; j <= 3; j++)
                  cin >> A[i][j];
      }
      for(int i = 1; i < N; i++)
            for(int j = 0; j < 4; j++)
                  Dp[i][j] = -Inf;
      for(int i = 1; i <= n; i++){
            for(int j = 1; j <= 3; j++){
                  for(int k = 1; k <= 3; k++){
                        if(j == k)
                              continue;
                        Dp[i][j] = max(Dp[i][j], Dp[i - 1][k] + A[i][j]);
                  }
            }
      }
      cout << max(Dp[n][1], max(Dp[n][2], Dp[n][3]));
      return 0;
}



Measured memory_bytes: 8064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 2 == 0) {
            System.out.println(n / 2 -1);
        } else {
            System.out.println(n / 2);
        }
    }
}


Measured memory_bytes: 21844
o[1<<20],n,r;main(i){for(;++i<999;)if(!o[i])for(r=i+i;r<1<<20;r+=i)o[r]=1;for(;scanf("%d",&n),n;printf("%d\n",r))for(i=1,r=0;++i<=n/2;)o[i]+o[n-i]||r++;exit(0);}

Measured memory_bytes: 0
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	int a,b,k,i,ck=0;
	cin>>k;
	cin>>a>>b;
	for(i=a ; i<=b ; i++){
		if(i%k==0){
			ck=1;
			break;
			}
		}
	if(ck)cout<<"OK\n";
	else cout<<"NG\n";
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int q,x,i,k,l[N],r[N],j,M=998244353;
long long dp[N*2],n,ans,s[N*2];
int main()
{
	scanf("%d %d",&n,&k);
	for(i=1;i<=k;++i)
		scanf("%d %d",&l[i],&r[i]);
	dp[n]=1;
	s[n]=1;
	for(i=n-1;i>=0;--i)
	{
		for(j=1;j<=k;++j)
			dp[i]=(dp[i]+s[i+l[j]]-s[i+r[j]+1])%M;
		s[i]=(dp[i]+s[i+1])%M;
	}
	cout<<(dp[1]%M+M)%M<<endl;
}


Measured memory_bytes: 6892
input()
x = list(map(float, input().split()))
y = list(map(float, input().split()))
manhattan = 0
euclidian = 0
minkowski3 = 0
chebyshev = 0
for i in range(len(x)):
    manhattan += abs(x[i]-y[i])
    euclidian += (x[i]-y[i])**2
    minkowski3 += abs(x[i]-y[i])**3
    chebyshev = max(chebyshev, abs(x[i]-y[i]))
euclidian = euclidian ** 0.5
minkowski3 = minkowski3 ** (1/3)
print(manhattan, euclidian, minkowski3, chebyshev, sep=('\n'))



Measured memory_bytes: 5644
N=int(input())
A=[int(i) for i in input().split()]
plus=0
zero=0
minus=0
for i in A:
    if i>0:
        plus+=1
    elif i==0:
        zero+=1
    else:
        minus+=1

if zero>0:
    print(sum([abs(i) for i in A]))
else:
    if minus%2==0:
        print(sum([abs(i) for i in A]))
    else:
        B=[abs(i) for i in A]
        print(sum(B)-2*min(B))


Measured memory_bytes: 14412
#include<iostream>
#include<cmath>
using namespace std;
double a, b; int c, d, e; char f;
#define A(D) sin(D*0.01745329252)
#define B(D) cos(D*0.01745329252)
int main() {
	while (true) {
		cin >> c >> f >> d;
		if (c == 0 && d == 0) { break; }
		a += 1.0*A(e) * c;
		b += 1.0*B(e) * c;
		e += d;
	}
	cout << (int)a << endl << (int)b << endl;
	return 0;
}

Measured memory_bytes: 1164
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9+7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


x, y, z = mii()

print(z, x, y)


Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define rep(ii, jj, ll, ss) for(int ii = jj; ii < ll; ii += ss)
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0;

string x;
vector <char> s;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> x;
    rep(i, 0, (int)x.length(), 1) {
        if (x[i] == 'S') s.pb(x[i]);
        else {
            if (!s.empty() && s.back() == 'S') s.pop_back();
            else s.pb(x[i]); 
        }
    }
    for(auto it:s) cerr << it << ' ';
    cerr << '\n';
    cout << s.size();
    time;
}

Measured memory_bytes: 3900
/* valime0 - 10 */
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x1,x2,x3,y1,y2,y3,a,a2,b,b2,c,c2,num,num2,h1,h2,h3,s,ans,k,j;
	int i,n;
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		a = 2 * (x2 - x1);
		b = 2 * (y2 - y1);
		c = (x1 * x1) - (x2 * x2) + (y1 * y1) - (y2 * y2);
		a2 = 2 * (x3 - x1);
		b2 = 2 * (y3 - y1);
		c2 = (x1 * x1) - (x3 * x3) + (y1 * y1) - (y3 * y3);
		num = (b * c2 - b2 * c)/(a * b2 - a2 *b);
		num2 = (c * a2 - c2 * a)/(a * b2 - a2 * b);
		//num = num + 0.0005;
		//num2 = num2 + 0.0005;

		if(num == x3){
			h3 = fabs(num2 - y3);
		}else if(num2 == y3){
			h3 = fabs(num - x3);
		}else{
			k = fabs(num2 - y3);
			j = fabs(num - x3);
			h3 = sqrt(((k*k) + (j*j)));
			//h3 = h3 + 0.0005;
		}
		printf("%.3lf %.3lf %.3lf\n",num,num2,h3);
	}
	
	return 0;
}

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int fact[3001];
// int binExp(int x,int n)
// {
//     int res=1;
//     while(n)
//     {
//         if(n&1) res=(res*x)%mod;
//         x=(x*x)%mod;
//         n>>=1;
//     }
//     return res;
// }
// int modInv(int i) {return binExp(i,mod-2);}
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    
    int n;
    cin>>n;

    vi a,b;
    int x,y;
    f0(i,0,n)
    {
        cin>>x>>y;
        a.pb(x+y);
        b.pb(x-y);
    }

    cout<<max(*max_element(all(a)) - *min_element(all(a)),
        *max_element(all(b)) - *min_element(all(b)));
}

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

vector<int> a(4);
string s("+-*");

int f(int x,int y,int c){
	switch(c){
	case 0:
		return x + y;
	case 1:
		return x - y;
	case 2:
		return x * y;
	}
}

int main(){
	while(cin>>a[0]>>a[1]>>a[2]>>a[3],a[0]||a[1]||a[2]||a[3]){
		sort(a.begin(),a.end());
		int flag = 1;
		do{
			for(int i = 0; i < 3; i++){
				for(int j = 0; j < 3; j++){
					for(int k = 0; k < 3; k++){
						if(f(f(f(a[0],a[1],i),a[2],j),a[3],k) == 10){
							cout<<"(("<<a[0]<<" "<<s[i]<<" "<<a[1]<<")"<<" "<<s[j]<<" "<<a[2]<<")"<<" "<<s[k]<<" "<<a[3]<<endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if(f(f(a[0],a[1],i),f(a[2],a[3],k),j) == 10){
							cout<<"("<<a[0]<<" "<<s[i]<<" "<<a[1]<<") "<<s[j]<<" ("<<a[2]<<" "<<s[k]<<" "<<a[3]<<")"<<endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if(f(f(a[0],f(a[1],a[2],j),i),a[3],k) == 10){
							cout<<"("<<a[0]<<" "<<s[i]<<" ("<<a[1]<<" "<<s[j]<<" "<<a[2]<<")) "<<s[k]<<" "<<a[3]<<endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if(f(a[0],f(f(a[1],a[2],j),a[3],k),i) == 10){
							cout<<a[0]<<" "<<s[i]<<" (("<<a[1]<<" "<<s[j]<<" "<<a[2]<<") "<<s[k]<<" "<<a[3]<<")"<<endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
					}
				}
			}
		}while(next_permutation(a.begin(),a.end()) && flag);
		if(flag) cout<<0<<endl;
	}
	return 0;
}

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

int main()
{
	int N, H, W;
	cin >> N;
	while (N--) {
		cin >> H >> W;
		vector<int> used(26), xma(26), xmi(26, 100), yma(26), ymi(26, 100);
		vector<vector<char>> a(H, vector<char>(W));
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> a[i][j];
				if (a[i][j] != '.') {
					int p = a[i][j] - 'A';
					used[p] = 1;
					xma[p] = max(xma[p], i);
					xmi[p] = min(xmi[p], i);
					yma[p] = max(yma[p], j);
					ymi[p] = min(ymi[p], j);
				}
			}
		}
		vector<vector<int>> d(26, vector<int>(26, 1000));
		for (int i = 0; i < 26; i++) {
			d[i][i] = 0;
		}
		bool sus = false;
		for (int i = 0; i < 26; i++) {
			if (used[i]) {
				for (int x = xmi[i]; x <= xma[i]; x++) {
					for (int y = ymi[i]; y <= yma[i]; y++) {
						if (a[x][y] == '.') {
							sus = true;
						}
						else if (a[x][y] - 'A' != i) {
							d[i][a[x][y] - 'A'] = -1;
						}
					}
				}
			}
		}
		for (int k = 0; k < 26; k++) {
			for (int i = 0; i < 26; i++) {
				for (int j = 0; j < 26; j++) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		for (int i = 0; i < 26; i++) {
			if (d[i][i] < 0) {
				sus = true;
				break;
			}
		}
		cout << (sus ? "SUSPICIOUS" : "SAFE") << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#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() {
  string s, t;
  cin >> s >> t;
  bool ok = false;
  rep(i, s.size()) {
    bool same = true;
    rep(j, s.size()) if (s[(i+j)%s.size()] != t[j]) same = false;
    if (same) ok = true;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
import fractions
n, m = map(int,input().split())
s = input()
t = input()
q = fractions.gcd(n, m)
l = n * m // q #lcm(n, m)
p = int(l/n * l/m / fractions.gcd(l/n, l/m)) #lcm(l/n, l/m)
for i in range(0, int(l/p)):
  if s[i * p//(l//n)] != t[i * p//(l//m)]:
    print('-1')
    exit()
print(l)

Measured memory_bytes: 5560
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


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

  int N; std::cin >> N;

  std::vector<ll> A(N), B(N), C(N);
  rep(i,N) std::cin >> A[i];
  rep(i,N) std::cin >> B[i];
  rep(i,N) std::cin >> C[i];

  std::sort( all(A) );
  std::sort( all(B) );
  std::sort( all(C) );

  ll ans = 0;
  rep(i,N) {
    auto a = std::lower_bound( all(A), B[i] );
    auto c = std::upper_bound( all(C), B[i] );
    ans += std::distance(A.begin(), a) * std::distance(c, C.end());
  }

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sigma_size 30
#define max_size (int)(1e5+10)
#define MAX (int)(1e5+7)
int qread()
{
	char c; int s=0,t=1; while ((c=getchar())<'0' || c>'9') (c=='-' && (t=-1));
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*t;
}


int dest = 0;
void get_dest(int N){
	for ( int i = 1 ; i <= N ; i++ )
		dest |= (1<<i);
}

int N , M;
int a[1005] , b[1005] ,c[1005][15];
bool flag[15];

const int inf = 1 << 30;
int dp[1<<15];
int vis[1<<15] = {0};
int num[1<<15],cnt = 0 ;
void dfs ( int s )
{
	if ( dp[s] != inf && vis[s] == 1 )
		return;
	vis[s] = 1;
	int res = dp[s];
	for ( int i = 0 ; i < cnt ; i++ )
	{
		int x = num[i];
		int tmp = s&(~x);
		if ( tmp != s ) 
		{	
			dfs(tmp);
			dp[s] = min ( dp[s] , dp[tmp]+dp[x] ) ;
		}
	}
}
int main ()
{
	N = qread();
	M = qread();
	get_dest(N);
	for ( int i = 1 ; i <= M ; i++ )
	{
		a[i] = qread();
		b[i] = qread();
		for ( int j = 1 ; j <= b[i] ; j++ )
		{
			int x = qread();
			c[i][x] = 1;
			flag[x] = true;
		}
	}
	for ( int i = 1 ; i <= N ; i++ )
		if ( flag[i] == false )
		{
			cout << "-1" << endl;
			return 0;
		}
	

	for ( int i = 0 ; i <= dest ; i++ )	dp[i] = inf;
	dp[0] = 0;
	for ( int i = 1 ; i <= M ; i++ )
	{
		int s = 0;
		for ( int j = 1 ; j <= N ; j++ )
			if (c[i][j])
				s |= (1<<j) ;
		if ( dp[s] == inf )
			num[cnt++] = s;
		dp[s] = min ( dp[s] , dp[0]+a[i] );
	}
	dfs(dest);
	cout << dp[dest] << endl;
}

Measured memory_bytes: 3684
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

def main():
    n = i2n()
    n = (10000 - n) % 1000
    print(n)

main()


Measured memory_bytes: 9428
n = int(input())
a = [] * n
ans = 1

a = list(map(int, input().split()))

if a.count(0) > 0:
  ans = 0
else:
  for i in range(n):
    if ans > 10**18:
      break
    else:
      ans *= a[i]

if ans == 0:
  print(ans)
elif ans > 10**18:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 21592
#include <iostream>
#include<algorithm>
#include <cmath>
#include<vector>
#include<cstdlib>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n <= 111)cout << 111;
	else if (n <= 222)cout << 222;
	else if (n <= 333)cout << 333;
	else if (n <= 444)cout << 444;
	else if (n <= 555)cout << 555;
	else if (n <= 666)cout << 666;
	else if (n <= 777)cout << 777;
	else if (n <= 888)cout << 888;
	else if (n <= 999)cout << 999;

}

Measured memory_bytes: 256
#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() {
    ll ans = 0;
    int n;
    cin >> n;

    ll block;
    block = n / 15;
    ans += 60 * block + 120 * (block) *(block - 1) / 2;

    ll amari = n % 15;
    for (ll i = 1; i <= amari; i++) {
        if (i % 3 != 0 && i % 5 != 0)
            ans += i + 15 * block;
    }

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


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

int main(){

    int N, M, K;
    cin >> N >> M >> K;
    vector<long long int> A(N+1);
    rep (i, N) cin >> A[i+1];
    vector<long long int> B(M+1);
    rep (i, M) cin >> B[i+1];

    rep (i, N) A[i+1] += A[i];
    rep (i, M) B[i+1] += B[i];

    int ans = 0;
    rep (i, N+1){
        int left = 0;
        int right = M+1;
        if (K < A[i]) continue;
        while (right > left + 1){
            int mid = left + (right - left)/2;
            if (K-A[i] < B[mid]) right = mid;
            else left = mid;
        }
        ans = max(ans,i+left);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6400
import java.io.*;
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int h[] = new int[N+1];
    for(int i = 1; i<=N; i++){
      h[i] = sc.nextInt(); 
    }
    int cnt = 0;
    for(int i = 1; i<=N; i++){
      boolean canseeocean = true;
      for(int j = 1; j<i; j++){
        if(h[j] > h[i]){
          canseeocean = false; 
        }
      }
      if(canseeocean){
        cnt++; 
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 35728
N = gets.to_i
as = gets.split.map(&:to_i)

odds_count = 0
four_count = 0
as.each do |a|
  odds_count += 1 if a.odd?
  four_count += 1 if a % 4 == 0
end

a_count = as.count

ans = ""
if a_count.odd?
  if odds_count - 1 <= four_count
    ans = "Yes"
  else
    ans = "No"
  end
else
  if odds_count <= four_count
    ans = "Yes"
  else
    ans = "No"
  end
end

puts ans

Measured memory_bytes: 8452
//Volume0-0075
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//declare
		String[] s;
		int      No;
		double   weight,height;

        //input
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	s = sc.nextLine().split(",");
        	No     = Integer.parseInt(s[0]);
        	weight = Double.parseDouble(s[1]);
        	height = Double.parseDouble(s[2]);

        	//calculate
        	if(weight / Math.pow(height,2) >= 25){

        		//output
        		System.out.println(No);
        	}
        }
	}
}

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

int main(){
    int cases, num[200];
    cin >> cases;
    for(int i = 0; i < cases; ++i){
        cin >> num[i];
    }
    for(int i = cases - 1; i >= 0; --i){
        if(i != 0){
        cout << num[i] << " ";
        }
        else{
            cout << num[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
    int n;
    long long k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    long long sum1,sum2,ans;
    sum1 = sum2 = ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i] > a[j]){
                sum1++;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i] < a[j]){
                sum2++;
            }
        }
    }

    ans += k*sum1%MOD;
    ans += (k*(k-1)/2)%MOD*sum2;
    ans %= MOD;
    cout << ans << endl;
}


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() {
  double n, m;
  cin >> n >> m;
  vector<double> as(n);
  double sum = 0;
  rep(i, n) {
    cin >> as[i];
    sum += as[i];
  }

  double d = (1/(4*m))*sum;

  sort(as.begin(), as.end());
  string ans = "Yes";
  rep(i, m) {
    double a = as[n-1-i];
    if (a < d) {
      ans = "No";
      break;
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
int main()
{
    fastio;
    int n,k,i;
    cin>>n>>k;
    for (i=k-n+1;i<k;i++)
        cout<<i<<" ";
    for ( ;i<n+k;i++)
        cout<<i<<" ";
    cout<<endl;
}

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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    vector<int> list(3);
    int K;
    for (int i = 0; i < 3; i++)
        cin >> list[i];
    cin >> K;
    sort(list.begin(), list.end());
    cout << list[2] * pow(2, K) + list[1] + list[0];
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N_MAX = 3 * 100000;
const int MOD = 1000 * 1000 * 1000 + 7;

int factm[N_MAX + 1];
int ifactm[N_MAX + 1];

int addm(int a, int b)
{
	return (0LL + a + b) % MOD;
}

int subm(int a, int b)
{
	return addm(a, MOD - b);
}

int mulm(int a, int b)
{
	return (1LL * a * b) % MOD;
}

int powm(int a, int n)
{
	if (n == 0) {
		return 1;
	}
	else {
		int ans = powm(mulm(a, a), n / 2);
		if (n & 1) {
			ans = mulm(ans, a);
		}
		return ans;
	}
}

int invm(int a)
{
	return powm(a, MOD - 2);
}

void init()
{
	factm[0] = 1;
	for (int i = 1; i <= N_MAX; ++i) {
		factm[i] = mulm(i, factm[i - 1]);
	}

	ifactm[N_MAX] = invm(factm[N_MAX]);
	for (int i = N_MAX - 1; i >= 0; --i) {
		ifactm[i] = mulm(i + 1, ifactm[i + 1]);
	}
}

int combm(int n, int k)
{
	int ans = 1;
	for (int i = 0; i < k; ++i) {
		ans = mulm(ans, n - i);
	}
	ans = mulm(ans, ifactm[k]);

	return ans;
}

int main()
{
	init();

	int n, a, b;
	cin >> n >> a >> b;

	int ans = powm(2, n);
	ans = subm(ans, 1);
	ans = subm(ans, combm(n, a));
	ans = subm(ans, combm(n, b));
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, j, y2, f;
  double y;
  cin >> x;
  y = x / 1.08;
  y = floor(y);
  j = max(0, (int)(y-5));
  f = 0;
  for (int i=j; i<j+10; i++) {
    y2 = (int)(i * 1.08);
    if (x == y2) {
      cout << i << endl;
      f = 1;
      break;
    }
  }
  
  if (f == 0) {
    cout << ":(" << endl;
  }
}


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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int main() {
  int n;
  int test;
  scanf("%d", &test);
  while (scanf("%d", &n) > 0) {
    int prev = -1;
    int upper = 0;
    int lower = 0;
    REP(i, n) {
      int next;
      scanf("%d", &next);
      if (prev == -1) { prev = next; }
      if (prev > next) {
        lower = max(lower, abs(prev - next));
      } else {
        upper = max(upper, abs(prev - next));
      }
      prev = next;
    }
    printf("%d %d\n", upper, lower);
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N;
	cin >> N;
	long long ans = 1e18;
	for (long long i = 1; i * i <= N; i++){
		if (N % i != 0) {
			continue;
		}
		long long tmp = N / i;
		ans = min(ans, i + tmp - 2);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl
#define De(...)
using namespace std; 

int _; 
 
int n,m,ans=0,ma=-1,mb=-1;
long long k,a[200050],b[200050];

inline bool isPrime(int x)
{
	for(int i=2;i*i <= x;i++)
		if(x%i == 0)
			return false;
	return true;
}

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	for(int i=0;i<m;i++)
		scanf("%d",b+i);
	for(int i=0;i<n;i++)
		if(k >= a[i])
		{
			ma++;
			k -= a[i];
			ans++;
		} 
		else
			break;
	for(int i=0;i<m;i++)
		if(k >= b[i])
		{
			mb++;
			k -= b[i];
			ans++;
		}
		else
			break;
	while(ma >= 0)
	{
		k += a[ma];
		ma--;
		for(int i=mb+1;i<m;i++)
			if(k >= b[i])
			{
				mb++;
				k -= b[i];
			}
			else
				break;
		ans=max(ans,ma+mb+2);
	} 
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6876
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

//　約数を列挙して返す。 ソートはされていない
vector<long> divisors(long x){
    vector<long> l;
    for(int i=1; i*i<=x; i++){
        if(x % i == 0) {
            l.push_back(i);
            l.push_back(x/i);
        }
    }
    return l;
}

int main(){
    int N, M;
    cin >> N >> M;
    long ans ;
    for(long i : divisors(M)){
        if(M % i == 0 && M / i >= N) ans = max(ans, i);
    }    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = {}
r = {}
xc = 0
for x in input().split():
    xi = int(x)
    lx = xc + xi
    if lx in l:
        l[lx] += 1
    else:
        l[lx] = 1
    rx = xc - xi
    if rx in r:
        r[rx] += 1
    else:
        r[rx] = 1
    xc += 1
c = 0
for x in l:
    if x in r:
        c += l[x] * r[x]
print(c)


Measured memory_bytes: 59628
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}
 
     Power Function Modulo P
 
ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}
 
 
   factorial
 
ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem
 
ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
 
 
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).
 
    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }
 
    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }
 
    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient
 
ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}
 
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
 
 long double r;
 cin>>r;
 cout<<setprecision(10)<<2*PI*r<<endl;
 
return 0;
}
 

Measured memory_bytes: 3776
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll h,w,m;cin>>h>>w>>m;
  vector<P>x(h),y(w);
  rep(i,0,h)x[i]=MP(0,i);
  rep(i,0,w)y[i]=MP(0,i);
  set<P>st;
  rep(i,0,m){
    ll a,b;cin>>a>>b;a--;b--;
    x[a].fi++;
    y[b].fi++;
    st.emplace(a,b);
  }
  sort(ALLR(x));
  sort(ALLR(y));
  ll nx=0,ny=0;
  while(nx<h&&x[nx].fi==x[0].fi)nx++;
  while(ny<w&&y[ny].fi==y[0].fi)ny++;
  rep(i,0,nx)rep(j,0,ny){
    ll px=x[i].se,py=y[j].se;
    //cout<<x[i] spa y[j]<<endl;
    if(!st.count(MP(px,py))){
    cout<<x[0].fi+y[0].fi<<endl;
      return 0;
    }
  }
  cout<<x[0].fi+y[0].fi-1<<endl;
  return 0;
}

Measured memory_bytes: 31448