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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

const int mod = 1000000007;
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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(int, char**)
{
  const mint B1 = 3;
  const mint B2 = 9973;

  int h, w;
  cin >> h >> w;
  vector< vector<int> > tbl(h, vector<int>(w));
  rep(i,h) {
    string s; cin >> s;
    rep(j,w) tbl[i][j] = s[j]-'0';
  }

  int r, c;
  cin >> r >> c;
  vector< vector<int> > ptn(r, vector<int>(c));
  rep(i,r) {
    string s; cin >> s;
    rep(j,c) ptn[i][j] = s[j]-'0';
  }

  vector< vector<mint> > H(h+1, vector<mint>(w+1));
  mint e1, e2;

  e2 = 1;
  rep(i,h) {
    e1 = 1;
    rep(j,w) {
      H[i+1][j+1] = e1 * e2 * (tbl[i][j]+1) + H[i][j+1] + H[i+1][j] - H[i][j];
      e1 *= B1;
    }
    e2 *= B2;
  }

  mint hash_ptn = 0;
  e2 = 1;
  rep(i,r) {
    e1 = 1;
    rep(j,c) {
      hash_ptn += e1 * e2 * (ptn[i][j]+1);
      e1 *= B1;
    }
    e2 *= B2;
  }

  vector<P> ans;
  rep(i,h-r+1) rep(j,w-c+1) {
    mint hash_tbl = H[i+r][j+c] - H[i+r][j] - H[i][j+c] + H[i][j];
    hash_tbl /= B2.pow(i) * B1.pow(j);
    if (hash_ptn.x == hash_tbl.x) {
      ans.emplace_back(i,j);
    }
  }

  for (auto a : ans) cout << a.first << " " << a.second << endl;

  return 0;
}


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

double minkdist( vector<double> x, vector<double> y, double p, int n )
{
	double res = 0;

	if( p == 0 ) {
		vector<double>z( 0 );
		for( int i =0; i < n; i++ ) {
			z.push_back( abs( x[ i ] - y[ i ] ) );
		}
		res = *max_element( z.begin(), z.end() );
	}
	else {
		for( int i = 0; i < n; i++ ) {
			res += pow( abs( x[ i ] - y[ i ] ), p );
		}
		res = pow( res, 1 / p );
	}

	return res;
}

int main()
{

	vector<double> x( 0 ), y( 0 );

	int n;
	cin >> n;

	double tmp;
	for( int i = 0; i < n; i++ ) {
		cin >> tmp;
		x.push_back( tmp );
	}
	for( int i = 0; i < n; i++ ) {
		cin >> tmp;
		y.push_back( tmp );
	}

	cout << fixed;

	double sum = 0;
	sum = minkdist( x, y, 1, n );
	cout << sum << endl;

	sum = minkdist( x, y, 2, n );
	cout << sum << endl;

	sum = minkdist( x, y, 3, n );
	cout << sum << endl;

	sum = minkdist( x, y, 0, n );
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3404
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int a, b;
    cin >> a >> b;
    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    }   
    else {
        b = min(b, -1ll);
        int cnt = max(0ll, b - a + 1);
        if (cnt & 1)
            cout << "Negative" << endl;
        else
            cout << "Positive" << endl;                    
    }   

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1000000000;

int main()
{
	ll n,k;
	cin >> n >> k;
	vector<pair<ll,ll>> vp(n);
	rep(i,n)
	{
		ll a,b;
		cin >> a >> b;
		vp[i]=make_pair(a,b);
	}
	sort(ALL(vp));
	rep(i,n)
	{
		k-=vp[i].second;
		if(k<=0)
		{cout<<vp[i].first<<endl;
		break;}
	}
	return 0;
}

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

typedef long long int LL;

LL n, k;
LL MOD = 1000000007LL;

LL solve() {
	LL x, tmp, ans = 0;
	for (x = k; true; x++) {
		tmp = x * n - x * x + x + 1;
		if (tmp <= 0)
			return ans;
		ans = (ans + tmp) % MOD;
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); 
	cout.tie(nullptr);
	while (cin >> n >> k)
		cout << solve() << endl; 
}

Measured memory_bytes: 3668
#include<stdio.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main()
{
	int n, d, x[10][10], count = 0;
	double sum = 0;
	scanf("%d%d", &n, &d);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < d; ++j) {
			scanf("%d", &x[i][j]);
		}
	}

	for (int i = 0; i < n; ++i) {
		for (int j = i; j < n; ++j) {
			if (i == j)continue;
			for (int k = 0; k < d; ++k) {
				sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			if (ceil(sqrt(sum)) == floor(sqrt(sum)))count++;
			sum = 0;
		}
	}
	printf("%d", count);
		return 0;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

#define INF 1LL << 60

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

template <typename T> inline
void chmin(T &a, T b){
    if (a > b) {
        a = b;
    }
}

template <typename T> inline
void chmax(T &a, T b){
    if (a < b) {
        a = b;
    }
}


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

    int N, K; cin >> N >> K;
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    vector<LL> dp(N, INF);

    dp[0] = 0;

    REP(i, N) {
        FOR(j, 1, K + 1) {
            if (i + j < N){
                chmin(dp[i+j], dp[i] + abs(h[i] - h[i + j]));
            } else {
                break;
            }
        }
    }

    cout << dp.back() << endl;

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n,m,a[305][305];
int cnt[305],vis[305],ans=1e9;
int findmax(){
	memset(cnt,0,sizeof(cnt));
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (!vis[a[i][j]]){
				cnt[a[i][j]]++;
				break;
			}
	int mx=0;
	for (int i=1;i<=m;i++)
		if (cnt[i]>cnt[mx]) mx=i;
	ans=min(ans,cnt[mx]);
	return mx;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for (int i=1;i<=m;i++)
		vis[findmax()]=1;
	printf("%d\n",ans);
}

Measured memory_bytes: 640
n,c=map(int,input().split())
g=[[0]*3 for i in range(n)]
for i in range(n):
  g[i]=list(map(int,input().split()))
g.sort(key=lambda x: x[0])
g.sort(key=lambda x: x[2])
T=[0]*(10**5+3)
i=0
while i<n:
  if i!=n-1 and g[i][2]==g[i+1][2] and g[i][1]==g[i+1][0]:
    T[g[i][0]]+=1
    i=i+1
    T[g[i][1]]-=1
    i=i+1
  else:
    T[g[i][0]]+=1
    T[g[i][1]+1]-=1
    i=i+1
ans=0
a=0
for i in range(len(T)):
  a=a+T[i]
  if a>ans:
    ans=a
print(ans)

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

public class Main {

	class Node {
		int parent;
		public Node(int x) {
			this.parent = x;
		}
	}
	
	class DisjointSet {
		Node[] p;
		int[] rank;
		
		public DisjointSet(int size) {
			p = new Node[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = new Node(x);
			rank[x] = 0;
		}
		
		private int findSet(int x) {
			while (x != p[x].parent) {
				x = p[x].parent;
			}
			return x;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] > rank[y]) {
				p[y].parent = x;
			} else {
				p[x].parent = y;
				if (rank[x] == rank[y]) {
					rank[x]++;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 61540
#include <stdio.h>

#define A 100000

int main() {
	static long long kk[A + 1];
	int n, a, b;
	long long k;

	scanf("%d%lld", &n, &k);
	while (n--) {
		scanf("%d%d", &a, &b);
		kk[a] += b;
	}
	for (a = 1; a <= A && k > 0; a++)
		k -= kk[a];
	printf("%d\n", a - 1);
	return 0;
}


Measured memory_bytes: 896
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        x: i64,
    }
    puts!("{}\n", if x >= 30 { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2208
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int count = 0;
    int max_count = 0;
    for (auto ch : s)
    {
        if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T')
        {
            count++;
        }
        else
        {
            max_count = max(max_count, count);
            count = 0;
        }
    }
    max_count = max(max_count, count);

    cout << max_count << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
A = []
B = []

for i in range(n):
  A.append([int(j) for j in input().split()])
for i in range(m):
  B.append(int(input()))
  
for i in range(n):
  s = 0
  for j in range(m):
    s += A[i][j] * B[j]
  print(s)


Measured memory_bytes: 6012
#include <iostream>
#include <algorithm>
using namespace std;
int n, k, a, s, c[200005];
int main() {
	int i;
	cin>>n>>k;
	for(i=0; i<n; i++) cin>>a, c[a]++;
	int m=n-k;
	sort(c, c+n+1);
	for(i=0; i<=n-k; i++) s += c[i];
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
n, d = map(int, input().split())
points = []
for _ in range(n):
    points.append(list(map(int, input().split())))

ans = 0
for i in range(n):
    for j in range(i, n):
        if i == j:
            continue
        dif = 0
        for k in range(d):
            dif += abs(points[i][k] - points[j][k]) ** 2
        if dif ** 0.5 == int(dif ** 0.5):
            ans += 1
print(ans)


Measured memory_bytes: 3188
a,b=map(int,input().split())
k=list(map(int,input().split()))

sa=0
ans=1

n=k[a-1]

for i in range(a-2,-1,-1):
    if k[i]>n:
        n=k[i]
    tmp=n-k[i]
    if tmp>sa:
        sa=tmp
        ans=1
    elif tmp==sa:
        ans+=1

    

print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int dp[2005][2005];
int pre[2][2005][2005];
pair<int,int>p[5005];

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

    int n;
    cin>>n;
    int x;
    char ch;
    fill_n(&dp[0][0],2005*2005,1e17);
    dp[0][0]=0;
    for(int i=1;i<=2*n;i++)
    {
      cin>>ch>>x;
      if(ch=='W')
      {
        p[i]={0,x};
      }
      else  
      {
        p[i]={1,x};
      }
    }
    ordered_set<int>s[2];
    int ans=0;
    for(int i=1;i<=2*n;i++)
    {
      int num=s[p[i].first].order_of_key(p[i].second);
      int sz=s[p[i].first].size();
      ans+=sz-num;
      s[p[i].first].insert(p[i].second);
      for(int j=0;j<=n;j++)
      {
        int num=s[!p[i].first].order_of_key(j+1);
        pre[p[i].first][p[i].second][j]=j-num;
      }
    }

    for(int i=1;i<=2*n;i++)
    {
      for(int j=0;j<=n&&i>=j;j++)
      {
        int k=i-j;
        int z=pre[0][j][k];
        if(j>0)
        dp[j][k]=min(dp[j][k],dp[j-1][k]+z);
        z=pre[1][k][j];
        if(k>0)
        dp[j][k]=min(dp[j][k],dp[j][k-1]+z);        
      }
    }

  cout<<dp[n][n]+ans;

}


Measured memory_bytes: 94848
n, q = map(int, input().split())
s = input()
ac = [0] * 100010
for i in range(n):
    if s[i : i + 2] == "AC":
        ac[i + 1] = ac[i] + 1
    else:
        ac[i + 1] = ac[i]

for i in range(q):
    l, r = map(int, input().split())
    print(ac[r - 1] - ac[l - 1])

Measured memory_bytes: 6060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
 
vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
 
void dfs(int now, ll d) {
  visited[now] = true;
  dist[now] = d;
  for (auto p : to[now]) {
    if (visited[p.first]) continue;
    dfs(p.first, d + p.second);
  }
}
 
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    to[u].push_back({v, w});
    to[v].push_back({u, w});
  }
  dfs(0, 0);
  for (int i = 0; i < N; i++) cout << dist[i] % 2 << endl;
}


Measured memory_bytes: 11828
#include<iostream>

using namespace std;

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

        int count = 0;
        cin >> count;

        int i;

        int num[n];

        for(i=0;i<n;i++)
        {
                num[i] = i + 1;
                //cout << num[i] <<endl;
        }

        int a,b;
        int temp;

        for(i = 0;i < count;i++)
        {
                scanf("%d,%d",&a,&b);
                temp = num[a-1];
                num[a-1] = num[b-1];
                num[b-1] = temp;
        } 
        for(i = 0;i < n;i++)
        {
                cout << num[i] << endl;
        } 

}

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

int main()
{
  int64_t N;
  cin >> N;
  int64_t ans = 0;
  for (int64_t i = 1; i <= N; i++)
  {
    int64_t m = N / i;
    ans += m * (m + 1) / 2 * i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
import math

N=int(input())

X =round(N / 1.08)

if math.floor(X * 1.08) == N:
  print(X)
elif math.floor((X+1) * 1.08) == N:
  print(X+1)
elif math.floor((X-1) * 1.08) == N:
  print(X-1)  
else:
  print(":(")

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
L = int(input()) - 1
N = L.bit_length() + 1
res = []
for x in range(2, N):
  res.append((x, x + 1, 0))
  res.append((x, x + 1, pow(2, N - x - 1)))

b = bin(L)[2: ]
t = 0
for i in range(N - 1):
  if int(b[i]):
    res.append((1, i + 2, t))
  t += pow(2, N - i - 2) * int(b[i])
res.append((1, N, t))
res.sort()
if N > 20:
  rres = []
  for r in res:
    if r[0] == 1:
      if r[1] == 2: continue
      rres.append((r[0], r[1] - 1, r[2]))
    else: rres.append((r[0] - 1, r[1] - 1, r[2]))
  print(N - 1, len(rres))
  for r in rres: print(*r)
else:
  print(N, len(res))
  for r in res: print(*r)


Measured memory_bytes: 38384
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
  bool ans=true;
  int n;cin >> n;
  int a;
  int b=0;
  int acount=0;int bcount=0;
  cin >> a;acount++;
  int tmp;
  int i=1;
  while(b==0&&i<n){
    cin >> tmp;
    if(tmp==a){ acount++;
    }
    else{
      b=tmp;
      bcount++;
    }
    i++;
  }
  if(b!=0){  
    if(abs(a-b)>1) ans=false;
  }
  while(i<n){
    cin >> tmp;
    if(tmp==a){
      acount++;
    }
    else if(tmp==b){
      bcount++;
    }
    else{
      ans=false;
    }
  i++;
  }
  if(b>a){
    tmp=b;
    b=a;a=tmp;
    tmp=bcount;
    bcount=acount;acount=tmp;
  }
  if(ans){
    if(b==0){
      if(a!=n-1){
        if(n<2*a){
          ans=false;
        }
      }
    }
    else if(bcount>b||bcount<a*2-n){
      ans=false;
    }
  }
  if(ans) cout << "Yes";
  else cout << "No";
}

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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll a[n],b[n],c[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  sort(a,a+n);
  sort(c,c+n);
  ll ans=0;
  for(int i=0;i<n;i++){
    ll x=lower_bound(a,a+n,b[i])-a;
    ll y=n-(upper_bound(c,c+n,b[i])-c);
    ans+=x*y;
  }
  cout << ans << endl;
}

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

int main()
{
  int X, A, B;
  cin >> X >> A >> B;
  if (A-B >= 0) {
    cout << "delicious" << endl;
  } else if (B-A <= X) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int INF = 1e9;
const int MAX = 100;
int x[MAX + 1];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
    }

    int ans = INF;
    for (int p = 1; p <= 100; ++p) {
        int candidate = 0;
        for (int i = 1; i <= n; ++i) {
            candidate += ((p - x[i]) * (p - x[i]));
        }
        ans = min(ans, candidate);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z;cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
}

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

int main(){
    int N,Q;
    scanf("%d %d",&N,&Q);
    long long int A[N],X[Q];
    for(int i=0;i<N;i++){
        scanf("%lld",A+i);
    }
    for(int i=0;i<Q;i++){
        scanf("%lld",X+i);
    }
    int r=0;
    long long int s=0,cnt=0,x=0;
    for(int i=0;i<Q;i++){
        cnt=0,r=0,s=0,x=X[i];
        for(int l=0;l<N;l++){
            while(r<N && s<=x){
                s+=A[r];
                r++;
            }
            if(s>x){cnt+=(r-l-1);}
            else{cnt+=r-l;}
            if(r==l){r+=1;}
            else{s-=A[l];}
        }
        printf("%lld\n",cnt);
    }
} 



Measured memory_bytes: 3464
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007

ll dp[1005][1005] = {};



int main(){
	int h,w;
	cin >> h >> w;
	char mat[h][w];

	for(int i=0 ; i < h ; ++i){
		for(int j=0;j < w; ++j){
			cin >> mat[i][j];
		}
	}
	dp[0][0] = 1;

	for(int i=1;i<h;++i){
		if(mat[0][i]== '.' ) dp[0][i] = dp[0][i-1];
		if(mat[0][i]== '#' ) break;
	}
	for(int i=1;i<w;++i){
		if(mat[i][0]== '.' ) dp[i][0] = dp[i-1][0];
		if(mat[i][0]== '#' ) break;
	}

	for(int i=1; i< h ; ++i){
		for(int j=1;j< w ; ++j){
			if(mat[i][j]=='.'){
				dp[i][j]= ( max(dp[i-1][j],(ll)0) + max(dp[i][j-1],(ll)0) ) % mod; 
			}
			else dp[i][j] = 0;
		}
	}

	cout << dp[h-1][w-1] << endl;

}


Measured memory_bytes: 9088
def gcd(x,y)
	while y >0
		r =x%y
		x=y
		y=r
	end
	return x
end

def lcm(x,y)
	return x * y / gcd(x,y)
end

a=Array.new
n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|i| i.to_i}

a.sort!{|a, b| b <=> a }


while a.length>=2
	a[1]=lcm(a[0],a[1])
	a.shift
end
puts a[0]

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

int main() {
    string s;
    cin >> s;
    int a=0;
    for(int i=0; i<s.size(); i++){
        a+=(s.at(i)-48);
    }
    if(a%9==0) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3752
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}


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

    int N;
    cin >> N;
    FOR(i, 1, N+10) {
        if(i*i > N) {
            cout << (i-1)*(i-1) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

set<pair<pii, array<int, 4>>> S;
int n, a[370][4][4];
int dx[9] = {0, 0, 1, 0, -1, 0, 2, 0, -2};
int dy[9] = {0, 1, 0, -1, 0, 2, 0, -2, 0};

bool dfs(int cur, int pos, array<int, 4> rain){
    if(cur == n){
        //printf("%d (%d, %d)\n", cur, pos / 4, pos % 4);
        return true;
    }
    if(S.find({{cur, pos}, rain}) != S.end()) return false;

    int x = pos / 4, y = pos % 4;
    rep(i, 2)rep(j, 2){
        int nx = x + i, ny = y + j;
        if(a[cur][nx][ny]){
            S.insert({{cur, pos}, rain});
            return false;
        }
    }

    array<int, 4> nxt_rain;
    rep(i, 4) nxt_rain[i] = rain[i];
    if(pos == 0) nxt_rain[0] = -1;
    if(pos == 2) nxt_rain[1] = -1;
    if(pos == 8) nxt_rain[2] = -1;
    if(pos == 10) nxt_rain[3] = -1;
    rep(i, 4){
        ++nxt_rain[i];
        if(nxt_rain[i] == 7){
            S.insert({{cur, pos}, rain});
            return false;
        }
    }

    rep(i, 9){
        int nx = x + dx[i], ny = y + dy[i];
        if(0 <= nx && nx < 3 && 0 <= ny && ny < 3){
            if(dfs(cur + 1, nx * 4 + ny, nxt_rain)){
                //printf("%d (%d, %d)\n", cur, pos / 4, pos % 4);
                return true;
            }
        }
    }
    S.insert({{cur, pos}, rain});
    return false;
}

int main(){
    while(scanf("%d", &n) && n){
        S.clear();
        rep(i, n)rep(x, 4)rep(y, 4) scanf("%d", &a[i][x][y]);
        printf("%d\n", dfs(0, 5, {0, 0, 0, 0}));
    }
}


Measured memory_bytes: 14000
#include<iostream>

using namespace std;

int main(void)

{
    int a, b, i, counter = 0;
    string s;
    cin>>s;
    a = 0;
    b = s.size()-1;
    while(a<b){
        if(s[a] == s[b]){

        }
        else{
            counter++;
        }
        a++;
        b--;
    }
    cout<<counter<<"\n";
    return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N;
    ll X = 100;
    ll ans = 0;
    while(1) {
    	if(X >= N) {
    		break;
    	}
    	X += X / 100;
    	ans++;
    }
    
    cout << ans << "\n";

    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3612
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    H, W = map(int, input().split())
    num = 0
    for _ in range(H):
        num += input().count("#")
    print("Possible" if num == H + W - 1 else "Impossible")


if __name__ == '__main__':
    main()


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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long ans=0;
	int m=0;
	for(int i=0;i<n;i++){
		m=max(m,a[i]);
		ans+=m-a[i];
	}
	cout<<ans<<endl;
}

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

using namespace std;

char alphas[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};


int main(){
    char x;
    cin >> x;
    for(int i=0;;i++){
        if(alphas[i]==x){
            cout << alphas[i+1] << endl;
            break;
        }
    }
}

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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define in insert
#define mp(a, b) make_pair(a, b)
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define INF INT_MAX
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	ll n, k; cin>>n>>k;
	vl a(n); forn(i, n) cin>>a[i], a[i]--;
	vl loc(n, -1);
	ll curr = 0, lo = 1;
	while(loc[curr]==-1){
		loc[curr] = lo++;
		curr = a[curr];
	}
	ll cycle_size = lo - loc[curr];//size
	if(k>loc[curr])
		k = loc[curr] + (k - loc[curr])%cycle_size;
	forn(i, n)
		if(loc[i]==k){
			cout<<a[i]+1<<endl; return; 
		}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

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

int x, y, s;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> x >> y >> s;
		if(x == 0 && y == 0 && s == 0) return 0;
		int ans = 0;
		for(int i=1; i<s; ++i){
			int a = i, b = s-i;
//			cout << a << " " << b << "\n";
			int c = 0, d = 0;
			for(int j=1; j<=a; ++j){
				int t = j*(100+x)/100;
				if(a == t) c = j;
			}
			for(int j=1; j<=b; ++j){
				int t = j*(100+x)/100;
				if(b == t) d = j;
			}
			a = c;
			b = d;
//			cout << a << " " << b << "\n";
			a = a*(100+y)/100;
			b = b*(100+y)/100;
//			cout << a << " " << b << "\n\n";
			ans = max(ans, a+b);
		}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin>>n>>s;
	vector<vector<mint>> dp(n+1,vector<mint>(n+1,0));
	s='1'+s;
	FOR(j,1,n+1) dp[1][j]=1;
	FOR(i,2,n+1){
		mint sum=0;
		if(s[i-1]=='<'){
			for(int j=1;j<=n-i+1;j++){
				sum+=dp[i-1][j];
				dp[i][j]+=sum;
			}
		}else{
			for(int j=n-i+1;j>=1;j--){
				sum+=dp[i-1][j+1];
				dp[i][j]+=sum;
			}
		}
	}
	mint ans=0;
	FOR(j,1,n+1){
		ans+=dp[n][j];
	}
	cout<<ans.x<<endl;
}

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

int main() {
    int W, H, x, y, r;
    string res;
    cin >> W >> H >> x >> y >> r;
    if (x >= r && x + r <= W && y >= r && y + r <= H)res = "Yes"; else res = "No";
    cout << res << endl;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=505;
char s[5];int a[N],col[N],bs[N],cnt[2],n,las,now,ql,qr,l,r,mid,ans;
inline int ask(R int l,R int r){
	putchar('?'),putchar(' ');
	fp(i,l,r)printf("%d ",i);
	putchar('\n'),fflush(stdout);
	scanf("%s",s+1);return s[1]=='R';
}
inline int ask(R int l,R int r,R int x,R int d){
	putchar('?'),putchar(' ');
	fp(i,l,r)if(i!=x)printf("%d ",i);
	if(d)printf("%d ",x);
	putchar('\n'),fflush(stdout);
	scanf("%s",s+1);
	if(s[1]=='-')while(true);
	return s[1]=='R';
}
int main(){
	scanf("%d",&n);
	fp(i,1,n<<1)col[i]=-1;
	l=1,r=n+1,ans=0,bs[1]=ask(1,n),bs[n+1]=bs[1]^1;
	while(r-l>1){
		mid=(l+r)>>1,bs[mid]=ask(mid,mid+n-1);
		bs[mid]==bs[l]?l=mid:r=mid;
	}
	col[l]=bs[l],col[r+n-1]=bs[r];
	ql=r,qr=r+n-2;
	fp(i,ql,qr)col[i]=ask(ql-1,qr+1,i,0)^1;
	fp(i,1,ql-2)col[i]=ask(ql,qr,i,1);
	fp(i,qr+2,n<<1)col[i]=ask(ql,qr,i,1);
	putchar('!'),putchar(' ');
	fp(i,1,n<<1)putchar(col[i]?'R':'B');
	putchar('\n'),fflush(stdout);
	return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  vector<int> v = {a, b, c};
  sort(v.begin(), v.end());

  if (v[0] + v[1] == v[2]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
asum = [0]*(n+1)
for i in range(n):
    asum[i+1] = asum[i] + a[i]
for i in range(1,m):
    b[i] += b[i-1]
ans = 0
from bisect import bisect_right
for i in range(n+1):
    tim = k - asum[i]
    if tim < 0:break
    tmp = bisect_right(b,tim)
    ans = max(ans,i+tmp)
print(ans)

Measured memory_bytes: 117932
#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n==1) printf("Hello World\n");
    else if(n==2)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        printf("%d\n",a+b);
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk;

  long k,x;
  cin >> k >> x;

  for(ii=x-k+1;ii<=x+k-1;ii++){
    cout << ii << " " ;
  }
  cout << endl;
  return 0;
}


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

int L,R;

signed main() {
  cin >> L >> R;

  if(R-L > 2019) { puts("0"); return 0; } 

  L %= 2019;
  R %= 2019;

  if(L >= R) { puts("0"); return 0; }

  int ans = 2019;
  for(int i=L; i<=R; i++) for(int j=i+1; j<=R; j++) {
    ans = min(ans, (i*j)%2019);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
int main()
{
    int n, m;
    cin >> n >> m;
    string s[n + 2];
    for (int i = 0; i < n; ++i)
    {
        cin >> s[i];
    }
    ll p[n + 1][m + 1];
    if (s[0][0] == '.') p[0][0] = 1;
    else p[0][0] = 0;
    for (int i = 1; i < n; i++) {
        if (s[i][0] == '.') p[i][0] = p[i - 1][0];
        else p[i][0] = 0;
    }
    for (int i = 1; i < m; i++) {
        if (s[0][i] == '.') p[0][i] = p[0][i - 1];
        else p[0][i] = 0;
    }
    for (int i = 1; i < n; i++)
        for (int j = 1; j < m; j++)
        {
            if (s[i][j] == '.')
            {
                p[i][j] = (p[i - 1][j] % mod) + (p[i][j - 1] % mod);
                p[i][j] %= mod;
            }
            else
                p[i][j] = 0;
        }
    cout << p[n - 1][m - 1] << endl;
}

Measured memory_bytes: 9088
N, M = map(int, input().split())
C = []
for i in range(M):
    C.append(list(map(int, input().split())))
C.sort(key=lambda x:x[0])
ans = 1
l = 0
r = N-1
for c in C:
    if r<=c[0]-1 or c[1]-1<=l:
        ans += 1
        l = c[0]-1
        r = c[1]-1
        continue
    l = max(l, c[0]-1)
    r = min(r, c[1]-1)
print(ans)

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

vector<vector<int>> tree;

void dfs(int n, int p, vector<int>& d){
    for(int v : tree[n]){
        if(d[v] == -1){
            d[v] = d[n] + 1;
            dfs(v, n, d);
        }
    }
}

int main(){
    int N;  cin >> N;
    tree.resize(N);
    for(int i=0; i<N-1; i++){
        int a, b;  cin >> a >> b;
        a--;  b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<int> df(N, -1);
    df[0] = 0;  dfs(0, -1, df);
    vector<int> ds(N, -1);
    ds[N-1] = 0;  dfs(N-1, -1, ds);

    int f = 0, s = 0;
    for(int i=0; i<N; i++){
        if(df[i] <= ds[i]) f++;
        else s++;
    }
    if(f > s){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int> > A(H, vector<int>(W, 0));
    for (auto &a : A) for (auto &_a : a) cin >> _a;
    vector<pair<int, int> > C(H*W);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            C[A[i][j]-1] = make_pair(i, j);
        }
    }
    vector<int> sum(H*W, 0), dp(H*W+1, 0);
    for (int i = D; i < W*H; i++) {
        dp[i] = abs(C[i].first-C[i-D].first)+abs(C[i].second-C[i-D].second);
    }
    for (int i = D; i < W*H; i++) {
        sum[i+1] = sum[i-D+1]+dp[i];
    }
    int Q;
    cin >> Q;
    vector<pair<int, int> > LR(Q);
    for (auto &lr : LR) cin >> lr.first >> lr.second;
    for (const auto lr : LR) printf("%d\n", sum[lr.second]-sum[lr.first]);
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n; cin >> n;
    vl a(n); rep(i,n) cin >> a[i];
    vl basis;
    ll pre = 0, ans = 0;
    rep(i,n) pre ^= a[i];
    rep(i,n) a[i] &= ~pre;
    rep(i,n){
        for(ll b : basis){
            chmin(a[i],a[i]^b);
        }
        if(a[i]) basis.push_back(a[i]);
    }
    ll id = 0;
    ll bit = 60;
    while(true){
        sort(a.begin()+id, a.end(), greater<ll>());
        if(a[id] == 0) break;
        while((a[id]>>bit & 1) == 0) bit--;
        for(ll i=id+1; i<n; i++){
            if(a[i]>>bit & 1) a[i] ^= a[id];
        }
        id++;
    }
    rep(i,id){
        if((ans ^ a[i]) > ans) ans ^= a[i];
    }
    ans = (ans<<1LL) + pre;
    cout << ans << endl;
}

Measured memory_bytes: 1024
///----------------------///
///---Code Written by----///
///-----Al-Shahreyaj-----///
///----------------------///

///PRAGMA
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>

///PBDS
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

//PBDS_SET
//Index of Value - .order_of_key()
//Value at Index - .find_by_order()
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set; 
//typedef tree<int, null_type, lessorequal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset; 

#define mem(a, x) memset(a, x, sizeof(a))
#define MP make_air
#define inf 1e8
#define INF 1e18
#define CP(x) printf("Case %d: ", x);
#define unq(v) v.erase(unique(all(v)),v.end())
#define one(x) __builtin_popcount(x)
#define onel(x) __builtin_popcountll(x)
#define ll long long
#define ld long double
#define LMX LLONG_MAX
#define fixpre(x) cout << fixed << setprecision(x)
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define matrix vector<vector<ll> >
#define F first
#define S second
#define pb push_back
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define INT ini()
#define LONG inl()
#define M 1000000007
#define N 100005

int ini(){int x;scanf("%d",&x);return x;}
ll inl(){ll x;scanf("%lld",&x);return x;}


int main()
{
	ld a, b;
	cin >> a >> b;
	a = a * b;
	fixpre(0);
	cout << floor(a) << endl;
	return 0;
}





Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	long n,u,v;
	cin>>n;
	long ans=n*(n+1)*(n+2)/6;
	for(int i=0;i<n-1;i++)
	{
		cin>>u>>v;
		ans-=min(u,v)*(n-max(u,v)+1);
	}
	cout<<ans;
}

Measured memory_bytes: 3532
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int n = 0;
  if (b == 100) {
    n = a * 1000 + b;
  } else if (b >= 10) {
    n = a * 100 + b;
  } else {
    n = a * 10 + b;
  }
  int s = sqrt(n);
  if (s * s == n) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3016
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	ll a;
	cin>>a;
	ll ans= a+ a*a+a*a*a;
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3648