akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#define maxn 400005
using namespace std;
typedef long long ll;
typedef set<int>:: iterator Ite;
const int DOWN = 0;
const int LEFT = 1;
const int UP = 2;
int n,m,rig[100005];
struct Point{
	int type,x,y,seg;
	Point(int a = 0,int b = 0,int c = 0,int d = 0): type(a),x(b),y(c),seg(d) {}
}ps[maxn];
bool cmp(const Point &a,const Point &b){
	if(a.y == b.y){
		if(a.type == b.type) return a.x < b.x;
		return a.type < b.type;
	}
	return a.y < b.y;
}
int work(){
	sort(ps+1,ps+m+1,cmp);
	int ans = 0;
	set <int> st;
	st.clear();
	for(int i=1;i<=m;i++){
		if(ps[i].type == 0) st.insert(ps[i].x);
		else if(ps[i].type == 2) st.erase(ps[i].x);
		else{
			int l = ps[i].x,r = rig[ps[i].seg];
			Ite itl = st.lower_bound(l),itr = st.upper_bound(r);
			ans += distance(itl,itr);
		}
	}
	return ans;
}
int main(){
	scanf("%d",&n);
	m = 0;
	for(int i=1;i<=n;i++){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(x1 == x2){
			if(y1 > y2) swap(y1,y2);
			ps[++m] = Point(0,x1,y1,0);
			ps[++m] = Point(2,x1,y2,0);
		}else{
			if(x1 > x2) swap(x1,x2);
			ps[++m] = Point(1,x1,y1,i);
			rig[i] = x2;
		}
	}
	printf("%d\n",work());
	return 0;
}



Measured memory_bytes: 12500
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int D = Integer.parseInt(sc.next());
    int N = Integer.parseInt(sc.next());

    int ans = (int) Math.pow(100, D);

    if (N == 100) {
      N++;
    }
    ans *= N;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include<cstdio>
#include<iostream>
#include<string>

#define R 1
#define D 2
#define L 3
#define U 4

using namespace std;

int main(void){

	int tate[6][7]={0};
	char inp;
	int yoko[7][6]={0};
	int x,y;
	int now;

	for(int i=1;i<6;i++){
		for(int j=1;j<5;j++){
			inp=getchar();
			yoko[i][j]=(int)(inp-'0');
		}
		getchar();
		if(i!=5){
			for(int j=1;j<6;j++){
				inp=getchar();
				tate[i][j]=(int)(inp-'0');
			}
			getchar();
		}
	}
	now=R;
	bool f=false;
	x=1,y=1;
	while(1){
		if(now==R){
			now=D;
			if(tate[y-1][x]==1&&f==false) now=U,f=true;
			else if(yoko[y][x]==1){
				x++;
				cout<<"R";
				now=R;
				f=false;
			}
		}
		if(now==D){
			now=L;
			if(yoko[y][x]==1&&f==false) now=R,f=true;
			else if(tate[y][x]==1){
				y++;
				cout<<"D";
				now=D;
				f=false;
			}
		}
		if(now==L){
			now=U;
			if(tate[y][x]==1&&f==false) now=D,f=true;
			else if(yoko[y][x-1]==1){
				x--;
				cout<<"L";
				now=L;
				f=false;
			}
		}
		if(now==U){
			now=R;
			if(yoko[y][x-1]==1&&f==false) now=L,f=true;
			else if(tate[y-1][x]==1){
				y--;
				cout<<"U";
				now=U;
				f=false;
			}
		}
		if(x==1&&y==1) break;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = ll(1e9+7);
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    ll n, dp[26]{};
    string s, t;
    cin >> n >> s >> t;
    dp[s[0]-'a'] = 1;
    for(int i=1;i<n-1;i++){
        dp[s[i]-'a'] += dp[t[i]-'a'];
        dp[s[i]-'a'] %= MOD;
    }
    cout << dp[t.back()-'a'] << endl;
    return 0;
}



Measured memory_bytes: 3364
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  string s;
  int k;
  cin >> k >> s;

  if(s.length() <= k){
    cout << s << endl;
  }else{
    LOOP(i,k){
      cout << s[i];
    }
    cout << "..." << endl;
  }

}


Measured memory_bytes: 3628
from collections import Counter

N = int(input())
A = Counter(list(map(int, input().split())))

P = sorted([i for i in A.items() if i[1] >= 2])

if len(P) < 2:
  print(0)
elif P[-1][1] >= 4:
  print(P[-1][0] ** 2)
else:
  print(P[-1][0] * P[-2][0])

Measured memory_bytes: 22024
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int gcd(int a,int b){

   if(a%b == 0)
    return b;
   else
    return gcd(b,a%b);

 }

 long long numbers[500005];

 long long dt,dx,dy,oldx=0,oldy=0,oldt=0;

 int main(){

 long long n,flag=0;
 cin>>n;

  for(int i=0;i<n;i++)
 {
    long long t,x,y;
    cin>>t>>x>>y;

     dt = t-oldt;
     dx = abs(x-oldx);
     dy = abs(y-oldy);

    if(dt >= dx+dy && (dt-dx-dy)%2 == 0){
        oldt = t;
        oldx = x;
        oldy = y;

    }
    else
    {
        flag = 1;
         break;
    }

  }

  if(flag == 1)
  cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;

 return 0;
 }


Measured memory_bytes: 3620
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()
    val func = if (n <= k) x * n else x * k + y * (n - k)
    println(func)
}


Measured memory_bytes: 29472
//
//  main.c
//  A
//
//  Created by s1262004 on 2019/07/12.
//  Copyright © 2019 s1262004. All rights reserved.
//

#include <stdio.h>

#define H 255
#define parent(x) x >> 1
#define left(x) x << 1
#define right(x) (x << 1) + 1

int n; //A.length
int node[H];
int heapSize;

void buildMaxHeap();
void maxHeapify(int);
void swap(int, int);
void printNode(int);

int main(int argc, const char * argv[]) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &node[i]);
    for (int i = 1; i <= n; i++) printNode(i);
    return 0;
}

void printNode(int i){
    printf("node %d: ", i);
    printf("key = %d, ", node[i]);
    if (i != 1) printf("parent key = %d, ", node[parent(i)]);
    if (left(i) <= n) printf("left key = %d, ", node[left(i)]);
    if (right(i) <= n) printf("right key = %d, ", node[right(i)]);
    printf("\n");
}




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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  cout << (in() + in()) % 24 << endl;
}


Measured memory_bytes: 256
"""abc157_b"""

A = [list(map(int, input().split())) for i in range(3)]

N = int(input())

B = [int(input()) for i in range(N)]

for a in A:
    for i in range(3):
        if a[i] in B:
            a[i] = 0

ANS = "No"

for a in A:
    if sum(a) == 0:
        ANS = "Yes"
        break

verti = 0
for i in range(3):
    for j in range(3):
        verti += A[j][i]
    if verti == 0:
        ANS = "Yes"
        break
    verti = 0

if (A[0][0] + A[1][1] + A[2][2]) == 0:
    ANS = "Yes"

if (A[0][2] + A[1][1] + A[2][0]) == 0:
    ANS = "Yes"

print(ANS)


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

int main(){
  int b,r,g,c,s,t;
  while(cin >> b >> r >> g >> c >> s >> t){
    if(t==0)break;

    int bonus = 5*b + 3*r;
    int res = 100;
    res += bonus * 15 + g*7 + 2*c + b*15 + r*15;
    res -= 2*bonus + 3*(t-s-bonus);
    cout << res << endl;
  }
}

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

int main(){
    string S, S2, T;
    cin >> S2;
    cin >> T;
    int n = S2.size();
    int m = T.size();
    if (n < m) {
        cout << "UNRESTORABLE\n";
        return 0;
    }
    vector<string> cand;
    for (int i = n-m; i >= 0; i--) {
        bool check = true;
        S = S2;
        for (int j = 0; j < m; j++) {
            if (S2[i+j] != T[j] && S2[i+j] != '?') {
                check = false;
            } else {
                S[i+j] = T[j];
            }
        }
        if (!check) continue;
        for (int j = 0; j < n; j++) {
            if (S[j] == '?') S[j] = 'a';
        }
        cand.push_back(S);
    }
    if (cand.empty()) {
        cout << "UNRESTORABLE\n";
        return 0;
    }
    sort(cand.begin(), cand.end());
    cout << cand[0] << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    char A[N][N],B[M][M];
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        strcpy(A[i], s.c_str());
    }
    for(int i=0;i<M;i++){
        string s;
        cin >> s;
        strcpy(B[i], s.c_str());
    }
    //int a = N%M==0 ? N/M : N/M+1;
    bool b = true;
    for(int i=0;i<N-M+1;i++){
        for(int j=0;j<N-M+1;j++){
            b=true;
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(A[i+k][j+l]!=B[k][l]){
                        b=false;
                        goto OUT;
                    }
                }
            }
            OUT:
            if(b) {
                cout << "Yes" << endl;
                goto END;
            }
        }
    }
    END:
    if(!b) cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
N_odds=[]
for i in range(105,N+1):
    if i%2==1 :
        N_odds.append(i)
    else:
        continue
eights=[105,135,165,189,195]
answers=[]
for i in N_odds:
    if i in eights:
        answers.append(i)
    else:
        continue
print(len(answers))


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
int sum[40005],n,m,S[20],st[40005];
ll f[40005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=40000;i++) sum[i]=sum[i-(i&-i)]+1;
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		S[x]|=(1<<y-1);
	}
	for(int i=0;i<(1<<n);i++){
		st[i]=(1<<n)-1;
		for(int p=1;p<=n;p++) if(i&(1<<p-1)) st[i]&=S[p];
	}
	f[0]=1;
	ll ans=1;
	for(int i=1;i<=m;i++) ans=ans*2%mod;
	for(int i=1;i<(1<<n);i++){
		if((i&1)!=((i>>1)&1)) continue;
		for(int p=i;p;p=(p-1)&i){
			if((p&1)!=((p>>1)&1)) continue;
			int k=i^p;
			ll w=f[k];
			for(int j=1;j<=n;j++)
				if(k&(1<<j-1)) w=w*((1<<sum[S[j]&p])-1)%mod;
				else if(p&(1<<j-1)) w=(w<<sum[S[j]&k])%mod;
			f[i]=(f[i]+w)%mod;
		}
	}
	ans=(ans-f[(1<<n)-1])%mod;
	ans=(ans+mod)%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 896
a, b, x = map(int, input().split())
import math

if x > a*a*b/2:
  c = (a*a*b - x)*2/(a*a)
  theta = math.atan(c/a)
else:
  c = (x*2)/(a*b)
  theta = math.atan(b/c)

ans = math.degrees(theta)
print(ans)

Measured memory_bytes: 3060
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

int a[100], b[100], l[100], r[100];
int search(int v) {
	int wl = 1, wr = 1;
	if(l[v] >= 0) wl = search(l[v]);
	if(r[v] >= 0) wr = search(r[v]);

	int p = 1, q = 1;

	while(wl * a[v] * p != wr * b[v] * q) {
		if(wl * a[v] * p > wr * b[v] * q)
			++q;
		else
			++p;
	}

	return wl * p + wr * q;
}

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

	for(int n; cin >> n, n;) {
		vector<int> in(n, 0);
		for(int i = 0; i < n; ++i) {
			cin >> a[i] >> b[i] >> l[i] >> r[i];
			--l[i];
			--r[i];
			if(l[i] >= 0) ++in[l[i]];
			if(r[i] >= 0) ++in[r[i]];
		}
		
		int ans;
		for(int i = 0; i < n; ++i)
			if(!in[i])
				ans = search(i);
		
		cout << ans << endl;	
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
def summ(M):
    S = 0
    for i in range(4):
        for j in range(4):
            S += M[i][j]
            S %= MOD
    return S

N = int(input())
MOD = 10**9 + 7
D = [[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(N+3)]
for i in range(4):
    for j in range(4):
        D[1][i][j][3] = 1
for n in range(2,N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                D[n][i][j][k] = sum(D[n-1][j][k])%MOD
    for l in range(4):
        D[n][2][1][l] -= D[n-1][1][l][0]
        D[n][2][l][1] -= D[n-1][l][1][0]
    D[n][2][1][1] += D[n-1][1][1][0]
    D[n][1][2][0] = 0
    D[n][2][0][1] = 0
    D[n][2][1][0] = 0
print(sum(summ(D[N-1][i]) for i in range(4))%MOD)

Measured memory_bytes: 73676
#include<iostream>
using namespace std;
struct Card{char suit, value;};

void Bubble(struct Card A[],int N){
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i+1;j--){
            if(A[j].value<A[j-1].value){
                Card t=A[j];
                A[j]=A[j-1];
                A[j-1]=t;
                
            }
        }
    }
}

void Selection(struct Card A[],int N){
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j].value<A[minj].value)minj=j;
            
        }
Card t=A[i];
A[i]=A[minj];
        A[minj]=t;
        
    }
}

void Print(struct Card A[],int N){
    for(int i=0;i<N;i++){
        if(i>0)cout<<" ";
        cout<<A[i].suit<<A[i].value;
        
    }
    cout<<endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i=0;i<N;i++){
        if(C1[i].suit != C2[i].suit)return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int N;
    char ch;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>C1[i].suit>>C1[i].value;
        
    }
    for(int i=0;i<N;i++)C2[i]=C1[i];
    Bubble(C1,N);
Selection(C2,N);

    Print(C1,N);
cout<<"Stable"<<endl;
Print(C2,N);
    if(isStable(C1,C2,N)){
        cout<<"Stable"<<endl;
        }
        else{
            cout<<"Not stable"<<endl;
        }

    return 0;
}



Measured memory_bytes: 3108
n = int(input())
A = list(map(int,input().split()))
A.insert(0,-1)

for i in range(1,n+1):
    print("node {}: ".format(i),end = "")

    print("key = {}, ".format(A[i]),end = "")

    if (i // 2) > 0:
        print("parent key = {}, ".format(A[i // 2]),end = "")
    
    if 2*i <= n:
        print("left key = {}, ".format(A[2*i]),end = "")
    
    if 2*i + 1 <= n:
        print("right key = {}, ".format(A[2*i + 1]),end = "")
    
    print("")



    
        




Measured memory_bytes: 5720
#include<iostream>

using namespace std;

int main(){

    int N, A, B;
    int sum;
    int a, b, c, d, e;

    cin >> N >> A >> B;

    for(int n=1;n<=N;++n){
        a = n/10000;
        b = (n%10000)/1000;
        c = (n%1000)/100;
        d = (n%100)/10;
        e = n%10;
        if(A<=a+b+c+d+e && a+b+c+d+e<=B){
            sum += n;
        }
    }

    cout << sum;

}


Measured memory_bytes: 256
//kalyanchirla
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
#define int long long
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define csl ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
int32_t main()
{ 
    csl;

    int a,b,c;
    cin >> a >> b >> c;

    for(int i=1;i<=10000;i++)
    {
        if((i*a)%b==c)
        {
            cout << "YES" << "\n";
            return 0;
        }
    }
    cout << "NO" << "\n";
}

Measured memory_bytes: 3548
n = int(input())
x = range(n)
P =[]
s = 0
for _ in x:P.append([int(i) for i in input().split()])
P.append(P[0])
for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Measured memory_bytes: 7728
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        String ans = "";
        String s = "zabcdefghijklmnopqrstuvwxy";
        char[] c = s.toCharArray();


        while(true){
            long mod = N % s.length();
            ans =  c[(int)mod] + ans;

            if( ( (N -1) / s.length()) < 1){
                break;
            } else{
                N = ((N-1) / s.length());
            }

        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 39204
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N,A,B;
	cin>>N>>A>>B;
	
	cout<<min(A,B)<<" ";
	if(A+B<=N)
	cout<<0<<endl;
	else
	cout<<A+B-N<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
#ifdef _WIN32
    #define gx getchar
    #define px putchar
    #define ps putchar(' ')
    #define pn putchar('\n')
    #define DEBUG 1
#else
    #define gx getchar_unlocked
    #define px putchar_unlocked
    #define ps putchar_unlocked(' ')
    #define pn putchar_unlocked('\n')
    #define DEBUG 0
#endif
 
#define rep(i,j,k) for(ll i=0;i<j;i+=k)
//input
void scan(int &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' ) sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * sign;
}
void lscan(ll &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' )
        sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * (ll)(sign);
}
int sscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
int wscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n' && c!=' ')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
 
//output
void print(int n)
{
    if(n<0)
    {
        n=-n;
        px('-');
    }
    int i=10;
    char o[10];
    do{o[--i] = (n%10) + '0'; n/=10;}while(n);
    do{px(o[i]);}while(++i<10);
}
void lprint(ll n)
{
    if(n<0LL)
    {
        n=-n;
        px('-');
    }
    int i=21;
    char o[21];
    do{o[--i] = (n%10LL) + '0'; n/=10LL;}while(n);
    do{px(o[i]);}while(++i<21);
}
void sprint(const char a[])
{
    const char *p=a;
    while(*p)px(*p++);
}
 
 
ll po(ll a, ll b, ll m)
{
	ll x=1,y=a;
	while(b > 0)
	{
		if(b%2 == 1)
		{
			x=(x*y);
			if(x>m) x%=m;
		}
		y = (y*y);
		if(y>m) y%=m;
		b /= 2;
	}
	return x;
}
unordered_map<int,int> m;

bool divisors(int n) 
{ 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i==0) 
        { 
            if(i!=n&&m[i])
            	return false;
            if(n/i!=n&&m[n/i])
            	return false;
            if(i==n&&m[i]>1)
            	return false;
            if(n==n/i&&m[n/i]>1)
            	return false;
        } 
    } 
	return true;
}  
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
	ll n,x;
	cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++) {
		cin>>a[i];
		m[a[i]]++;
	}
	ll ans = 0;
	for(ll i=0;i<n;i++) {
		if(divisors(a[i]))
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 33160
import bisect
N, M = map(int, input().split())


ab = [tuple(map(int, input().split())) for i in range(M)]
ab = [tuple([ab[i][0], ab[i][1], i]) for i in range(M)]

ans = 1
tmp = 0

a = sorted(ab, key=lambda x: x[0])
b = sorted(ab, key=lambda x: x[1])

checked = set()

for i in range(M):
    if b[tmp][1] <= a[i][0]:
        ans += 1
        while(b[tmp][1] <= a[i][0] or b[tmp][2] in checked):
            tmp += 1
    checked.add(a[i][2])


print(ans)



Measured memory_bytes: 35832
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, x, a[30]; bool dp[1000001], prime[1000001];
int main() {
	prime[0] = true, prime[2] = true;
	for(int i = 3; i <= 1000000; i += 2) prime[i] = true;
	for(int i = 3; i <= 1000; i++) {
		if(!prime[i]) continue;
		for(int j = i; i * j <= 1000000; j++) prime[i * j] = false;
	}
	while(scanf("%d%d", &n, &x), n) {
		for(int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n);
		for(int i = 0; i < x; i++) dp[i + 1] = false; dp[0] = true;
		for(int i = 1; i <= x; i++) {
			for(int j = 0; j < n && i >= a[j]; j++) {
				if(dp[i - a[j]]) {
					dp[i] = true; break;
				}
			}
		}
		for(int i = x; i >= 0; i--) {
			if(dp[i] && prime[i]) {
				printf(i ? "%d\n" : "NA\n", i); break;
			}
		}
	}
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> v;
  for (int i=0; i < N; i++) {
    int d; cin >> d;
    v.push_back(d);
  }

  
  sort(v.begin(), v.end());
  int middle = N/2;
  int ans = v.at(middle) - v.at(middle-1);

  cout << ans << endl;
  
}

Measured memory_bytes: 892
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;


int main() {
	int N, M; cin >> N >> M;
	vector<int> a(M+1,1e6),ans(N+1);
	vector<bool> z(N,1);
	for (int i = 1; i <= M; i++) {
		cin >> a[i];
		z[a[i]] = 0;
		ans[a[i]] = 0;
		if (a[i] == a[i - 1] + 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	ans[0] = 1;
	ans[1] = 1;
	for (int i = 2; i <= N; i++) {
		ans[i] = z[i-1]*ans[i - 1] + z[i-2]*ans[i - 2];
		ans[i] %= (int)(1e9) + 7;
	}
	cout << ans[N];
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int a[2001];
int N;

int maxen(int x,int k);
map<pii,int> dpX;
map<pii,int> dpY;

int minen(int x,int k){
    //if(k==N-1)return abs(x-a[N-1]);
    if(dpY.find({x,k})!=dpY.end())return dpY[{x,k}];
    int ret=abs(x-a[N-1]);
    for(int i=k;i<N-1;++i){
        ret = min(ret,maxen(a[i],i+1));
    }
    return dpY[{x,k}]=ret;
}

int maxen(int x,int k){
    //相手がxの時のk以降から引く
    if(dpX.find({x,k})!=dpX.end())return dpX[{x,k}];
    int ret =abs(x-a[N-1]);
    for(int i=k;i<N-1;++i){
        ret=max(ret,minen(a[i],i+1));
    }
    return dpX[{x,k}]=ret;


}

int main() {

    int Z,W;cin>>N>>Z>>W;
    REP(i,N)cin>>a[i];
    cout<<maxen(W,0)<<endl;


    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <cstring>

using namespace std;

typedef pair<int, int> pii;

int wall[100];
map<int, pii> cats;

int main(){
	while(true){
		int w, q;
		cin >> w >> q;
		if(w == 0 && q == 0){ break; }
		memset(wall, 0, sizeof(int) * 100);
		cats.clear();
		while(q--){
			string cmd;
			cin >> cmd;
			if(cmd[0] == 's'){
				int id, len, i, l;
				cin >> id >> len;
				pii info;
				for(i = l = 0; i < w && l < len; ++i){
					if(wall[i]){
						l = 0;
					}else{
						++l;
					}
				}
				if(l < len){
					cout << "impossible" << endl;
				}else{
					info.first = i - len;
					info.second = len;
					for(--i; i >= info.first; --i){ wall[i] = 1; }
					cout << info.first << endl;
					cats.insert(make_pair(id, info));
				}
			}else{
				int id;
				cin >> id;
				pii info = cats[id];
				for(int i = info.second - 1; i >= 0; --i){
					wall[i + info.first] = 0;
				}
				cats.erase(cats.find(id));
			}
		}
		cout << "END" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * (a + b);
        System.out.println(area + " " + length);
    }
}


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

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpii;

const int MAXN=1e5+10;
const ll MOD=1e9+7;

int N;
vpii A;
int D, idx1, idx2;
ll fact[MAXN], ifact[MAXN], ans[MAXN];

ll comb(int n, int m) {
	if(n < m) return 0;
	return (fact[n] * ifact[m] % MOD) * ifact[n-m] % MOD;
}

ll sq(ll n) {return n * n % MOD;}
ll pot(ll b, ll e)  {return e? sq(pot(b,e>>1)) * (e&1?b:1) % MOD : 1;}

int main() {
	ri(N),N++;
	FOR(i,0,N) {
		int x;ri(x);
		A.pb({x,i});
	}
	sort(A.begin(), A.end());
	FOR(i,0,A.size()-1) if(A[i].first == A[i+1].first) {
		idx1 = A[i].second;
		idx2 = A[i+1].second;
	}
	D = N - idx2 + idx1 - 1;
	fact[0] = ifact[0] = 1;
	FOR(i,1,N+1) fact[i]  = fact[i-1] * i % MOD;
	FOR(i,1,N+1) ifact[i] = pot(fact[i], MOD-2);
	FOR(k,1,N+1) ans[k] = (comb(N,k) - comb(D,k-1) + MOD) % MOD;
	FOR(k,1,N+1) printf("%lld\n",ans[k]);
}


Measured memory_bytes: 4468
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char c;
	cin >> a ;
	for(;;){
		cin >> c ;
		if(c=='=')break;
		cin >> b ;
		if(c=='+')a=a+b;
		else if(c=='-')a=a-b;
		else if(c=='/')a=a/b;
		else if(c=='*')a=a*b;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 1160
use std::cmp::min;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let s: String = read();

    let mut es = s.chars().filter(|&c| c == 'E').count();
    let mut ws = 0;
    let mut ans = es;

    for c in s.chars() {
        if c == 'E' {
            es -= 1;
        }
        ans = min(ans, ws + es);
        if c == 'W' {
            ws += 1;
        }
    }

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int main() {
    int N, K; cin >> N >> K;
    int a[N]; rep(i, N) cin >> a[i];
    vector<bool>dp(K + 1, false); //dp[i] : 残り石がiのとき，負けるか？
    dp[0] = true;
    for(int i = 1; i <= K; ++i) {
        bool flg = true;
        rep(j, N) {
            if(i - a[j] >= 0)
                if(dp[i - a[j]]) {
                    flg = false;
                }
        }
        dp[i] = flg;
    }
    cout << ((!dp[K]) ? "First" : "Second") << endl;
}


Measured memory_bytes: 384
N = int(input())
num_list = [int(input()) for _ in range(N)]
import math

def prime_chk(n):
    if 0 < n <= 3:
        return True
    else:
        for i in range(2, int(math.sqrt(n)+1)):
            if n % i == 0:
                return False
        return True

res_list = [i for i in num_list if prime_chk(i)]
print(len(res_list))


Measured memory_bytes: 6072
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

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

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }
#include <vector>
using i64 = long long;

#include <vector>
#include <tuple>

struct union_find {
  std::vector<int> par;
  union_find(int N): par(N, -1) {}
  int root(int x) {
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }
  std::tuple<int, int> unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return { -1, -1 };
    if(par[x] > par[y]) std::swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return { x, y };
  }
  int size(int x) {
    return -par[root(x)];
  }
};

int main() {
  i64 N;
  cin >> N;
  vector<tuple<i64, i64, i64>> vec;
  rep(i,0,N) {
    i64 x, y;
    cin >> x >> y;
    x--;
    y--;
    vec.emplace_back(x, y, i);
  }
  sort(all(vec));
  reverse(all(vec));

  union_find uf(N);
  vector<pair<i64, i64>> st;
  for(auto [x, y, i]: vec) {
    i64 MAX = y;
    while(!st.empty() && st.back().first > y) {
      MAX = std::max(MAX, st.back().first);
      uf.unite(i, st.back().second);
      st.pop_back();
    }
    st.push_back({ MAX, i });
  }
  st.clear();
  reverse(all(vec));
  for(auto [x, y, i]: vec) {
    i64 MIN = y;
    while(!st.empty() && st.back().first < y) {
      MIN = std::min(MIN, st.back().first);
      uf.unite(i, st.back().second);
      st.pop_back();
    }
    st.push_back({ MIN, i });
  }
  rep(i,0,N) {
    cout << uf.size(i) << '\n';
  }
}



Measured memory_bytes: 10692
H, W = map(int, input().split())
a = [input() for _ in range(H)]

row = []
for i in a:
    if i == '.' * W:
        continue
    row.append(i)

column = []
for i in range(W):
    for j in range(len(row)):
        if row[j][i] == '#':
            column.append(i)
            break

for i in range(len(row)):
    for j in column:
        print(row[i][j], end="")
    print('\n')

Measured memory_bytes: 4340
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M;
	int L, R;
	int l = -INF, r = INF;
	
	cin>>N>>M;
	
	for(int i = 0; i < M; i++){
		cin>>L>>R;
		l = max(l, L);
		r = min(r, R);
	}
	
	cout<<max(0ll, r-l+1);
	
	
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };

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

macro_rules! read_value {
    ($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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize
    }
    if a == b && b == c && a % 2 == 0 {
        println!("-1");
        return;
    }
    let mut m = 2;
    for i in 0..30 {
        let ra = a % m;
        let rb = b % m;
        let rc = c % m;
        if !(ra % 2 == 0 && ra == rb && rb == rc) {
            println!("{}", i);
            return;
        }
        m <<= 1;
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main()
{
	long long a,b;
	int k;
	cin>>a>>b>>k;
	if(b-a<2*k) for(int i=a;i<=b;i++)
				{
					cout<<i<<endl;
				}
	else 
	{
		for(int i=a;i<a+k;i++)
		{
			cout<<i<<endl;
		}
		for(int i=b-k+1;i<=b;i++)
		{
			cout<<i<<endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int main()
{
  int n,k,min;
  int h[100005];
  cin>>n>>k;
  for(int i=0; i<n; i++){
    cin>>h[i];
  }
  dp[1]=abs(h[1]-h[0]);
  for(int i=2; i<n; i++){
    min=1000000000;
    for(int j=1; j<=k; j++){
      if(i>=j){
	if(min>abs(h[i]-h[i-j])+dp[i-j]){
	  min=abs(h[i]-h[i-j])+dp[i-j];
	}
      }
    }
    dp[i]+=min;
  }
  cout<<dp[n-1]<<'\n';
  return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
vector<ll> daikus(vector<vector<mp> > &g,ll s){
	int n = g.size();
	vector<ll> c(n,inf);
	vector<ll> used(n,true);
	priority_queue<mp,vector<mp> , greater<mp> > q;
	q.push( mp(0,s) );
	while(!q.empty() ){
		mp now = q.top();
		q.pop();
		ll nc = now.first;
		ll nn = now.second;
		if(used[nn] && c[nn] > nc){
			used[nn] = false;
			c[nn] = min(c[nn],nc);
			for(ll i=0;i<g[nn].size();i++){
				ll next = g[nn][i].second;
				ll nec = nc + g[nn][i].first;
				if(used[next]){
					q.push( mp(nec,next) );
				}
			}
		}
	}

	return c;
}


int main(){
	while(1){
		ll n,m,s,g1,g2;
		cin>>n>>m>>s>>g1>>g2;
		s--;
		g1--;
		g2--;
		if(n==0)break;
		vector<vector<mp> > g(n),rg(n);
		for(ll i=0;i<m;i++){
			ll ss,t,c;
			cin>>ss>>t>>c;
			ss--;
			t--;
			g[ss].push_back( mp(c,t) );
			rg[t].push_back( mp(c,ss) );
		}
		vector<ll> sm = daikus(g,s),g1m = daikus(rg,g1),g2m = daikus(rg,g2);
		ll res = inf;
		for(ll i= 0;i<n;i++){
			res = min(res, sm[i]+g1m[i]+g2m[i]);
		}
		cout<<res<<endl;
	}

	return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s; cin >> s;
    int ans = 0;
    if (s == "RRR") ans = 3;
    else if (s == "SSS") ans = 0;
    else if (s == "RRS" || s == "SRR") ans = 2;
    else ans = 1;
    cout << ans << endl;
}


Measured memory_bytes: 3644
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=II()
	A=LI()

	m=10**9+7

	S=sum(A)
	S%=m
	ans=0


	for i in A:
		S-=i
		S%=m
		ans+=i*S
		ans%=m
	print(ans)









if __name__ == "__main__":
	main()


Measured memory_bytes: 29148
// УЛЬЯНА НОВОЯТЛОВА САМАЯ ЛУЧШАЯ В МИРЕ!!!

#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <stack>
#include <algorithm>
#include <random>

using namespace std;

typedef long long ll;

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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    
    cin >> n;
    
    vector<int> v23, v21, v22, v3;
    
    for (int i = 30000; i >= 1; i--) {
        if (i % 2 == 0) {
            if (i % 3 == 0) {
                v23.push_back(i);
            }
            
            if (i % 3 == 1) {
                v21.push_back(i);
            }
            
            if (i % 3 == 2) {
                v22.push_back(i);
            }
        } else {
            if (i % 3 == 0) {
                v3.push_back(i);
            }
        }
    }
    
    
    if (n <= 4) {
        if (n == 3) {
            cout << "2 5 63" << endl;
        } else if (n == 4) {
            cout << "2 5 20 63" << endl;
        }
    } else {
        n -= 4;
        cout << v3.back() << " ";
        v3.pop_back();
        cout << v3.back() << " ";
        v3.pop_back();
        
        cout << v21.back() << " ";
        v21.pop_back();
        cout << v22.back() << " ";
        v22.pop_back();
        
        
        for (int i = 0; i < n / 2; ++i) {
            if (v3.size() != 0) {
                cout << v3.back() << " ";
                v3.pop_back();
                cout << v3.back() << " ";
                v3.pop_back();
                continue;
            }
            
            if (v21.size() != 0) {
                cout << v21.back() << " ";
                v21.pop_back();
                cout << v22.back() << " ";
                v22.pop_back();
                continue;
            }
            
            cout << v23.back() << " ";
            v23.pop_back();
            cout << v23.back() << " ";
            v23.pop_back();
        }
        
        if (n % 2 == 1) {
            cout << v23.back() << " ";
            v23.pop_back();
        }
    }
    
    return 0;
}



Measured memory_bytes: 512
/** AtCoder Beginner Contest 136, by Abreto<m@abreto.net> */
#include <bits/stdc++.h>

using namespace std;

namespace abreto {

int check(int n)
{
    int d = 0;
    while (n)
    {
        d++;
        n /= 10;
    }
    return (d & 1);
}

void main(void)
{
    int N;
    int ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i++)
        ans += check(i);
    cout << ans << '\n';
}

}

int main(void)
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    abreto::main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#define MAX 100001
using namespace std;

class Queue{
    pair<string, int> q[MAX];
    int head = 0;
    int tail = MAX - 1;
public:
    bool is_empty(){
        int diff = tail - head;
        if (diff == -1 || diff == MAX) return true;
        return false;
    }
    void enqueue(pair<string, int> num){
        tail = (tail + 1) % MAX;
        q[tail] = num;
    }
    pair<string, int> dequeue(){
        pair<string, int> ret = q[head];
        head = (head + 1) % MAX;
        return ret;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    Queue que1;
    for (int i = 0; i < n; i++) {
        string p;
        int num;
        cin >> p >> num;
        que1.enqueue(make_pair(p, num));
    }
    Queue que2;
    int time_ = 0;
    while(!que1.is_empty()) {
        pair<string, int> front = que1.dequeue();
        if (front.second <= q) {
            time_ += front.second;
            front.second = time_;
            que2.enqueue(front);
        } else {
            front.second -= q;
            time_ += q;
            que1.enqueue(front);
        }
    }
    while (!que2.is_empty()) {
        pair<string, int> front = que2.dequeue();
        cout << front.first << " " << front.second << endl;
    }
    return 0;
}

Measured memory_bytes: 8608
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, k;
    cin >> a >> b >> k;
    for( int i = 100; i >= 1; --i ) {
        if( !(a % i) && !( b % i ) ) --k;
        if( !k ) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}



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

int main() {
    cin.tie(NULL); cout.tie(NULL);
    ios_base::sync_with_stdio(false);
   long long int a,b,c,d; cin>>a>>b>>c>>d;
cout<<max(max(a*d,a*c),max(b*d,b*c));
   
	return 0;
}


Measured memory_bytes: 3656
import math

def abc175c_walking_takahashi():
    x, k, d = map(int, input().split())
    x = -x if x < 0 else x
    num = math.ceil(x / d)
    if num > k:
        print(x-k*d)
        return
    else:
        k -= num
        x -= num*d
        if k % 2 == 0:
            print(abs(x))
        else:
            print(x+d)
abc175c_walking_takahashi()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ‘ ‘
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n)
    cin >> a[i];
  reverse(all(a));
  b[0] = 0;
  rep2(i, 1, n){
    if(a[i - 1] > a[i])
      b[i] = 0;
    else
      b[i] = b[i - 1] + 1;
  }
  k = 0;
  rep(i, n)
    k = max(k, b[i]);
  cout << k;
  memi;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;
const double PI = 3.14159265358979323846;

bool IsPrime(ll num)  //素数判定
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;  // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }
  // 素数である
  return true;
}

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double h = 2 * x / b / a;
  if (h <= a) {
    cout << setprecision(12) << 90 - acos(b / (sqrt(h * h + b * b))) * 180 / PI
         << endl;
  } else {
    double v = a * a * b - x;
    double w = 2 * v / a / a;
    cout << setprecision(12) << 90 - acos(w / sqrt(w * w + a * a)) * 180 / PI
         << endl;
  }
  return 0;
}

Measured memory_bytes: 256