akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

const int P = 1000000007;
int n, fac[1000005], ifac[1000005];

int power(int a, int x) {
	int ans = 1;
	for (; x; x >>= 1, a = 1ll * a * a % P)
		if (x & 1) ans = 1ll * ans * a % P;
	return ans;
}

int binom(int n, int m) {
	return 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;
}

int main() {
	scanf("%d", &n);
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	ifac[n] = power(fac[n], P - 2);
	for (int i = n; i; --i) ifac[i - 1] = 1ll * ifac[i] * i % P;
	int ans = 0, pw = 1;
	for (int k = 1; k <= n; ++k) {
		pw = pw * 2 % P;
		int invk = 1ll * ifac[k] * fac[k - 1] % P;
		ans = (ans + 1ll * ifac[k] * ifac[n - k] % P * (pw - (k & 1 ? -1 : 1)) % P * invk) % P;
	}
	ans = 1ll * ans * power(3, P - 2 - n) % P * fac[n - 1] % P;
	printf("%d\n", ans);
}


Measured memory_bytes: 8064
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int A, B, X;
    cin >> A >> B >> X;
    
    if(A <= X && X <= A + B){
        p("YES");
    }else{
        p("NO");
    }
    
    return 0;
}

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

int main(){
  int H,N,sum=0;
  cin >> H >> N;
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    sum+=A;
  }
  if(sum>=H){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3612
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        

        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var vals = Console.ReadLine().Split(' ').
                Select(x => int.Parse(x)).ToArray();

            int X = vals[0];
            int N = vals[1];
            if (N == 0)
            {
                Console.WriteLine(X);
                Console.Out.Flush();
                return;
            }
            var p= vals = Console.ReadLine().Split(' ').
                Select(x => int.Parse(x)).ToArray();
            var cheker = new bool[100 + 1];
            foreach (var item in p)
            {
                cheker[item] = true;
            }

            var ans = 0;
            for (int i = 0; i < 101; i++)
            {
                if ( X-i<=0 || !cheker[X - i])
                {
                    ans = X - i;
                    break;
                }
                if (X+i>100 || !cheker[X + i])
                {
                    ans = X + i;
                    break;
                }
            }



            Console.WriteLine(ans);
            Console.Out.Flush();
        }
        



    }
}




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

using namespace std;
typedef long long ll;

#define MAX 100001
ll INF = 1LL * 1e14;
int a[3*MAX];
ll head[MAX], tail[MAX];
priority_queue<ll, vector<ll>, greater<ll> > hpq;
priority_queue<ll> tpq;


int main(void) {
    int i, n, cnt = 0;
    scanf("%d", &n);
    for(i=0; i<3*n; i++) {
        scanf("%d", a+i);
        if(i < n) {
            head[0] += a[i];
            hpq.push(a[i]);
        }
        else if(i >= 2*n) {
            tail[0] += a[i];
            tpq.push(a[i]);
        }
    }

    for(i=1; i<=n; i++) {
        hpq.push(a[n-1+i]);
        head[i] = head[i-1] + a[n-1+i] - hpq.top();
        hpq.pop();
        tpq.push(a[2*n-i]);
        tail[i] = tail[i-1] + a[2*n-i] - tpq.top();
        tpq.pop();
    }

    ll ans = -INF;
    for(i=0; i<=n; i++) ans = max(ans, head[i] - tail[n-i]);
    printf("%lld\n", ans);
return 0;
}

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

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

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b,c; cin>>a>>b>>c;
	if(a+c==2*b) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
class edge:
    def __init__(self, u, v):
        self.u = u
        self.v = v
    def min(self):
        return min(self.u, self.v)
    def max(self):
        return max(self.u, self.v)

N = int(input())
 
edge_list = []
for i in range(N - 1):
    u, v = map(int, input().split())
    edge_list.append(edge(u - 1, v - 1))
 
ver_num = int(N * (N + 1) * (N + 2) / 6)
 
edge_num = 0
for e in edge_list:
    edge_num += (N + 1 - (e.max() + 1)) * (e.min() + 1)
    
print(ver_num - edge_num)


Measured memory_bytes: 54888
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int inf=0x3f3f3f3f;
#define N 100010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,ans;
pair<int,int> a[N];
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		int x=read(),L=read();
		a[i]=make_pair(x+L,x-L);
	}
	sort(a+1,a+n+1);
	int now=-inf;
	for(int i=1;i<=n;++i){
		if(a[i].second>=now){
			++ans;
			now=a[i].first;
		}
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 4508
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {

  int reserves[1000] = {0};
  int a, b, N;
  cin >> a >> b >> N;

  rep(i, N) {
    int start, finish;
    cin >> start >> finish;
    for(int j = start; j < finish; j++ ) {
      reserves[j] = 1;
    }
  }

  bool isConflict = false;
  for(int j = a; j < b; j++ ) {
    if (reserves[j] == 1) {
      isConflict = true;
    } 
  }

  if (isConflict) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
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 print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[300010];
    rep(i,0,3*N) cin >> A[i];
    priority_queue<ll, vector<ll>, greater<ll> > pq1;
    ll tt = 0;
    rep(i,0,N){
        pq1.push(A[i]);
        tt += A[i];
    }
    ll v1[300010] = {};
    v1[N-1] = tt;
    rep(pos,N,2*N){ //[0, pos), [pos, N)
        if(pq1.top() < A[pos]){
            tt += A[pos] - pq1.top(); 
            pq1.pop();
            pq1.push(A[pos]);
        }
        v1[pos] = tt;
    }
    ll v2[300010] = {};
    tt = 0;
    priority_queue<ll, vector<ll>, less<ll> > pq2;
    rep(i,2*N,3*N){
        pq2.push(A[i]);
        tt += A[i];
    }

    v2[2*N-1] = tt;
    rrep(pos, 2*N-1, N){
        if(pq2.top() > A[pos]){
            tt -= pq2.top() - A[pos];
            pq2.pop();
            pq2.push(A[pos]);
        }
        v2[pos-1] = tt;
    }
    ll ans = -INF;
    rep(i,N-1,2*N) ans = max(ans, v1[i] - v2[i]);
    print(ans);
    

    
}

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

int main()
{
   int x,a,b;
   int sum;
   scanf("%d%d%d",&x,&a,&b);
   sum=x-a;
   x=x-a;
   int n=x/b;
   sum=sum-n*b;
   printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  a[0] = b[0] = 0;
  for(int i(1);i<n;i++){
    cin >> a[i];
    b[i] = 0;
  }

  for(int i(1);i<n;i++){
    b[a[i]-1]++;
  }
  for(int i(0);i<n;i++)	cout << b[i] << endl;
}

Measured memory_bytes: 5160
use io::*;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let a: i32 = sc.next();
    let b: i32 = sc.next();

    let ans = (a - 1) * (b - 1);
    println!("{}", ans);
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    vector<string>v;
    for(int i=1; i<=9; i++)
    {
        string temp="0";
        temp+=(i+48);
        v.push_back(temp);
    }
    v.push_back("10");
    v.push_back("11");
    v.push_back("12");
    int cnt=0,x=0,y=0;
    for(int i=0; i<12; i++)
    {
        if(s[0]==v[i][0] && s[1]==v[i][1])
            x=1;
    }
    for(int i=0; i<12; i++)
    {
        if(s[2]==v[i][0] && s[3]==v[i][1])
            y=1;
    }
    if(x && y)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(x)
        cout<<"MMYY"<<endl;
    else if(y)
        cout<<"YYMM"<<endl;
    else
        cout<<"NA"<<endl;


    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int n,m;
int miti[52][52];
int dk[52];
stack<int> s;
int ans=0;
bool  visited[8];

int  dfs(int v){
   
    bool av=true;
    rep(i,n){
        if(visited[i]==false){av=false;}
    }
    
    if(av){return 1;}
    int ret=0;
    for(int i=0;i<n;i++){
        
        if(miti[v][i]==false)continue;
        if(visited[i]==true)continue;
        visited[i]=true;
        ret+=dfs(i);
        visited[i]=false;
        
        
        
    }
    return ret;
    
    
   
}


int main(){
  
    cin>>n>>m;
    
    
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        miti[a-1][b-1]=1;
        miti[b-1][a-1]=1;
    }

    rep(i,8){visited[i]=false;}
    visited[0]=true;
    cout<<dfs(0)<<endl;
    
    return 0;
}


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

const int h_mv[4] = {-1, +1, 0 , 0};
const int w_mv[4] = {0, 0, -1 , +1};

char A[1002][1002];


bool white_check(int h, int w) {
	for (int i = 0; i < 4; i++) {
	if (A[h+h_mv[i]][w+w_mv[i]]=='.')
			return true;
	}
	return false;
}

int main(void) {
	int H, W;
	cin >> H >> W;

	queue <pair <int, int> > blacks;
	for (int h = 0; h <= H+1; h++) {
		A[h][0] = A[h][W+1] = '#';
	}
	for (int w = 0; w <= W+1; w++) {
		A[0][w] = A[H+1][w] = '#';
	}

	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			cin >> A[h][w];
			if (A[h][w]=='#') {
				blacks.push(make_pair(h, w));
			}
		}
	}
	int ans = 0;
	queue <pair <int, int> > next_blacks = blacks;
	while (next_blacks.size() > 0) {
		blacks = next_blacks;
		queue<pair<int,int>>().swap(next_blacks);
		
		bool turns = false;
		while (blacks.size() > 0) {
			pair <int, int> a = blacks.front();
			int h = a.first;
			int w = a.second;
			blacks.pop();
			if (white_check(h, w)) {
				turns = true;

				for (int i = 0; i < 4; i++) {
					int nh = h+h_mv[i];
					int nw = w+w_mv[i]; 
					if (A[nh][nw]=='.') {
						next_blacks.push(make_pair(nh, nw));
						A[nh][nw] = '#';
					}
				}
			}
		}
		if (turns) ans++;
	}

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



Measured memory_bytes: 17552
import sys
input = sys.stdin.readline
n = int(input())
h = tuple(map(int,input().split()))

dp = [0]*n
#print(dp)

dp[1] = abs(h[1]-h[0])
#print(dp)

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
#print(dp)

print(dp[-1])

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

using namespace std;
const int MAX=1e3,MOD=1e9+7;
int n,m;
char arr[MAX+2][MAX+2];
long long dp[MAX+2][MAX+2];

long long solve(int x,int y){
if(x>n || y>m) return 0;
if(x==n&&y==m) return 1;
if(arr[x][y]=='#') return 0;
if(dp[x][y]!=-1) return dp[x][y];
long long ans=0;
ans+=solve(x+1,y);
ans%=MOD;
ans+=solve(x,y+1);
ans%=MOD;
return dp[x][y]=ans;
}

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>arr[i][j];
    memset(dp,-1,sizeof dp);
    cout<<solve(1,1);
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
using namespace std;
bool isBlocked[20][20];
int solve(int x,int y){
	if(isBlocked[x][y]) return 0;
	if(x==1&&y==1) return 1;
	if(x==0||y==0) return 0;
	return solve(x-1,y)+solve(x,y-1);
}
int main() {
	int a,b,n,x,y;
	while(true){
		cin >> a >> b;
		if(a==0) return 0;
		cin >> n;
		for(int i=0;i<20;i++) for(int j=0;j<20;j++) isBlocked[i][j]=false;
		for(int i=0;i<n;i++){
			cin >> x >> y;
			isBlocked[x][y]=true;
		}
		cout << solve(a,b) << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mxn =  5e5+5;
const int inf = 0x3f3f3f3f;
typedef long long ll;
const ll mod =998244353; 
int n,m;
ll dp[mxn],v[mxn];
//dp[i] : 装满i容量的物品 的方案数 

int main()
{

	ll ans = 0;
	memset(dp,0,sizeof(dp));
	scanf("%d%d",&n,&m);
	for(int i = 1;i<=n;i++)scanf("%lld",&v[i]);
	
	for(int i  = 1;i<=n;i++)
	{
		dp[0] ++;
		for(int j = m;j>=v[i];j--)
		{
			dp[j] = ( dp[j]+dp[j-v[i]])%mod;
		}
		ans = (ans + dp[m])%mod;
	}
	printf("%lld",ans);
	
	
	return 0;
}

Measured memory_bytes: 6016
import sys
n = int(input())
if n == 2:
	print(1)
	sys.exit()
divs = []
i = 2
while i*i <= n:
	if n%i == 0:
		divs.append(i)
		if i*i < n:
			divs.append(n//i)
	i += 1
divs.append(n)

ans = set()
i = 2
while i*i <= n-1:
	if (n-1)%i == 0:
		ans.add(i)
		if i*i < (n-1):
			ans.add((n-1)//i)
	i += 1
ans.add(n-1)

for d in divs:
	tmp = n
	while tmp%d == 0:
		tmp //= d
	if tmp%d == 1:
		ans.add(d)
print(len(ans))

Measured memory_bytes: 40428
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    multiset<int> s;

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        s.insert(a);
    }

    int m;
    cin >> m;

    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;

        auto it = s.find(a);
        if (it == s.end()) {
            cout << "NO" << endl;
            return 0;
        }
        s.erase(it);
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 9600
n = int(input())
cnt = 0
isOK = False
for i in range(n):
  x,y = map(int,input().split())
  if x==y:
    cnt += 1
  else:
    cnt = 0
  if cnt>=3:
    isOK = True
    break
#if cnt >= 3:
#  isOK = True

if isOK:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 9164
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let x = v[0];
	let y = v[1];
	let z = v[2];
	if x%(y+z) >= z {
		println!("{}", x/(y+z));
	}else{
		println!("{}", x/(y+z) - 1);
	}
}

Measured memory_bytes: 4352
import fractions
n, m = map(int,input().split())
s = list(map(str,input()))
t = list(map(str,input()))
k = 0
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[0] != t[0]:
    print('-1')
    break
  elif q == 1:
    print(l)
    break
  elif s[i * p//(l//n)] != t[i * p//(l//m)]:
    print('-1')
    break
  else:
    k = k + 1

if k == l/p:
  print(l)

Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
int main () {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a;i <= b; i ++) {
    string s, t;
    s = to_string(i);
    t = s;
    reverse(begin(t),end(t));
    if(s == t) ans++;
  }
  cout << ans << endl;
}

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

int n;
int a[16][16] ,lg2[(1<<16)+1];
long long dp[1<<16];

long long solve(int bits){
    if(bits == (1<<n)-1)
        return 0;
    auto&ret = dp[bits];
    if(~ret)
        return ret;

    int inv_bits = ((1<<n)-1)^bits; ret = -1e18;
    for(int i=inv_bits; i; i=(i-1)&inv_bits){
        long long grp_cost = 0LL;
        for(int j=i; j; j-=(j&-j))
        for(int k=i; k!=j; k-=(k&-k))
            grp_cost += a[lg2[j&-j]][lg2[k&-k]];
        ret = max(ret ,grp_cost+solve(bits|i));
    }
    return ret;
}

int main()
{
    for(int i=0; i<=16; i++)
        lg2[1<<i] = i;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    for(int j=0; j<n; j++)
        scanf("%d",&a[i][j]);
    memset(dp ,-1 ,sizeof dp);
    printf("%lld\n",solve(0));
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;
const int MOD=1000000007;
int h,w;
char a[1005][1005];
long long f[1005][1005];

int main()
{
    cin>>h>>w;
    for (int i=0;i<h;i++) cin>>a[i];
    f[0][0]=1;
    for (int i=0;i<h;i++)
    for (int j=0;j<w;j++)
    if (a[i][j]=='.')
    {
        f[i+1][j]=(f[i][j]+f[i+1][j])%MOD;
        f[i][j+1]=(f[i][j+1]+f[i][j]) % MOD;
    }
    cout<<f[h-1][w-1];
    return 0;
}


Measured memory_bytes: 9088
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

set<char> st({'A', 'T', 'C', 'G'});

int main() {
    int n, q, l, r;
    cin >> n >> q;
    string s;
    cin >> s;
    
    int dp[n+1];
    dp[0] = 0;
    for(int i=1;i<n;++i) {
        if(s[i-1] == 'A' && s[i] == 'C') dp[i] = 1 + dp[i-1];
        else dp[i] = dp[i-1];
    }

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define MAXN 1005

using namespace std;

int main ()
{
	int N;
	scanf("%d",&N);
	N *= 2;
	static int a[MAXN];
	int i;
	for (i = 0; i < N; i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+N);
	int res = 0;
	for (i = 0; (i+1) < N; i+=2) res += a[i];
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, i, j, no[2], point[2], z, team[100] = { 0 };
    scanf("%d", &n);
    
    if(n){
        int prank[n];
        
        for(i = 0; i < n * (n - 1) / 2; i++){
            scanf("%d %d", &no[0], &no[1]);
            scanf("%d %d", &point[0], &point[1]);
            if(point[0] > point[1])
                team[no[0] - 1] += 3;
            else if(point[0] < point[1])
                team[no[1] - 1] += 3;
            else {
                team[no[0] - 1]++;    team[no[1] - 1]++;
            }
        }
        
        for(i = 0; i < n; i++){
            prank[i] = team[i];
        }
        for(i = 0; i < n - 1; i++){
            for(j = i + 1; j < n; j++){
                if(prank[i] < prank[j]){
                    z = prank[i];
                    prank[i] = prank[j];
                    prank[j] = z;
                }
            }
        }
        
        for(i = 0; i < n; i++){
            for(j = 0; j < n; j++){
                if(team[i] == prank[j]){
                    printf("%d\n", ++j);
                    break;
                }
            }
        }
        
    }
    
    return (0);
}

Measured memory_bytes: 600
#include<stdio.h>
int main()
{
	int h1,m1,h2,m2,k;
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	printf("%d",(h2-h1)*60+m2-m1-k);
	return 0;
}

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

*/
void solve(long long N, deque<long long> A){
	long long ans = 0;
	int v = 1;
	
	while( A.size() ){
		if( A.size() and v == A.front() ){
			v++;
			A.pop_front();
			continue;
		}
		
		if( A.size() and v > A.front() ){
			A.pop_front();
			continue;
		}
		if( A.front() % v == 0 ){
			//cout << "look:" << A.front() << " v:" << v << " ans:" << (A.front() / v - 1) << endl;
			ans += (A.front() / v - 1);
			A.front() = 1;
		}else{
			//cout << "look:" << A.front() << " v:" << v << " ans:" << (A.front() / v ) << endl;
			ans += A.front() / v;
			A.front() = 1;
		}
	}
	cout << ans << endl;
	
		
}



int main(){	
	ios::sync_with_stdio(false);
	long long N;
	cin >> N;
	deque<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> A[i];
	}
	solve(N, A);
	return 0;
}

Measured memory_bytes: 1920
N, K = map(int, input().split())

d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

A = sum(A, [])
A = list(set(A))

ans = N
for i in range(N+1):
    if i in A:
        ans = ans - 1

print(ans)


Measured memory_bytes: 9208
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int sx; int sy; int tx; int ty;
	while (~scanf("%d%d%d%d", &sx, &sy, &tx, &ty)) {
		int x = tx - sx, y = ty - sy;
		string ans;
		rep(i, x)
			ans += 'R';
		rep(i, y)
			ans += 'U';
		rep(i, x)
			ans += 'L';
		rep(i, y)
			ans += 'D';
		ans += 'L';
		rep(i, y + 1)
			ans += 'U';
		rep(i, x + 1)
			ans += 'R';
		ans += 'D';
		ans += 'R';
		rep(i, y + 1)
			ans += 'D';
		rep(i, x + 1)
			ans += 'L';
		ans += 'U';
		puts(ans.c_str());
	}
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    cin >> A >> B >> C ;
    int pre=0;
    pre = B/A;
    if(pre >= C)
    {
        cout << C << endl;
    }
    else
    {
        cout << pre << endl;
    }
}

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

map<string,bool> mp;

int n,k;
string c[10];
bool used[10];

void dfs(int num,string s){
	if(num == k){
		mp[s] = true;
		return;
	}
	for(int i = 0;i < n;i++){
		if(!used[i]){
			used[i] = true;
			dfs(num + 1,s + c[i]);
			used[i] = false;
		}
	}
}

int main(){
	while(cin >> n >> k,n){
		mp.clear();
		for(int i = 0;i < n;i++) cin >> c[i];
		dfs(0,"");
		cout << mp.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3300
from copy import copy

N = int(input())

XtoBR = {}
YtoBR = {}
Rnumber = {}
for i in range(N):
    a, b = map(int, input().split())

    Rnumber[i] = (a, b)
    XtoBR[a] = ("R", i)
    YtoBR[b] = ("R", i)

Bnumber = {}
for i in range(N):
    a, b = map(int, input().split())

    Bnumber[i] = (a, b)
    XtoBR[a] = ("B", i)
    YtoBR[b] = ("B", i)

X_list = sorted(list(XtoBR.keys()))

ClearX = {}
clear = set()

ans = 0
for x in reversed(X_list):
    if(XtoBR[x][0] == "B"):
        clear.add(XtoBR[x][1])
    else:
        ClearX[XtoBR[x][1]] = copy(clear)

Y_list = sorted(list(YtoBR.keys()))

clear = set()
for y in reversed(Y_list):
    if(YtoBR[y][0] == "B"):
        clear.add(YtoBR[y][1])
        continue

    n = YtoBR[y][1]
    allclear = clear & ClearX[n]
    # print(clear, ClearX[n], allclear)
    if(len(allclear) == 0):
        continue

    tmp_x = 2 * N + 1
    tmp = 0
    # print(allclear)
    for i in allclear:
        if(Bnumber[i][0] < tmp_x):
            tmp = i
            tmp_x = Bnumber[i][0]

    ans += 1
    clear.remove(tmp)

print(ans)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
int H, W, M;
set<i_i> st;
 
void input() {
    cin >> H >> W >> M;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        st.insert({a, b});
    }
}
 
void solve() {
    map<int, int> mph, mpw;
    int hmaxval = 0;
    int wmaxval = 0;
    vector<int> hmax, wmax;
    for(auto tmp : st) {
        chmax(hmaxval, ++mph[tmp.first]);
        chmax(wmaxval, ++mpw[tmp.second]);
    }
    for(auto tmp : mph) {
        if(hmaxval == tmp.second) hmax.push_back(tmp.first);
    }
    for(auto tmp : mpw) {
        if(wmaxval == tmp.second) wmax.push_back(tmp.first);
    }
    int ANS = hmaxval + wmaxval - 1;
    for(auto h : hmax) {
        for(auto w : wmax) {
            if(st.find({h, w}) == st.end()) {
                ANS++;
                cout << ANS << endl;
                return;
            }
        }
    }
    cout << ANS << endl;
}
 
int main() {
    input();
    solve();
    return 0;
}

Measured memory_bytes: 49548
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

int main() {
  int H, N;
  cin >> H >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  if (sum >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x;
	cin >> x;
	if(x == 7 || x == 5 || x == 3)puts("YES");
	else puts("NO");
	return 0;
}



Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  string s,t;
  cin >> s >> t;
  if(s==t){
    cout << "EQUAL\n";
  }else {
    if(s.size()>t.size()){
      cout <<"GREATER\n";
    }else if(s.size()<t.size()){
      cout <<"LESS\n";
    }else{
      if(s>t){
      cout <<"GREATER\n";
      }else{
      cout <<"LESS\n";
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
#define type tuple<long long, long long, long long>

using namespace std;

bool comp1 (type a, type b)
{
    return -get<0>(a)-get<1>(a)-get<2>(a)>-get<0>(b)-get<1>(b)-get<2>(b);
}

bool comp2 (type a, type b)
{
    return -get<0>(a)-get<1>(a)+get<2>(a)>-get<0>(b)-get<1>(b)+get<2>(b);
}

bool comp3 (type a, type b)
{
    return -get<0>(a)+get<1>(a)-get<2>(a)>-get<0>(b)+get<1>(b)-get<2>(b);
}

bool comp4 (type a, type b)
{
    return -get<0>(a)+get<1>(a)+get<2>(a)>-get<0>(b)+get<1>(b)+get<2>(b);
}

bool comp5 (type a, type b)
{
    return +get<0>(a)-get<1>(a)-get<2>(a)>+get<0>(b)-get<1>(b)-get<2>(b);
}

bool comp6 (type a, type b)
{
    return +get<0>(a)-get<1>(a)+get<2>(a)>+get<0>(b)-get<1>(b)+get<2>(b);
}

bool comp7 (type a, type b)
{
    return +get<0>(a)+get<1>(a)-get<2>(a)>+get<0>(b)+get<1>(b)-get<2>(b);
}

bool comp8 (type a, type b)
{
    return +get<0>(a)+get<1>(a)+get<2>(a)>+get<0>(b)+get<1>(b)+get<2>(b);
}

int main()
{
    int n, m;
    long long x, y, z, ans=-99999999999999999, a, b, c;
    vector<type> vec;
    cin>>n>>m;
    for (int i=0; i<n; i++)
    {
        cin>>x>>y>>z;
        vec.push_back(make_tuple(x, y, z));
    }
    sort(vec.begin(), vec.end(), comp1);
    a=0; b=0; c=0;
    for (int i=0; i<m; i++)
    {
        a+=get<0>(vec[i]);
        b+=get<1>(vec[i]);
        c+=get<2>(vec[i]);
    }
    ans=max(ans, abs(a)+abs(b)+abs(c));
    sort(vec.begin(), vec.end(), comp2);
    a=0; b=0; c=0;
    for (int i=0; i<m; i++)
    {
        a+=get<0>(vec[i]);
        b+=get<1>(vec[i]);
        c+=get<2>(vec[i]);
    }
    ans=max(ans, abs(a)+abs(b)+abs(c));
    sort(vec.begin(), vec.end(), comp3);
    a=0; b=0; c=0;
    for (int i=0; i<m; i++)
    {
        a+=get<0>(vec[i]);
        b+=get<1>(vec[i]);
        c+=get<2>(vec[i]);
    }
    ans=max(ans, abs(a)+abs(b)+abs(c));
    sort(vec.begin(), vec.end(), comp4);
    a=0; b=0; c=0;
    for (int i=0; i<m; i++)
    {
        a+=get<0>(vec[i]);
        b+=get<1>(vec[i]);
        c+=get<2>(vec[i]);
    }
    ans=max(ans, abs(a)+abs(b)+abs(c));
    sort(vec.begin(), vec.end(), comp5);
    a=0; b=0; c=0;
    for (int i=0; i<m; i++)
    {
        a+=get<0>(vec[i]);
        b+=get<1>(vec[i]);
        c+=get<2>(vec[i]);
    }
    ans=max(ans, abs(a)+abs(b)+abs(c));
    sort(vec.begin(), vec.end(), comp6);
    a=0; b=0; c=0;
    for (int i=0; i<m; i++)
    {
        a+=get<0>(vec[i]);
        b+=get<1>(vec[i]);
        c+=get<2>(vec[i]);
    }
    ans=max(ans, abs(a)+abs(b)+abs(c));
    sort(vec.begin(), vec.end(), comp7);
    a=0; b=0; c=0;
    for (int i=0; i<m; i++)
    {
        a+=get<0>(vec[i]);
        b+=get<1>(vec[i]);
        c+=get<2>(vec[i]);
    }
    ans=max(ans, abs(a)+abs(b)+abs(c));
    sort(vec.begin(), vec.end(), comp8);
    a=0; b=0; c=0;
    for (int i=0; i<m; i++)
    {
        a+=get<0>(vec[i]);
        b+=get<1>(vec[i]);
        c+=get<2>(vec[i]);
    }
    ans=max(ans, abs(a)+abs(b)+abs(c));
    cout<<ans<<'\n';
    return 0;
}


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

csum1 = [A[0] for _ in range(N)]
for i in range(1,N):
  csum1[i] = csum1[i-1]+A[i]
csum2 = [A[-1] for _ in range(N)]
for i in range(N-2,-1,-1):
  csum2[i] = csum2[i+1]+A[i]

ans = float('inf')
for i in range(N-1):
  ans = min(abs(csum1[i]-csum2[i+1]),ans)
print(ans)


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  REP(i, N) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int sum = 0;
  REP(i, N-1) {
    sum += L[i];
  }
  if(L[N-1] < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
char s[200111];
int n, dp[200111][3];
int main()
{
	scanf("%s", s+1);
	n = strlen(s+1);
	dp[1][1] = 1;
	dp[2][2] = 1;
	for (int i=2; i<=n; i++)
	{
		for (int j=1; j<=2; j++)
		{
			int &cur = dp[i][j];
			string a;
			if (j==2) a.PB(s[i-1]);
			a.PB(s[i]);
			for (int k=1; k<=2&&j+k<=i; k++)
			{
				string b;
				if (k==2) b.PB(s[i-j-1]);
				b.PB(s[i-j]);
				if (a!=b) cur = max(cur, dp[i-j][k]+1);
			}
//			cout<<dp[i][j]<<" ";
		}
//		cout<<endl;
	}
	cout<<max(dp[n][1], dp[n][2])<<endl;
	return 0;
}

Measured memory_bytes: 2816
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var a = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList();
        
        if (a[0] < a[1] && a[1] < a[2])
        {
            Console.WriteLine("Yes");
        }
        
        else
        {
            Console.WriteLine("No");
        }
    }
}


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

typedef struct {
	char mark;
	int num;
} TRUMP;

void bubbleSort(TRUMP a[], int n);
void selectionSort(TRUMP a[], int n);
void dispTrumpList(const TRUMP trump[], int n);
bool isStable(const TRUMP t1[], const TRUMP t2[], int n);

int main(void)
{	
	int n;
	cin >> n;
	
	TRUMP trump[36], trump1[36], trump2[36];
	for (int i = 0; i < n; i++) {
		cin >> trump[i].mark >> trump[i].num;
		trump1[i].mark = trump[i].mark;
		trump1[i].num = trump[i].num;
		trump2[i].mark = trump[i].mark;
		trump2[i].num = trump[i].num;
	}
	//memcpy(trump1, trump, sizeof(trump) * n);
	//memcpy(trump2, trump, sizeof(trump) * n);
	
	bubbleSort(trump1, n);
	dispTrumpList(trump1, n);
	if (isStable(trump, trump1, n)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	selectionSort(trump2, n);
	dispTrumpList(trump2, n);
	if (isStable(trump, trump2, n)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
}

void bubbleSort(TRUMP a[], int n)
{
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (a[j].num < a[j-1].num) {
				swap(a[j], a[j-1]);
			}
		}
	}
}

void selectionSort(TRUMP a[], int n)
{
	int i, j;
	for (i = 0; i < n; i++) {
		int minj = i;
		for (j = i; j < n; j++) {
			if (a[j].num < a[minj].num) {
				minj = j;
			}
		}
		swap(a[i], a[minj]);
	}
}

void dispTrumpList(const TRUMP trump[], int n)
{
	for (int i = 0; i < n; i++) {
		cout << trump[i].mark << trump[i].num;
		if (i < n - 1) cout << " ";
		else cout << endl;
	}
}

bool isStable(const TRUMP t1[], const TRUMP t2[], int n)
{
	char m1[9][4] = {"\0"};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			if (m1[t1[i].num-1][j] == '\0') {
				m1[t1[i].num-1][j] = t1[i].mark;
				break;
			}
		}
	}
	
	char m2[9][4] = {"\0"};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			if (m2[t2[i].num-1][j] == '\0') {
				m2[t2[i].num-1][j] = t2[i].mark;
				break;
			}
		}
	}
	
	for (int i = 0; i < 9; i++) {
		for (int j = 0; j < 4; j++) {
			if (m1[i][j] != m2[i][j]) return false;
		}
	}
	return true;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#define For(n) for(int i=0;i<n;i++)

using namespace std;
int main() {
    int n,k;
    cin >> n>>k;
    int arr[n];
    For(n){
        cin >>arr[i];
    }
    sort(arr,arr+n);
    int ans=0;
    For(k){
        ans+=arr[i];
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    for(int i=0;i<c*2;i++){
        if(b-a<2*c){
            for(int j=0;j<=b-a;j++){
                cout << a+j << endl;
                }
        break;
        }
        else if(b>c*2){
            for(int l=0;l<b;l++){
              if(l<c){
                cout << a+l << endl;
            }
            else if(l<b-c){
            continue;
            }
            else{
                cout << l+1 << endl;
            }
        }
        break;
    }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int x, y;
	scanf("%d %d", &x, &y);

	if (y > x)
		swap(x, y);

	while (y > 0) {
		int r = x % y;
		x = y;
		y = r;
	}
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;

    vector<ll> c(26);
    vector<vector<ll> > v(26);

    for(ll i = 0; i < s.length(); i++) {
        ll a = s[i] - 'a';
        c[a]++;
        v[a].push_back(i);
    }

    for(ll i = 0; i < t.length(); i++) {
        ll a = t[i] - 'a';
        if(c[a] == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<vector<ll> > n(26, vector<ll>(s.length()));

    for(ll i = 0; i < 26; i++) {
        if(c[i])
            n[i][0] = v[i][0];
    }

    vector<ll> b(26);

    ll x = s[0] - 'a';
    b[x]++;
    b[x] %= c[x];
    n[x][0] = v[x][b[x]];

    for(ll i = 1; i < s.length(); i++) {
        for(ll j = 0; j < 26; j++) {
            n[j][i] = n[j][i - 1];
        }
        ll a = s[i] - 'a';
        b[a]++;
        b[a] %= c[a];
        n[a][i] = v[a][b[a]];
    }

    ll pos = 0;
    ll ans = 0;

    x = 0;
    if(t[0] == s[0]) x++;

    for(ll i = x; i < t.length(); i++) {
        ll a = t[i] - 'a';
        ll next = n[a][pos];
        if(next <= pos) {
            ans += static_cast<ll>(s.length());
        }
        pos = next;
    }

    cout << ans + pos + 1LL << endl;
}

Measured memory_bytes: 25632
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

const int inf=1e9+10;
const int maxn=16;

int dp[1<<maxn][maxn],dp2[1<<maxn],n,m,cost[maxn][maxn]; 
vector <int> g[1<<maxn]; 

string get_s(int x){
	string s;
	for(int i=0;i<n;i++){
		s+=char(x%2+'0');
		x/=2;
	}
	reverse(s.begin(),s.end());
	return s;
}

vector <int> get_msk(int mask){
//	if(mask==32727) cout<<(1<<15)<<" "<<mask<<endl;
	vector <int> v,v2;
	for(int i=0;i<n;i++) 
		if(!(mask&(1<<i))) v.pb(i);
	for(int msk2=0;msk2<(1<<(int)v.size());msk2++){
		int msk3=0;
		for(int i=0;i<v.size();i++) if(msk2&(1<<i))
			msk3|=1<<v[i];	
		if(msk3!=0) g[mask].pb(msk3);
	}
//	if(mask==32727) cout<<mask<<endl;
//	for(int i=0;i<v2.size();i++) cout<<get_s(v2[i])<<endl;
	return v2;
}

int main(){
	for(int i=0;i<maxn;i++) for(int j=0;j<maxn;j++) 
		cost[i][j]=0;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--; v--;
		cost[u][v]=c;
		cost[v][u]=c;
	}
//	get_msk(1);
	for(int mask=0;mask<(1<<n);mask++) get_msk(mask);
//	cout<<"here"<<endl;
//	for(int i=0;i<g[1].size();i++) cout<<get_s(g[1][i])<<endl;
	for(int mask=0;mask<(1<<n);mask++) 
		for(int i=0;i<n;i++) for(int j=0;j<n;j++)
			if((mask&(1<<i))&&(mask&(1<<j)))
				dp2[mask]=dp2[mask]+cost[i][j];
	for(int mask=0;mask<(1<<n);mask++) dp2[mask]=dp2[mask]/2;
	for(int mask=0;mask<(1<<n);mask++) for(int i=0;i<n;i++) dp[mask][i]=-inf;
	dp[1<<0][0]=0;
	for(int mask=0;mask<(1<<n);mask++){
		for(int i=0;i<n;i++){
			if((dp[mask][i]==-inf)||!(mask&(1<<i))) continue;
		//	cout<<mask<<" "<<i<<" "<<dp[mask][i]<<endl;
			for(int j=0;j<n;j++){
			//	cout<<(!(mask&(1<<j)))<<" "<<cost[i][j]<<endl;
				if((!(mask&(1<<j)))&&(cost[i][j]>0)){
				//	cout<<j<<endl;
					dp[mask|(1<<j)][j]=max(dp[mask|(1<<j)][j],dp[mask][i]+cost[i][j]);
				}
			}
			
			for(int j=0;j<g[mask].size();j++){
				int mask2=g[mask][j]|(1<<i);
			//	if(mask==1) cout<<get_s(mask2)<<endl;
			//	if(mask==1&&i==0) cout<<get_s(mask)<<" "<<get_s(mask2)<<" "<<i<<endl;
				dp[mask|mask2][i]=max(dp[mask|mask2][i],dp[mask][i]+dp2[mask2]);
			}
		}
	}
//	cout<<dp[7][0]<<endl;
	printf("%d\n",dp2[(1<<n)-1]-dp[(1<<n)-1][n-1]);
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)

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

    vector<int> p(n+1);
    vector<int> a(n+1);
    rep1(i,n) cin >> p[i];
    p[0]=0;a[0]=0;


    rep1(i,n) a[i] = p[i] + a[i-1];

    int cnt=0,sum=0;
    for(int i=1;i<n-k+2;i++){
        sum = max(sum,a[i+k-1]-a[i-1]);
    }
    printf("%lf\n",(double)(sum+k)/2.0 );

}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
vi dp(1<<16,inf);
vp w;
int main(){
	int n;
	cin>>n;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	vs s(4);
	rep(i,4)cin>>s[i];
	char c[3]={'R','G','B'};
	rep(i,n)loop(j,-4,4)loop(k,-4,4)rep(l,3){
		int t=0,tt=0;
		rep(x,in[i].first)rep(y,in[i].second)if(0<=j+x&&0<=k+y&&j+x<4&&k+y<4){
			tt|=1<<((j+x)*4+k+y);
			if(s[j+x][k+y]==c[l])
				t|=1<<((j+x)*4+k+y);
		}
		w.pb({tt,t});
//		cout<<bitset<16>(t)<<" "<<bitset<16>(tt)<<endl;
	}
	dp[0]=0;
	queue<pii>que;
	que.push({0,0});
	while(que.size()){
		pii q=que.front();
		int a=q.first;
		que.pop();
		if(dp[a]<q.second)continue;
		rep(i,w.size()){
			int t=(a&(~w[i].first))|w[i].second;
			if(dp[t]>dp[a]+1){
				dp[t]=dp[a]+1;
				que.push({t,dp[t]});
			}
		}
	}
	cout<<dp[(1<<16)-1]<<endl;
}

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

using namespace std;

typedef long long ll;

ll solveBTDFS(string a,ll start,ll last,ll sum,ll n){
  cout<<"solveBTDFS("<<start<<","<<last<<","<<sum<<")"<<endl;
  if(start==n-1){
    string s=a.substr(last,n-last);
    ll val=stoll(s);
    return (val+sum);
  }
  string s=a.substr(last,start+1-last);
  ll val=stoll(s);
  ll sum1=solveBTDFS(a,start+1,start+1,sum+val,n);
  ll sum2=solveBTDFS(a,start+1,last,sum,n);
  return sum1+sum2;
}

int main(){
  string a;
  cin>>a;
  ll ans=0;
  ll n=a.length()-1;
  for(int i=0;i<1<<n;i++){
    ll lasti=0;
    ll sum=0;
    for(int j=0;j<n;j++){
      if(i&1<<j){
        string s=a.substr(lasti,j+1-lasti);
        ll val=stoll(s);
        sum+=val;
        lasti=j+1;
      }
    }
    string s=a.substr(lasti,n+1-lasti);
    ll val=stoll(s);
    sum+=val;
    ans+=sum;
  }
  cout<<ans<<endl;
  //cout<<solveBTDFS(a,0,0,0,n+1)<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, Ai, Bi;
  cin >> A >> B;
  Ai = 0; Bi = 0;
  
  
  for(int i = 0;i < A;i++){
  Bi= Bi * 10 + B;
  }

  for(int i = 0;i < B;i++){
  Ai = Ai * 10 + A;
  }  
  
  if(A < B) cout << Ai << endl;
  else cout << Bi << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int N, K;
  cin >> N >> K;
  vl num(K, 0);
  for (int i = 1; i <= N; i++) num[i % K]++;
  ll res = 0;
  for (int a = 0; a < K; a++) {
    int b = (K - a) % K;
    int c = (K - a) % K;
    if ((b + c) % K != 0) continue;
    res += num[a] * num[b] * num[c];
  }
  cout << res << endl;
  return 0;
}


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


def read():
    N = int(input().strip())
    D = []
    for i in range(N):
        a, b = map(int, input().strip().split())
        D.append((a, b))
    return N, D


def solve(N, D):
    seq = 0
    for a, b in D:
        if a == b:
            seq += 1
        else:
            seq = 0
        if seq >= 3:
            return "Yes"
    return "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9196