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

int main(void){
	int i, n, x[200000], y[200000];
	int count;
	int d;
	double dist;
	
	count=0;
	scanf("%d %d", &n, &d);
	for(i=0; i<n; i++){
		scanf("%d %d", &x[i], &y[i]);
    }
	for(i=0; i<n; i++){
		dist=sqrt((double)x[i]*x[i]+(double)y[i]*y[i]);
		if(dist <= d) count++;
	}
	printf("%d", count);
	return 0;
}

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

using namespace std;

int main()
{
    int n,i;
    cin>>n;
    vector<int> A(n);
    for(i=0 ; i<n ; i++)
    {
        cin>>A[i];
    }
    for(i=n-2; i>=0 ; i--)
    {
        if(A[i]>A[i+1])
        {
            A[i]--;
        }
    }
    int flag=0;
    for(i=0 ; i<n-1 ; i++)
    {
        if(A[i]>A[i+1])
        {
            flag=1;
        }
    }
    if(flag==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> ans(N, 10);
	vector<int> A;
	for(int i = 0; i < N; i++){
		int t;
		cin >> t;
		A.push_back(t);
	}
	for(int i = 0; i < N; i++){
		ans[A[i] - 1] = i + 1;
	}
	for(int i = 0; i < N - 1; i++){
		cout << ans[i] << " ";
	}
	cout << ans[N - 1] << endl;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ta = max(0ll, a - c);
    b = max(0ll, b - c + (a - ta));
    a = ta;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	String[][] w = {
		{"a", "f", "k", "p", "u", "z"},
		{"b", "g", "l", "q", "v", "."},
		{"c", "h", "m", "r", "w", "?"},
		{"d", "i", "n", "s", "x", "!"},
		{"e", "j", "o", "t", "y", " "}
	};
	
	public Main(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String str = sc.next();
			int n = str.length();
			if(n%2 == 1){
				n = 0;
			}
			String st = "";
			for(int i = 0; i < n; i+=2){
				int s = Integer.parseInt(str.substring(i, i+1))-1;
				int t = Integer.parseInt(str.substring(i+1, i+2))-1;
				if(s < 0 || s > 5 || t < 0 || t > 4){
					n = 0;
					break;
				} else {
					st += w[t][s];
				}
			}
			
			if(n == 0){
				System.out.println("NA");
			} else {
				System.out.println(st);
			}
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
#define maxx 100004
//树的左子右兄弟表示法 
struct node{
	int p;   //父结点 
	int l;   //最左边的子结点 
	int r;   //紧邻的兄弟结点 
};
struct node tree[maxx]; 
int depth[maxx];
int n;
/*
void Depth()
{
	for(int i=0;i<n;i++)
	{
		int cnt=0;
		int k=i;
		while(tree[k].p!=-1)
		{
			cnt++;
			k=tree[k].p;
		}
		depth[i]=cnt;
	}
}*/
void Depth(int u,int p)
{
	depth[u]=p;
	if(tree[u].r!=-1)
		Depth(tree[u].r,p);
	if(tree[u].l!=-1)
		Depth(tree[u].l,p+1);
}
//NULL和0在计算机中的存储是一致的 
void printTree()
{
	for(int i=0;i<n;i++)
	{
		cout<<"node "<<i<<": parent = ";
		if(tree[i].p==-1)
			cout<<"-1";
		else cout<<tree[i].p;
		cout<<", depth = "<<depth[i]<<", ";
		if(depth[i]==0)
			cout<<"root, [";
		else if(tree[i].l==-1)
			cout<<"leaf, [";
		else cout<<"internal node, [";
		int kk=tree[i].l;
		if(kk!=-1)
		{
				
			cout<<tree[i].l;
			while(tree[kk].r!=-1)
			{
			
				cout<<", ";
				cout<<tree[kk].r;
				kk=tree[kk].r;
			}
		}
		cout<<"]"<<endl;
		
	}
}
int main()
{
	cin>>n;
	//结点信息初始化 
	for(int i=0;i<n;i++)
	{
		tree[i].l=tree[i].p=tree[i].r=-1;
	}
	// 
	for(int i=0;i<n;i++)
	{
		int id;
		cin>>id;
		int nn;
		cin>>nn;
		//degree[i]=nn;
		for(int j=0;j<nn;j++)
		{
			int tt,pnn;
			cin>>tt;
			tree[tt].p=id;
			if(j==0)
				tree[id].l=tt;
			if(j!=0)
				tree[pnn].r=tt;
			pnn=tt;
		}
	}
	//cout<<"1111"<<endl;
	int r;
	for(int i=0;i<n;i++)
	{
		if(tree[i].p==-1)
		{
			r=i;
			break;
		}
	}
	Depth(r,0);
	//cout<<"1111"<<endl;
	printTree();
	return 0;
} 


Measured memory_bytes: 7744
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    int no_of_players, no_of_points, no_of_answers;
    cin >> no_of_players >> no_of_points >> no_of_answers;

    vector <int> points(no_of_players + 1, no_of_points - no_of_answers);
    for(int i = 1; i <= no_of_answers; i++)
    {
        int player;
        cin >> player;

        points[player]++;
    }

    for(int i = 1; i <= no_of_players; i++)
    {
        cout << (points[i] > 0 ? "Yes\n" : "No\n");
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s<d) cout<<"No";
	else cout<<"Yes";
	re 0;
}

Measured memory_bytes: 3648
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    N = int(input())
    X = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        X[a-1].append(b-1)
        X[b-1].append(a-1)

    Q = [0]
    P = [-1] * N
    R = []
    while Q:
        i = Q.pop()
        R.append(i)
        for j in X[i]:
            P[j] = i
            X[j].remove(i)
            Q.append(j)
    
    node_type = [0] * N # 1: Leaf etc. 2: Node with a leaf child
    for i in R[::-1]:
        t = sum([1 if node_type[j] == 1 else 0 for j in X[i]])
        if t > 1:
            return 1
        if t:
            node_type[i] = 2
        
        t = sum([1 if node_type[j] <= 1 else 0 for j in X[i]])
        if t == 0:
            node_type[i] = 1
    
    return 1 if node_type[0] == 1 else 0

print("First" if main() else "Second")

Measured memory_bytes: 66224
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,k,a[200010],nxt[100][200010];
	cin >> n >> k;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++) nxt[0][i] = a[i] - 1;
	for(int i = 1;i < 100;i++){
		for(int j = 0;j < n;j++) nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
	}
	int pos = 0;
	for(int i = 0;i < 62;i++){
		if(k >> i & 1) pos = nxt[i][pos];
	}
	cout << pos + 1 << endl;
}

Measured memory_bytes: 161456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 1

int main()
{	
	ios_base::sync_with_stdio(0);
	ll l,r,mod = 2019;
	while(cin>>l>>r){
		ll ans = mod;
		if(l>=r || (r-l+1)>=2019) ans = 0;
		l%=mod;r%=mod;
		for(ll i=l; i<=r; i++){
			for(ll j=i+1; j<=r; j++){
				ans = min(ans,(i*j)%mod);
			}
		}
		if(l>=r) ans = 0;
		cout<<ans%mod<<endl;
	}
	
}


Measured memory_bytes: 256
from collections import Counter
def solve():
    if N % 2 == 1:
        if counter[0] != 1:
            return 0
        else:
            for i in range(2, N, 2):
                if counter[i] != 2:
                    return 0
            return (2 ** (N // 2)) % mod
    else:
        for i in range(1, N, 2):
            if counter[i] != 2:
                return 0
        return (2 ** (N // 2)) % mod

mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
print(solve())

Measured memory_bytes: 14820
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[101];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    for (int i = 0; i < m; ++i)
    {
        int y;
        cin >> y;
        a[y] = 1;
    }
    int p = 0, q = 0;
    for (int i = 0; i < x; ++i)
        p += a[i];
    for (int i = x + 1; i <= n; ++i)
        q += a[i];
    cout << min(p, q);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAX 100007
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>

//const ll modd = 998244353;
const ll inf = 1e18;

ll d;
vector<int> num;
ll dp[10005][102][2];

ll solve(int pos, ll sm, int tight){
    if(pos==num.size()){
        if(sm==0){
            return 1;
        }
        return 0;
    }

    ll &ret = dp[pos][sm][tight];
    if(ret!=-1) return ret;
    ret = 0;
    int lim = (tight?num[pos]:9);

    for(int i=0;i<=lim;i++){
        int ctit = 0;
        if(tight && i==lim) ctit = 1;

        ret = (ret+solve(pos+1, (sm+i)%d, ctit))%MOD;
    }

    return ret;
}


int main(){
	/*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    fast;
    string s;
    cin>>s;
    cin>>d;

    for(auto c:s){
        num.pb(c-'0');
    }

    memset(dp, -1, sizeof(dp));
    ll ans = solve(0,0,1)-1;
    if(ans<0) ans+=MOD;
    cout<<ans<<'\n';
	return 0;
}



Measured memory_bytes: 17152
s = input()
a = s[0:2]
b = s[2:]
if a[0] == 0:
    a = a[1]
if b[0] == 0:
    b = b[1]
a = int(a)
b = int(b)

if (a >= 13 or a == 0) and 1 <= b and b <= 12:
    print('YYMM')
elif 1 <= a and a <= 12 and (b >= 13 or b == 0):
    print('MMYY')
elif ((a >= 13 or a == 0) and (b == 0 or b >= 13)):
    print('NA')
else:
    print('AMBIGUOUS')

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

#define ll long long

using namespace std;

//memset(dp, 0, sizeof(dp));

void work(int T) {
	
	int n;
	cin >> n;
	
	cout << (1000 - n % 1000) % 1000 << endl;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
	// int t;
	// for(cin >> t; t > 0; t--) {
		// work(t);
	// }
	work(0);
	return 0;
};

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int n, m, h[100001], c[100001];

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        if (h[a] < h[b])
            c[a] = 1;
        if (h[a] > h[b])
            c[b] = 1;
        if (h[a] == h[b]) {
            c[a] = 1;
            c[b] = 1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (c[i] == 0)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

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

class C
{
    static void Main()
    {
        Console.ReadLine();
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        for (var i = a.Length - 2; i >= 0; i--)
        {
            var d = a[i] - a[i + 1];
            if (d > 1)
            {
                Console.WriteLine("No");
                return;
            }
            if (d == 1) a[i]--;
        }
        Console.WriteLine("Yes");
    }
}


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

int main(){
    string o,e;
    cin>>o>>e;
    int a=0;
    if(o.size()==e.size()){
        for(int i=0;i<o.size();i++){
            cout<<o[i];
            cout<<e[i];
        }
    }
    if(o.size()>e.size()){
        for(int i=0;i<o.size();i++){
            cout<<o[i];
            if(i<e.size())
            cout<<e[i];
        }
    }
    cout<<endl;
    return 0;
}

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

bool judge(int x)
{
    int result = 1;
    int k = sqrt(x);
    for(int i = 2; i <= k; i++)
    {
        int tmp = 1;
        while(x % i == 0)
        {
            tmp++;
            x = x / i;
        }
        result *= tmp;
    }
    if(result == 8)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    int n;
    cin >> n;
    int count = 0;
    for(int i = 0; 2*i + 1 <= n; i++)
    {
        if(judge(2*i+1))
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int n;
	cin >> n;
	cout << n*(n+1)/2 << endl;
	//printf((a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]) ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
string s; int a[4];
int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N') a[0]++;
		if (s[i] == 'E') a[1]++;
		if (s[i] == 'S') a[2]++;
		if (s[i] == 'W') a[3]++;
	}
	bool x0 = a[0], x1 = a[1], x2 = a[2], x3 = a[3];
	if (x0 != x2 || x1 != x3) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 160: C (2020/03/28)
K, N = map(int, input().split())
S = input().split()
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(S[i])
max = 0
for i in range(N):
    if i != N-1:
        D = A[i+1]-A[i]
    else:
        D = K-A[i]+A[0]
    if max < D:
        max = D
print(K-max)

Measured memory_bytes: 26444
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
using namespace std;
int main() {
	int N; cin >> N;
	cout << N + N * N + N * N * N << endl;
	return 0;
}

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

#define PI 3.14159265359

long long A, B, H, M;

int main(){
	cin >> A >> B >> H >> M;
	double x1,x2,y1,y2;
	x1 = A* cos(2.0 * PI * H/12.0 + 2.0 * PI/12 * M/60.0);
	y1 = A* sin(2.0 * PI * H/12.0 + 2.0 * PI/12 * M/60.0);
	x2 = B* cos(2.0 * PI * M/60.0);
	y2 = B* sin(2.0 * PI * M/60.0);
	printf("%.20f\n", sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)));
}

Measured memory_bytes: 3940
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])

const ans = () => {
  let count = 0

  for (let i = 1; i <= n; i++) {
    const len = String(i).length

    if (len % 2 !== 0) count++
  }

  console.log(count)
}

ans()


Measured memory_bytes: 10956
/* ~created by Roh@n M@he$hwari~ */

#include<bits/stdc++.h>
using namespace std;
int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,x,i,j;
	cin>>n>>x;
	long long dp[n+1][x+1];
	int v[n],w[n];
	for(i=0;i<n;i++) cin>>w[i]>>v[i];
	for(i=0;i<=n;i++)
		for(j=0;j<=x;j++)
		{
			//cout<<w[i-1]<<" "<<j<<endl;
			if(i==0||j==0)
				dp[i][j]=0;
			else  if(w[i-1]<=j)
			{
				//cout<<"&&&"<<endl;
				dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
			}
			else
				dp[i][j]=dp[i-1][j];
			//cout<<dp[i][j]<<endl;
		}
	cout<<dp[n][x]<<endl;
	return 0;
}


Measured memory_bytes: 79104
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: u64,
        ab: [(u64,u64);n]
    }
    let mut m = m;
    let mut ab = ab;
    ab.sort_by_key(|x| x.0);
    let mut sum = 0;
    for (a,b) in ab {
        if m == 0 {
            break;
        }
        let x = std::cmp::min(m,b);
        m -= x;
        sum += a * x;
    }
    println!("{}", sum);
}


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

using namespace std;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
ll sum(ll n){

return ((n*(n+1))/2);

}
int main(){

fast();

vector<int>is;

for(int i = 0;i<3;i++){
     int x;
     cin>>x;

    is.push_back(x);
}
sort(is.begin(),is.end());

for(int i = 0;i<3;i++){
      if(i==0||i==1)
     cout<<is[i]<<" ";
     else cout<<is[i];
}cout<<endl;


return 0;
}


Measured memory_bytes: 3160
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        char S=scanner.next().charAt(0);
        if(Character.isUpperCase(S)){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 35176
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int const N = 3;
int const none = -1;

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

    vector<int> number[N];
    for( int i=0; i<n; ++i ) {
        for( int j=0; j<N; ++j ) {
            int s;
            cin >> s;
            number[j].push_back( s );
        }
    }

    vector<int> score( n, 0 );
    for( int i=0; i<N; ++i ) {
        for( int j=0; j<n; ++j ) {
            int const p = number[i].at( j );
            number[i].at( j ) = none;

            if ( find( number[i].begin(), number[i].end(), p ) == number[i].end() ) {
                score.at( j ) += p;
            }

            number[i].at( j ) = p;
        }
    }

    for( int i=0; i<n; ++i ) {
        cout << score.at( i ) << endl;
    }
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	string s;
	cin>>a;
	cin>>s;
	for(int i=0;i<=s.size();i++)
	{
		s[i]=s[i]+a;
		if(s[i]>'Z')
		{
			s[i]-=26; 
		}
	}
	cout<<s<<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = []
for _ in range(m):
    p, x = map(int, input().split())
    px.append([p-1, x])

for i in px:
    ind = i[0]
    print(sum(t[:ind] + [i[1]] + t[ind+1:]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main()
{
    ll n;
    cin >> n;
    if (n == 1) {
        Yes;
        return 0;
    }
    vector<ll> a(n);
    rep0(i, n)cin >> a[i];
    rrep0(i, n - 1){
        if (a[i] - a[i + 1] >= 2) {
            No;
            return 0;
        }else if(a[i] - a[i + 1] == 1){
            --a[i];
        }
    }
    Yes;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

int main()
{
    int n, k, q; cin >> n >> k >> q;
    vector <ll> A(q);
    for (int i = 0; i < q; i ++){
        cin >> A.at(i);
    }
    vector <ll> ans(n, k);
    
    for (auto a: A){
        ans.at(a - 1) += 1;
    }

    for (auto p: ans){
        p -= q;
        if (p < 1) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    string s; cin >> s;

    ll m = 0;
    map<char, ll> c;
    rep(i, n){
        c[s[i]]++;
        for(ll j=i+1, k=i+2;k<n;j++, k+=2){
            if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) m++;
        }
    }

    cout << c['R']*c['G']*c['B']-m << endl;

    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>

#define true 1
#define false 0

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)


int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  double sum=0;
  double jpy_btc;
  rep(i,N){
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf, "%lf %s", &jpy_btc, buf);
    if(buf[0]=='J'){
      sum=sum+jpy_btc;
    }
    else{
      sum=sum+jpy_btc*380000;
    }
  }

  printf("%lf\n",sum);

  return 0;

}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for(int i=(int)(a);(i)<(int)(b);i++)

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    int temp = x;
    x = y;
    y = temp;

    temp = x;
    x = z;
    z = temp;
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
using ll = long long;

long long find_min(function<bool(long long)> solve, long long low, long long high) {
	long long ng = low, ok = high;
	while (ok - ng > 1) {
		long long mid = (ok + ng) / 2;
		if (solve(mid)) {
			ok = mid;
		} else {
			ng = mid;
		}
	}
	return ok;
}

int main() {
	ll n, k, zero = 0;
	cin >> n >> k;
	vector<ll> A_plus, A_minus;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		if (a > 0) A_plus.push_back(a);
		else if (a < 0) A_minus.push_back(-a);
		else zero++;
	}
	sort(A_plus.begin(), A_plus.end());
	sort(A_minus.begin(), A_minus.end());
	ll num_minus = A_minus.size() * A_plus.size();
	ll num_zero = zero * (n - zero) + zero * (zero-1) / 2;
	ll ans;
	if (k <= num_minus) {
		function<ll(ll)> g = [&](ll x) {
			ll res = 0, j = A_minus.size();
			for (ll i : A_plus) {
				while (j > 0 && i*A_minus[j-1] >= -x) j--;
				res += A_minus.size() - j;
			}
			return res;
		};
		function<bool(ll)> f = [&](ll x) {
			return g(x) >= k;
		};
		ans = find_min(f, -(*A_minus.rbegin())*(*A_plus.rbegin())-1, -1);
	} else if (k <= num_minus + num_zero) {
		ans = 0;
	} else {
		k -= num_minus + num_zero;
		function<ll(ll)> g = [&](ll x) {
			ll res = 0, j = A_minus.size()-1;
			for (ll i = 0; i < A_minus.size() && i < j; i++) {
				ll z = x / A_minus[i];
				while (j > i && A_minus[j] > z) j--;
				res += j - i;
			}
			j = A_plus.size()-1;
			for (ll i = 0; i < A_plus.size() && i < j; i++) {
				ll z = x / A_plus[i];
				while (j > i && A_plus[j] > z) j--;
				res += j - i;
			}
			return res;
		};
		function<bool(ll)> f = [&](ll x) {
			return g(x) >= k;
		};
		ll high = 1;
		if (!A_plus.empty()) high = max(high, *A_plus.rbegin());
		if (!A_minus.empty()) high = max(high, *A_minus.rbegin());
		high = high*high + 1;
		ans = find_min(f, 0, high);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5284
#include<stdio.h>

int main(void)
{
  int n,m;
  char a[100][100];
  char b[100][100];
  int i,j,k,l,s=0,q=0;

  scanf("%d %d",&n,&m);

  for(i=0;i<n;i++)
    scanf("%s",a[i]);

  for(i=0;i<m;i++)
    scanf("%s",b[i]);

  for(i=0;i<=n-m;i++){
    for(l=0;l<=n-m;l++){
    s=0;
    for(j=0;j<m;j++){
      for(k=0;k<m;k++){
      if(a[k+i][j+l]==b[k][j])
        s++;
      }
    }
    if(s==m*m){
      q=1; break;
    }
  }
}
  if(q==1)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <utility>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
int main() {
	int n, m;
	pair<int, int> x[50];
	pair<int, int> y[50];
	pair<int, int> mini[50] = {};
	cin >> n >> m;
	FOR(i, 0, n) {
		cin >> x[i].first >> x[i].second;
		mini[i].first = 1000000000;
	}
	FOR(i, 0, m) {
		cin >> y[i].first >> y[i].second;
	}
	FOR(i, 0, n) {
		FOR(j, 0, m) {
			if (mini[i].first != min(mini[i].first, abs(x[i].first - y[j].first) + abs(x[i].second - y[j].second))) {
				mini[i].first=abs(x[i].first - y[j].first) + abs(x[i].second - y[j].second);
				mini[i].second = j + 1;
			};
			if (j >= m - 1) {
				cout << mini[i].second << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int n,m;
int dl[200][200], ds[200][200],dp[1001][200];
const int inf = 500000000;

int main() {
 while(cin >> n >> m, n) {
  for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)dl[i][j] = ds[i][j] = inf;
  for (int i = 0; i < n; i++)dl[i][i] = ds[i][i] = 0;
  for (int i = 0; i < m; i++) {
   int x,y,t;
   char c;
   cin >> x >> y >> t >> c;
   x--, y--;
   if (c == 'L') {
    dl[x][y] = min(dl[x][y],t);
    dl[y][x] = min(dl[y][x], t);
   } else {
    ds[x][y] = min(ds[x][y],t);
    ds[y][x] = min(ds[y][x], t);
   }
  }
  for (int k = 0; k < n; k++) {
   for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
     dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
     ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
    }
   }
  }
  int r, initz, pos;
  cin >> r >> initz;
  initz--;
  for (int i = 0; i < r; i++)for (int j = 0; j < n; j++)dp[i][j] = inf;
  dp[0][initz] = 0;
  pos = initz;
  for (int i = 1; i < r; i++) {
   int z;
   cin >> z;
   z--;
   for (int j = 0; j < n; j++) {
    dp[i][j] = min(dp[i][j], dp[i-1][j] + dl[pos][z]);
    for (int k = 0; k < n; k++) {
     dp[i][j] = min(dp[i][j], dp[i-1][k] + dl[pos][k] + ds[k][j] + dl[j][z]);
    }
   }
   pos = z;
  }
  int ans = inf;
  for (int i = 0; i < n; i++) {
   ans = min(ans, dp[r-1][i]);
  }
  cout << ans << endl;
 }
 return 0;
}

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

int main() {
    vector<ll> abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];
    int K;
    cin >> K;

    sort(abc.begin(), abc.end());
    abc[2] = abc[2] * pow(2, K);

    int res = abc[0] + abc[1] + abc[2];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if (a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if (a < b) a = b;}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 10050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;


void solve() {
	int a; cin >> a;
	print(a + a * a + a * a*a);
}

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

	 //int q;
	 //cin >> q;
	 //while (q--)
	solve();
}


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

typedef struct pdata {
    int t;
    int x;
    int y;
}pdata;

int main (void){
    pdata d1,d2;
    int n;
    int t,x,y;
    int dt,dm;
    bool res = true;
    cin >> n;
    d1.t = 0;
    d1.x = 0;
    d1.y = 0;
    for(int i = 0;i < n;i++){
        cin >> t >> x >> y;
        d2.t = t;
        d2.x = x;
        d2.y = y;
        dt = d2.t - d1.t;
        dm = abs(d2.x - d1.x) + abs(d2.y - d1.y);
        // cout << "dt:" << dt << " dm:" << dm << endl;
        if(dm <= dt && (dm == dt || (dt - dm) % 2 == 0)){
            d1 = d2;
            continue;
        }else{
            res = false;
            break;
        }

    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<pair<ll,ll>> primeFactors(ll n)  {
    vector<pair<ll,ll>> v;
    int cnt=0;

    while (n % 2 == 0)  {
        n = n/2;
        cnt++;
    }
    if(cnt>0){
      v.pb({2,cnt});
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2) {
      cnt=0;
        while (n % i == 0) {
            n = n/i;
            cnt++;
        }
        if(cnt>0) v.pb({i,cnt});
    }
    if (n > 2)  v.pb({n,1});
    return v;
}
void solve(){
  ll n;
  cin>>n;
  vector<pair<ll,ll>> x=primeFactors(n);
  ll ans=0;
  rep(i,0,x.size()){
    // cout<<x[i].f<<" "<<x[i].s<<endl;
    int last=0;
    for(ll j=1;j<=10;j++){
      // cout<<(j*(j+1))/2<<endl;
      if((j*(j+1))/2 > x[i].s){
        break;
      }
      else last=j;
    }
    // cout<<last<<endl;
    ans+=last;
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    {
      solve();
    }
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
const int mod = 1e9+7;

void solve()
{
	int n;
	cin >> n;
	ll sum = 0;
	ll tot = 0;
	for(int i = 0; i<n; i++)
	{
		int t;
		cin >> t;
		(tot += t * sum) %= mod;
		(sum += t) %= mod;
	}
	cout << tot << "\n";
	
}

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


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> ans;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, k;
	cin >> n >> k;
	int mx = (n-1)*(n-2)/2;
	if(k > mx)
		return !(cout << -1);
	for(int i=1; i<n; i++)
		ans.push_back({i, n});
	int d = mx - k, i = 1, j = 2;
	while(d--) {
		ans.push_back({i, j++});
		if(j == n) {
			i++;
			j = i+1;
		}
	}
	cout << ans.size() << '\n';
	for(auto pr: ans)
		cout << pr.first << ' ' << pr.second << '\n';
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=5e3+5,mod=1e9+7;
char s[N][N];
int n,m;
ll dp[N][N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    dp[1][1]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        if(i==1&&j==1) continue;
        if(s[i][j]=='.')
        {
            if(s[i-1][j]=='.') dp[i][j]+=dp[i-1][j];
            if(s[i][j-1]=='.') dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    printf("%lld\n",dp[n][m]);
}


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

const int Maxl = 26;
const int Inf = 1000000000;

string s;
map <int, int> M;

void insertMap(int mask, int val)
{
	map <int, int>::iterator it = M.find(mask);
	if (it != M.end()) it->second = min(it->second, val);
	else M[mask] = val;
}

int getMap(int mask)
{
	map <int, int>::iterator it = M.find(mask);
	return it != M.end()? it->second: Inf;
}

int Get(int mask)
{
	int res = getMap(mask);
	for (int i = 0; i < Maxl; i++)
		res = min(res, getMap(mask ^ 1 << i));
	return res;
}

int main()
{
	cin >> s;
	insertMap(0, 0);
	int mask = 0, val = Inf;
	for (int i = 0; i < s.length(); i++) {
		mask ^= 1 << int(s[i] - 'a');
		val = Get(mask) + 1;
		insertMap(mask, val);
	}
	printf("%d\n", val);
	return 0;
}

Measured memory_bytes: 9860
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

use std::cmp::{max, min};

fn main() {

  let n: i64 = read();
  let mut ans = 0;

  for i in 1..n {
      ans += i;
  }

  println!("{}", ans);
  
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
  int n,m,i,j,r,a,c,max;
  while(scanf("%d %d",&n,&m),n||m){
    int b[100002]={0};
    int d[100000]={0};
    int e[100000]={0};
    while(m--){
      scanf("%d",&a);
      b[a]++;
    }
    c=r=0;
    for(i=1;i<100001;i++){
      if(b[i])c++;
      else{
	if(b[i-1]&&b[i+1])e[r]=1;
	if(c){
	  d[r++]=c;
	  c=0;
	}
      }
    }
    for(i=max=0;i<r;i++){//printf("%d %d\n",d[i],e[i]);
      if(max<d[i]+b[0])max=d[i]+b[0];
      if(b[0]&&e[i]){
	if(max<d[i]+d[i+1]+1)max=d[i]+d[i+1]+1;
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 1780
L, R = map(int, input().split())
mod = 2019
s = 2018
for i in range(L,R):
    for j in range(i+1, R+1):
        t = (i%mod)*(j%mod)%mod
        if s > t:
            s = t
        if t == 0:
            break
    else:
        continue
    break
print (s)

Measured memory_bytes: 3060
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_C
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int dp[100][16384];

int main(int argc, char **argv)
{
        int N, W;
        cin >> N >> W;
        vector<int> v(N), w(N);
        for (int i = 0; i < N; i++)
                cin >> v[i] >> w[i];
        for (int i = 0; i < N; i++) {
                for (int j = 0; j <= W; j++) {
                        if (j < w[i]) {
                                dp[i][j] = !i ? 0 : dp[i-1][j];
                        }
                        else {
                                dp[i][j] = max(!i ? 0 : dp[i-1][j], dp[i][j-w[i]] + v[i]);
                        }
                }
        }
        cout << dp[N-1][W] << endl;
        return 0;
}

Measured memory_bytes: 7044
#include<bits/stdc++.h>
using namespace std;
int n;
int a[10009];
int main() {
    cin>>n;
    int sum=0;
    int m=1234;
    for(int i=1;i<=n;i++){
        cin>>a[i-1];
        sum+=a[i-1];
        m=min(m,sum/i);
    }
    cout<<m<<endl;
}



Measured memory_bytes: 3080
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}


int dp[100001][101];
int cum[100001][101];
int32_t main()
{
    IOS
    
    
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;++i)
        cin>>a[i];
    
    
    memset(dp,0,sizeof(dp));
    memset(cum,0,sizeof(cum));
    for(int i=0 ;i<=n;++i)
        dp[0][i]=1,cum[0][i]=1;
    
    
   // for(int i=1;i<=n;++i)
   // {
   //      dp[1][i]=dp[1][i-1]%mod;
   //      if(a[i-1]>0)
   //          dp[1][i]++;
   //      dp[1][i]%=mod;
   //      cum[1][i]=(cum[0][i]+dp[1][i])%mod;
   // }
   for(int i=1;i<=k;++i)
   {
        cum[i][1]=cum[i-1][1];
        if(i<=a[0])
        {
            dp[i][1]=1;
            cum[i][1]++;
        }
        cum[i][1]%=mod;
   }
    for(int i=1;i<=k;++i)
    {
        for(int j=2;j<=n;++j)
        {   
            dp[i][j]=cum[i][j-1]%mod;
            if(i-min(i,a[j-1])!=0)
            {
               // cout<<i<<" "<<j<<" "<<min(i,a[j-1])<<endl;
                dp[i][j]=(dp[i][j]-cum[i-min(i,a[j-1])-1][j-1]+mod)%mod;
               
            }
            dp[i][j]%=mod;
            cum[i][j]=(cum[i-1][j]+dp[i][j]+mod)%mod;
 
        }

    }
    cout<<dp[k][n]%mod;
}



Measured memory_bytes: 158080
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int find(int x,vector<int>&v)
{
	while(x!=v[x])
	{
		v[x]=v[v[x]];
		x=v[x];
	}
	return x;
}
 void uni(int a,int b,vector<int>&v)
 {
 	int x=find(a,v);
 	int y=find(b,v);
 	if(x!=y)
 	v[x]=y;
 }
int main() 
{
	ll n,m;
	cin>>n>>m;
	vector<int> v(n+1);
	for(int i=1;i<=n;i++)v[i]=i;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		uni(a,b,v);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(v[i]==i)ans++;
	}
	cout<<ans-1;
	return 0;
} 

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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
// clang-format on

using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

template <typename T>
class RMQ
{
  const T INF = numeric_limits<T>::min();
  int n = 1;
  vector<T> data;

public:
  RMQ(int s)
  {
    while (n < s)
      n *= 2;
    data.resize(2 * n - 1);
  }

  void update(int i, T x)
  {
    i += n - 1;
    data[i] = x;
    while (i > 0)
    {
      i = (i - 1) / 2;
      data[i] = max(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  T query(int a, int b) { return query1(a, b, 0, 0, n); }
  T query1(int a, int b, int i, int l, int r)
  {
    if (b <= l || r <= a)
      return INF;
    if (a <= l && r <= b)
      return data[i];
    int m = (l + r) / 2;
    T x = query1(a, b, i * 2 + 1, l, m);
    T y = query1(a, b, i * 2 + 2, m, r);
    return max(x, y);
  }
};

int main()
{
  IOS;
  int N;
  cin >> N;
  VLL H(N), A(N);
  LL MAX_H = 0;
  forn(i, 0, N)
  {
    cin >> H[i];
    MAX_H = max(MAX_H, H[i]);
  }
  forn(i, 0, N) cin >> A[i];

  RMQ<LL> rmq(MAX_H + 1);
  VLL dp(MAX_H + 1);
  LL res = 0;
  for (int i = 0; i < N; i++)
  {
    LL a = rmq.query(0, H[i] + 1);
    chmax(dp[H[i]], A[i] + a);
    rmq.update(H[i], dp[H[i]]);
    res = max(res, dp[H[i]]);
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 11856
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    i = 0
    for b in sorted(bb, reverse=True):
        if b <= max_a:
            break
        i += 1
        h -= b
        if h <= 0:
            return i
    return i + ceil(h / max_a)


n, h = map(int, input().split())
aa, bb = [], []
for _ in range(n):
    a, b = map(int, input().split())
    aa.append(a)
    bb.append(b)

print(solve(h, aa, bb))


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

    lint n, k;
    cin >> n >> k;

    lint ans=0;
    lint MOD = 1e9 + 7;
    vector<lint> p(n);
    lint tmp = 0;
    FOR(i,1,n+2) {
        tmp += n+1 - i;
        tmp -= i-1;

        //cout << tmp << "\n";
        if(i>=k){
            ans += tmp+1;
            ans %= MOD;
        }
    }

    cout << ans <<"\n";

    return 0;
}

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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int& i: v) cin >> i;
    int res = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(i + j > k || i + j > n) continue;
            vector<int> inHand;
            for(int x = 0; x < i; x++) inHand.push_back(v[x]);
            for(int x = 0; x < j; x++) inHand.push_back(v[n - x - 1]);
            sort(inHand.begin(), inHand.end());
            int rem = k - i - j;
            int val = 0;
            for(int i = 0; i < inHand.size(); i++){
                if(inHand[i] < 0 && rem > 0){
                    rem--;
                    continue;
                }
                val += inHand[i];
            }
            res = max(res, val);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
	int n; cin >> n ;
	int a[n];
	for(int i=0 ; i < n ; i++){
		cin >> a[i];
	}
	ll sum =0;
	for(int i=0 ; i < n ; i++){
		for(int j=i+1 ; j < n ; j++){
			sum+=(a[i]*a[j]);
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M;
    vi h(N);
    cin >> h;
    vi a(M), b(M);
    vvi c(N);
    REP(i, M) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        c[a[i]].push_back(b[i]);
        c[b[i]].push_back(a[i]);
    }
    REP(i, N) {
        bool flag = true;
        REP(j, c[i].size()) {
            if (h[i] <= h[c[i][j]]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9544