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

int main(){
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);

    int64_t w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << (w*h)*0.5;
    if(w%2==0 && x==w/2 && h%2==0 && y==h/2) cout << " 1" << endl;
    else cout << " 0" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import math

def readinput():
    n=int(input())
    a=[]
    for i in range(n):
        a.append(int(input()))
    return n,a

def isPrime(n):
    if n==2:
        return True

    if n<=1 or n%2==0:
        return False

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

def getPrimes(n):
    '''n以下の素数のリストを返す'''
    p=[]
    for i in range(2,n+1):
        if isPrime(i):
            p.append(i)
    return p

def main(n,a):
    m=max(a)
    p=getPrimes(m)
    cnt=0
    for _ in a:
        if _ in p:
            cnt+=1
    return cnt

if __name__=='__main__':
    #n,a=readinput()
    #ans=main(n,a)
    n=int(input())
    cnt=0
    for i in range(n):
        x = int(input())
        if isPrime(x):
            cnt+=1
    print(cnt)



Measured memory_bytes: 5680
#include <bits/stdc++.h>
 
#define int long long
#define left left1
#define right right1
 
using namespace std;

int can[5][5];
pair <int, int> was[101];

void solve () {
    cout << "Yes";
    exit (0);
}

 main () {
    //freopen ("deleg.in", "r", stdin);
    //freopen ("deleg.out", "w", stdout);
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
    for (int i = 1;i <= 3;i ++) {
        for (int j = 1;j <= 3;j ++) {
            int x;
            cin >> x;
            was[x] = make_pair (i, j);
        }
    }
    int n;
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        int x;
        cin >> x;
        int q = was[x].first;
        int w = was[x].second;
        can[q][w] = 1;
    }
    if (can[1][1] + can[1][2] + can[1][3] == 3) solve ();
    if (can[2][1] + can[2][2] + can[2][3] == 3) solve ();
    if (can[3][1] + can[3][2] + can[3][3] == 3) solve ();
    
    if (can[1][1] + can[2][1] + can[3][1] == 3) solve ();
    if (can[1][2] + can[2][2] + can[3][2] == 3) solve ();
    if (can[1][3] + can[2][3] + can[3][3] == 3) solve ();
    
    
    if (can[1][3] + can[2][2] + can[3][1] == 3) solve ();
    if (can[1][1] + can[2][2] + can[3][3] == 3) solve ();
    cout << "No";
	return 0;   
}

Measured memory_bytes: 256
a_list = [int(input()) for _ in range(5)]

min_index = -1
min_num = 9
for i, a in enumerate(a_list):
    last = int(str(a)[-1])
    if last == 0:
        continue
    if last <= min_num:
        min_num = last
        min_index = i

if min_index == -1:
    print(sum(a_list))
    exit()

ans = 0
for i, a in enumerate(a_list):
    last = int(str(a)[-1])
    if i == min_index:
        ans += a
    elif last == 0:
        ans += a
    else:
        ans += a
        ans += 10 - last
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int ans[5];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(ans,-1,sizeof(ans));
	int n,m;
	cin>>n>>m;
	bool flag=false;
	for(int i=1;i<=m;i++)
	{
		int s,c;
		cin>>s>>c;
		if(ans[s]==-1||ans[s]==c)
			ans[s]=c;
		else
			flag=true;
	}
	if(flag)
	{
		cout<<-1<<endl;
		return 0;
	}
	if(n==1)
	{
		if(ans[1]==-1)
		{
			cout<<0<<endl;
			return 0;
		}
		else
		{
			cout<<ans[1]<<endl;
			return 0;
		}
	}
	if(ans[1]==0)
	{
		cout<<-1<<endl;
		return 0;
	}
	if(ans[1]==-1)
		ans[1]=1;
	for(int i=2;i<=n;i++)
		if(ans[i]==-1)
			ans[i]=0;
	for(int i=1;i<=n;i++)
		cout<<ans[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int a,b; cin>>a>>b;
	co(a+b/2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const int INF = 1e+9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main () {
  int N; cin >> N;
  int ans = N;
  for (int i = 0; i <= N; i++) {
    int cc = 0;
    int t = i;
    while (t > 0) {
      cc += t%6;
      t /= 6;
    }
    t = N-i;
    while (t > 0) {
      cc += t%9;
      t /= 9; 
    }
    if (ans > cc) ans = cc;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,x,tot,cnt,sum;
int a[N],b[N],c[N];
int main(){
	scanf("%d",&n);
	for (register int i=1; i<=n; ++i)
	{ 
		scanf("%d",&x);
		if (i&1) a[++tot]=x;
		else b[++cnt]=x;
		c[i]=x;	
	}
	sort(a+1,a+tot+1); sort(b+1,b+cnt+1);
	sort(c+1,c+n+1);
	for (register int i=1; i<=tot; i++) 
	{
		int pos=lower_bound(c+1,c+n+1,a[i])-c;
		if (pos%2!=1) sum++;
	}
	for (register int i=1; i<=cnt; ++i)
	{
		int pos=lower_bound(c+1,c+n+1,b[i])-c;
		if (pos%2!=0) sum++;
	}
	printf("%d\n",sum/2);
return 0;	
}

Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		System.out.println(n+n*n+n*n*n);
	}

}


Measured memory_bytes: 35756
/*Lucky_Glass*/
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N=2e5;
#define fir first
#define sec second

int n;
int A[N+3],B[N+3];
bool fail;
priority_queue< pair<int,int> > que;

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&A[i]);
    for(int i=0;i<n;i++){
        scanf("%d",&B[i]);
        if(B[i]!=A[i]) que.push(make_pair(B[i],i));
        if(B[i]<A[i]) fail=true;
    }
    if(fail) printf("-1\n"),exit(0);
    long long ans=0;
    while(!que.empty()){
        int it=que.top().sec;que.pop();
        int div=B[(it+1)%n]+B[(it-1+n)%n];
        long long delta=(B[it]-A[it])/div;
        if(!delta){fail=true;break;}
        B[it]-=div*delta;
        ans+=delta;
        if(B[it]==A[it]) continue;
        que.push(make_pair(B[it],it));
    }
    if(fail) printf("-1\n");
    else printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3700
if __name__ == '__main__':
    text = input()
    number = int(input())
    dic = []

    for text_len in range(1, min(len(text),number) + 1):
        for ss_len in range(0, len(text) - text_len + 1):
            word = text[ss_len:text_len + ss_len]
            if word not in dic:
                dic.append(word)

    dic = sorted(dic)

    print(dic[number - 1])

Measured memory_bytes: 4084
#include<stdio.h>
#include<math.h>
#define PI 3.141592653589793238462643383279
const double r=10.0;
const double eps=1e-8;
int main(void)
{
  int m,n,i,a[100],b[100];
  long double sa,sb;
  for(;;){
    scanf("%d",&m); if(!m)break;
    a[m-1]=360;
    for(i=0;i<m-1;i++){
      scanf("%d",a+i);
      a[m-1]-=a[i];
    }
    scanf("%d",&n);
    b[n-1]=360;
    for(i=0;i<n-1;i++){
      scanf("%d",b+i);
      b[n-1]-=b[i];
    }
    sa=sb=0;
    for(i=0;i<m;i++)
      sa+=1.0/2.0*r*r*sin(a[i]*PI/180);
    for(i=0;i<n;i++)
      sb+=1.0/2.0*r*r*sin(b[i]*PI/180);
    sa=fabs(sa); sb=fabs(sb);
    if(sa>sb+eps)puts("1");
    else if(sa+eps<sb)puts("2");
    else puts("0");
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
 
int main() {
  string str1,str2;
  cin>>str1>>str2;

  sort(str1.begin(), str1.end()); 
  sort(str2.begin(), str2.end(), greater<char>());

  if (str1 < str2) 
        cout<<"Yes";
     else
         cout<<"No";

}



Measured memory_bytes: 256
from collections import deque
n,x,y = map(int,input().split())
x,y = x-1 ,y-1
g = [[float('inf')]*n for _ in range(n)]
for i in range(n):
    que = deque([(i, 0)])
    while que:
        node, cost = que.popleft()
        if g[i][node]!=float('inf'):
            continue
        else:
            g[i][node] = cost
            if node>0:
                que.append((node-1, cost+1))
            if node<n-1:
                que.append((node+1, cost+1))
            if node==x:
                que.append((y, cost+1))
            if node==y:
                que.append((x, cost+1))
cnt = [0]*n
for i in range(n):
    for j in range(i+1, n):
        cnt[g[i][j]] += 1
for c in cnt[1:]:
    print(c)

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


int main() {
	string bsc;
	int ans = 0;
	cin >> bsc;
	int end = bsc.size()/2;
	for(int i=0,j=bsc.size()-1; i<end; i++,j--) {
		if(bsc[i]!=bsc[j]) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp.chars
l = s.length
k = gets.to_i
s << "_"

conts = []
cont = 1
[*1..l].each{|i|
  if s[i] == s[i-1]
    cont += 1
  else
    conts << cont
    cont = 1
  end
}
if conts.length == 1
  ans = conts[0]*k/2
elsif s[0] != s[l-1]
  ans = conts.map{|i|i/2}.inject(:+)
  ans *= k
else
  ans1 = conts.map{|i|i/2}.inject(:+)
  conts.push (conts.pop + conts.shift)
  ans2 = conts.map{|i|i/2}.inject(:+)
  ans = ans1 + ans2 * (k-1)
end
p ans


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

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

	int res = 0;
	REP(i, n - 1) {
		if (s[i] == s[i+1])
			res++;
	}

	string find_word1, find_word2;
	if (s[0] == 'L') {
		find_word1 = "LR";
		find_word2 = "RL";
	} else {
		find_word1 = "RL";
		find_word2 = "LR";
	}
	auto pos = s.find(find_word1);
	int cnt = 0;
	while (pos != string::npos) {
		auto pos2 = s.find(find_word2, pos + 1);
		if (pos2 != string::npos)
			cnt++;
		else
			break ;
		pos = s.find(find_word1, pos2 + 1);
	}
	if (pos != string::npos)
		if (cnt < k)
			res++;
	cout << res + min(k, cnt) * 2 << '\n';
    return 0;
}


Measured memory_bytes: 3672
#include <map>
#include <cmath>
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 5;
LL a[MAXN] , tr[MAXN] , prim[MAXN];
int n , is_pr[MAXN] , cnt;
map <int , int> M;
void pre(int m) {
	for (LL i = 1; i <= m; ++i) tr[i] = i * i * i;
	for (int i = 2; i <= m; ++i) {
		if(!is_pr[i]) prim[++cnt] = i;
		for (int j = 1; j <= cnt && prim[j] * i <= m; ++j) {
			is_pr[i * prim[j]] = 1;
			if(i % prim[j]) break; 
		}
	}
}
void update(LL &x) {
	for (int i = 2; i <= 3200; ++i) {
		if(tr[i] > x) break;
		while(x % tr[i] == 0) x /= tr[i];
	}
}
LL b[MAXN] , tot;
LL get_g(LL x) {
	LL res = 1;
	for (int i = 1; i <= cnt; ++i) {
		if(prim[i] > x) break;
		LL tot = 0;
		while(x % prim[i] == 0) x /= prim[i] , tot ++;
		if(tot) {
			tot = 3 - tot;
			while(tot -- > 0) res = res * prim[i];
		}
	}
	if(x == 1) return res;
	LL tmp = sqrt(x);
	if(tmp * tmp == x) return res * tmp;
	else return res * x * x;
}
signed main() {
	scanf("%lld" , &n);
	for (int i = 1; i <= n; ++i) scanf("%lld" , &a[i]);
	pre(3200);
	for (int i = 1; i <= n; ++i) {
		update(a[i]);
		if(!M[a[i]]) b[++tot] = a[i];
		M[a[i]] ++;
	}
	LL ans = 0;
	for (int i = 1; i <= tot; ++i) {
		if(b[i] == 1) ans ++;
		else {
			LL tmp = get_g(b[i]);
			ans += max(M[b[i]] , M[tmp]);
			M[b[i]] = M[tmp] = 0;
		}
	}
	printf("%lld" , ans);
	return 0;
}

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

using namespace std;

int main()

{

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

	d=c;

	c=b;

	b=a;

	a=d;

	cout<<a<<" "<<b<<" "<<c<<endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	cin >> a;
	sort(a.begin(), a.end());
	ll deg = a.back();
	ll ma = 0;
	ll ans = 0;
	for (int i = 0; i < n - 1; ++i) {
		ll tmp = min(a[i], deg - a[i]);
		if (tmp > ma) {
			ans = a[i];
			ma = tmp;
		}
	}
	cout << deg << ' ' << ans << endl;
	return 0;
}

Measured memory_bytes: 4000
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int x, n;
int p[110];

int solve() {
    set<int> s;
    for (int i = 0; i < n; i++) s.insert(p[i]);

    int diff = inf;
    int res = 0;
    for (int i = -100; i <= 200; i++) {
        if (s.count(i) == 0 && abs(x-i) < diff) {
            res = i;
            diff = abs(x-i);
        }
    }
    return res;
}

void input() {
    cin >> x >> n;
    for (int i = 0; i < n; i++) cin >> p[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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

typedef long long ll;

int main() {
    ll A ;
    ll B ;
    ll C ;

    cin >> A >> B >> C ;
    
    ll a ;
    ll b ;
    ll c ;

    if ( A%2 == 1 ){a = B*C ; }
    else {a = 0 ; }

    if ( B%2 == 1 ){ b = A*C ; }
    else { b = 0 ; }

    if ( C%2 == 1 ){ c = A*B ; }
    else { c = 0 ; }

    ll ans = min(a,min(b,c));
    
    cout << ans << endl;
    
    
    
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long

int32_t main()
{
 
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   // int t;
   // cin >> t;
    int n,m,k;
    cin >> n >> m >> k;
	char mat[n][m];
	fo(i,0,n){
		fo(j,0,m)cin >> mat[i][j];


	}	
	int ans = 0;    
	fo(mar,0,(1ll << n)){
		fo(mac,0,(1ll << m)){
			int b  = 0;
			fo(i,0,n){
				fo(j,0,m){
					if(((mar >> i)&1^1) && ((mac >> j)&1^1) && (mat[i][j] == '#'))b++;
				}
			}
			if(b == k)ans++;
		}
	}
	cout << ans << endl;




return 0;
}


Measured memory_bytes: 3632
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!long;
    const S = readln.chomp;
    const K = readln.chomp.to!long;

    S.map!(c => c != S[K-1] ? "*" : [c]).join.writeln;
}



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

int main() {
  int N, a = 0, b = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for(int i = N - 1; i >= 0; i--){
    if(N % 2 == 1){
    if(i % 2 == 0) a += A.at(i);
    else b += A.at(i);
    }
    else{
    if(i % 2 == 1) a += A.at(i);
    else b += A.at(i);    
    }
  }
  cout << a - b << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int length = arr.length;
        long[][] dp = new long[length + 1][2];
        dp[0][1] = 1;
        for (int i = 1; i <= length; i++) {
            dp[i][0] += dp[i - 1][0] * 3;
            dp[i][0] %= MOD;
            if (arr[i - 1] == '1') {
                dp[i][1] += dp[i - 1][1] * 2;
                dp[i][1] %= MOD;
                dp[i][0] += dp[i - 1][1];
                dp[i][0] %= MOD;
            } else {
                dp[i][1] += dp[i - 1][1];
            }
        }
        System.out.println((dp[length][0] + dp[length][1]) % MOD);
    }
}

Measured memory_bytes: 29732
#include<bits/stdc++.h>
using namespace std;
/*long long fun(long long sum,int i,int n,long long int *arr)
{
    if(i==(n-1))
    return sum;
    long long int ans1,ans2;
    if((i+1)<=n-1)
    ans1=fun(sum+abs(arr[i+1]-arr[i]),i+1,n,arr);
    else
    ans1=-1;
    if((i+2)<=(n-1))
    ans2=fun(sum+abs(arr[i+2]-arr[i]),i+2,n,arr);
    else
    ans2=-1;
    if(ans1!=-1&&ans2!=-1)
    return min(ans1,ans2);
    else if(ans1==-1)
    return ans2;
    else if(ans2==-1)
    return ans1;
    return -1;
}*/
int main(void)
{
    long long int n;
    cin>>n;
    long long int *arr=new long long int[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    //1st method.
    //long long int ans=fun(0,0,n,arr);
    //cout<<ans<<endl;

    //2nd method.
    /*int a[n]={0};
    int b[n]={0};
    for(int i=1;i<n;i++)
    {
        a[i]=abs(arr[i]-arr[i-1])+min(a[i-1],b[i-1]);
        if(i==1)
        b[i]=a[i];
        else
        b[i]=abs(arr[i]-arr[i-2])+min(a[i-2],b[i-2]);
    }
    cout<<min(a[n-1],b[n-1])<<endl;*/

    //3rd method.
    long long int a[n];
    for(int i=0;i<n;i++)
    a[i]=INT_MAX;
    a[0]=0;
    for(int i=0;i<(n-1);i++)
    {
        if((i+1)<n)
        a[i+1]=min(a[i+1],a[i]+abs(arr[i]-arr[i+1]));
        if((i+2)<n)
        a[i+2]=min(a[i+2],a[i]+abs(arr[i]-arr[i+2]));
    }
    cout<<a[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>


#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define micro 0.000001
using namespace std;

int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
pair <int, int> vu[4] = { {0,1}, {0,-1} , {1,0},{-1,0} }; // EWSN

const int max_v = 4e6 + 7;
const int INF = 1e9 + 7;



int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a, b, c;
	ci(a >> b >> c);
	swap(a, b);
	swap(a, c);
	co(a << " " << b << " " << c);
	return 0;
}	

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int n, a, b;
string s;

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

	cin >> n >> s;
	for (char c : s)
		if (c == 'R') a++;
		else b++;

	if (a > b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

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

  int a = s.find('A');
  int z = s.rfind('Z');
  int ans = z - a + 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

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

  int l = 0, r = n-1;
  int c = 0;
  while (1) {
    while (l < n && s[l] == 'R') l++;
    while (r >= 0 && s[r] == 'W') r--;
    if (l < r) {
      s[r] = 'W';
      s[l] = 'R';
      l++; r--;
      c++;
    } else {
      break;
    }
  }

  cout << c << endl;
}


Measured memory_bytes: 3748
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, w: usize,
        gv: [(usize, usize); n]
    }

    let mut dp = vec![1<<60; 100001];
    dp[0] = 0;
    for (g, v) in gv {
        for i in (0..=100000).rev() {
            if i + v <= 100000 {
                dp[i+v] = min(dp[i+v], dp[i]+g);
            }
        }
    }
    for i in (0..=100000).rev() {
        if dp[i] <= w {
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 2852
S = input()

N = len(S)

S2 = S

# s[0] = '1'

count_1 = 0
count_2 = 0
for i in range(N):
	if i % 2 == 0:
		if S[i] == '1':
			count_1 += 1
		else:
			count_2 += 1
	else:
		if S[i] == '0':
			count_1 += 1
		else:
			count_2 += 1

print (min(count_1,count_2))


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    N,K=map(int,input().split())
    S=[0]*N
    for i in range(K):
        d=int(input())
        A=list(map(int,input().split()))
        for i in range(len(A)):
            S[A[i]-1]+=1
    
    print(S.count(0))

    
resolve()

Measured memory_bytes: 67656
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    cout << (s[0] == s[1] && s[2] == s[3] && s[0] != s[3] ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ll mod2 = 998244353;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define lwi(x) cout << " your " << #x << " is ---> " << x << " ";
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e6+5;
int32_t main(){
    FastIO;
    int x, y;
    cin >> x >> y;
    if (y > 4*x || y < 2*x || y&1) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


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


int main()
{
 	string S; cin >> S;
	int h[10];
	int count = 0;
	int answer = 0;
	for (int i=0;i<10;i++){
		h[i] = 0;
	}
	for (int i=0;i<S.length();i++){
		if (S.at(i)=='A'){
			h[i] = 1;
		}
		if (S.at(i)=='C'){
			h[i] = 1;
		}
		if (S.at(i)=='G'){
			h[i] = 1;
		}
		if (S.at(i)=='T'){
			h[i] = 1;
		}
	}
	for (int i=0;i<10;i++){
		if (h[i] == 1){
			count ++;
		}
		if (h[i] == 0){
			count = 0;
		}
		if (answer < count){
			answer = count;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vi prime_count;
void sieve(int max){
    int count = 0;
    vector<bool> table(max + 1, true);
    table[0] = false;
    prime_count.push_back(0);
    table[1] = false;
    prime_count.push_back(0);
    for(int i = 2; i <= max; i++){
        if(table[i]){
            count++;
            for(int j = 2; i * j <= max; j++){
                table[i * j] = false;
            }
        }
        prime_count.push_back(count);
    }
}

int main(){
    int n;
    sieve(1000000);
    while(cin>>n){
        cout << prime_count[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 5440
#include <bits/stdc++.h>
#define INL inline
#define REG register
#define DB double
#define LDB long double
#define ULL unsigned long long
#define LL long long

#define RPT(i,x,y) for (REG int i=(x);i<(y);i++)
#define DRPT(i,x,y) for (REG int i=(x);i>(y);i--)
#define MST(a,b) memset((a),(b),sizeof(a))
#define MRK() cout<<"Mark"<<endl;
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;

#define MAXN 10000
#define MAXM 10000
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;

ULL dp[52][52][3010];
LL n,k;
int main()
{
	cin>>n>>k;
	if (k&1)
	{
		cout<<0;
		return 0;
	}
	dp[0][0][0]=1;
	RPT(i,0,n+1)
		RPT(j,0,i+1)
			RPT(k,0,i*i+2)
			{
				//cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<endl;
				dp[i][j][k]%=MOD;
				dp[i+1][j][k+j]+=dp[i][j][k];
				dp[i+1][j+1][k+j+1]+=dp[i][j][k];
				dp[i+1][j][k+j]+=dp[i][j][k]*2*j;
				if (j>=1)
					dp[i+1][j-1][k+j-1]+=dp[i][j][k]*j*j;
			}
	cout<<dp[n][0][k/2];
	return ~~(0^_^0);
}



Measured memory_bytes: 61824
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	char a[3];
 	cin >> a;
 	if(a[0]!=a[1]&&a[0]!=a[2]&&a[1]!=a[2]){
 		cout << "Yes" << endl;
 	}else{
 		cout << "No" << endl;
 	}
 }

Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
x =[]
y =[]
info = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
  x.append([i,info[i][0]])
  y.append([i,info[i][1]])

x = sorted(x,key=itemgetter(1))
y = sorted(y,key=itemgetter(1))
tree = []
#for i in range(n):
#  if i==0:
#    tree[x[i][0]].append([x[i+1][0],abs(x[i][1]-x[i+1][1])])
#    tree[y[i][0]].append([y[i+1][0],abs(y[i][1]-y[i+1][1])])
#  elif i==n-1:
#    tree[x[i][0]].append([x[i-1][0],abs(x[i][1]-x[i-1][1])])
#    tree[y[i][0]].append([y[i-1][0],abs(y[i][1]-y[i-1][1])])
#  else:
#    tree[x[i][0]].append([x[i+1][0],abs(x[i][1]-x[i+1][1])])
#    tree[x[i][0]].append([x[i-1][0],abs(x[i][1]-x[i-1][1])])
#    tree[y[i][0]].append([y[i+1][0],abs(y[i][1]-y[i+1][1])])
#    tree[y[i][0]].append([y[i-1][0],abs(y[i][1]-y[i-1][1])])
    
for i in range(n-1):
    tree.append([x[i][0],x[i+1][0],abs(x[i][1]-x[i+1][1])])
    tree.append([y[i][0],y[i+1][0],abs(y[i][1]-y[i+1][1])])

#UnionFindクラス
class UnionFind(object):

  def __init__(self, n=1):
    self.par = [i for i in range(n)]
    self.rank = [0 for _ in range(n)]

  def find(self, x):
  
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
  
  # xとyの根を結合させる
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x != y:
      if self.rank[x] < self.rank[y]:
        x, y = y, x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
      self.par[y] = x
  
  # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）
  def is_same(self, x, y):
    return self.find(x) == self.find(y)

uf = UnionFind(len(tree))
tree = sorted(tree,key=itemgetter(2))
ans = 0

for i in range(len(tree)):
  if not uf.is_same(tree[i][0],tree[i][1]):
    uf.union(tree[i][0],tree[i][1])
    ans +=tree[i][2]
print(ans)

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int count = 0;
  while(k > 0) {
    if(a > 0) {
      a--; k--; count++;
    }
    else if(a == 0 && b > 0){
      b--; k--;
    }
    else {
      c--; k--; count--;
    }
  }
  cout << count << endl;
} 



Measured memory_bytes: 3596
// Problem : C - Digits in Multiplication
// Contest : AtCoder - AtCoder Beginner Contest 057
// URL : https://atcoder.jp/contests/abc057/tasks/abc057_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
inline int dig(ll N)
{
	int c=0;
	while(N!=0)
	{
		N/=10;
		c++;
	}
	return c;
} 
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll N;
	cin>>N;
	int mn=dig(N);
	for(ll x=2;x<=sqrt(N);x++)
	{
		if(N%x==0)
		{
			ckmin(mn,max(dig(x),dig(N/x)));
		}
	}
	cout<<mn<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 

int main()
{
    long X,Y,Z;
    std::cin >> X >> Y >> Z;
    std::cout << Z << " " << X << " " <<Y << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
int N, C, s, t, c;
vector<P> channel[40], V, G[40];
priority_queue<ll, vector<ll>, greater<ll>> que;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> N >> C;
	for (int i = 0; i < N; i++)
	{
		cin >> s >> t >> c;
		channel[c].push_back(P(s, t));
	}
	for (int i = 1; i <= C; i++)
	{
		sort(channel[i].begin(), channel[i].end());
		for (int j = 0; j < channel[i].size(); j++)
		{
			if (j == 0)
			{
				G[i].push_back(P(channel[i][j].first, channel[i][j].second));
			}
			else
			{
				if (G[i][G[i].size() - 1].second == channel[i][j].first)
				{
					G[i][G[i].size() - 1] = P(G[i][G[i].size() - 1].first, channel[i][j].second);
				}
				else
				{
					G[i].push_back(P(channel[i][j].first, channel[i][j].second));
				}
			}
		}
	}
	for (int i = 1; i <= C; i++)
	{
		for (int j = 0; j < G[i].size(); j++)
		{
			V.push_back(P(G[i][j].first, G[i][j].second + 1));
		}
	}
	sort(V.begin(), V.end());
	que.push(V[0].second);
	for (int i = 1; i < V.size(); i++)
	{
		ll time = que.top();
		if (time <= V[i].first)
		{
			que.pop();
		}
		que.push(V[i].second);
	}
	cout << que.size() << endl;
	int www;
	cin >> www;
}


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

using namespace std;

int		main(void)
{
	vector<int> a(3);
	cin >> a.at(0) >> a.at(1) >> a.at(2);
	sort(a.begin(), a.end());
	cout << a.at(0) << " " << a.at(1) << " " << a.at(2) << endl;
	return (0);
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<string> w(n);
    map<string, int> mp;
    rep(i, n)
    {
        cin >> w[i];
    }
    mp[w[0]]++;
    rep(i, n - 1)
    {
        if(mp[w[i+1]] != 0 || w[i][w[i].size()-1] != w[i+1][0]){

            cout << "No" << endl;
            return 0;
        }
        mp[w[i+1]]++;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int k;
    cin>>k;
    set<string>x;
    for(int i=0;i<k;i++){
        for(int j=0;j+i<n;j++){
            string subs;
            for(int l=j;l<=j+i;l++)subs.push_back(s[l]);
            x.insert(subs);
        }
    }
    auto itr=x.begin();
    for(int i=0;i<k-1;i++)++itr;
    cout<<*itr<<endl;
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    int n,k;
    cin >> n >> k;
    vvi v(n,vi(3));
    {
        int i = 0;
        int num = 0;
        while(i < n)v[i][0] = num, i += 2, num++;
        i = 1;
        while(i < n)v[i][0] = num, i += 2, num++;
        i = 1;
        while(i < n)v[i][1] = num, i += 2, num++;
        i = 0;
        while(i < n)v[i][1] = num, i += 2, num++;
    }
    bool ans = true;
    rep(i,n){
        v[i][0] += k;
        v[i][1] += k;
        v[i][2] = 2*n+i+k;
        if(v[i][0] + v[i][1] > v[i][2])ans = false;
    }
    if(ans)rep(i,n)cout << v[i][0] << " " << v[i][1] << " " << v[i][2] << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 7680
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);
	if(a < b)
		printf("a < b\n");
	else if(a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return 0;
}

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

int main(){
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> VA(A);
  vector<int> VB(B);
  vector<vector<int>> VC(M, vector<int>(3));
  for (int i = 0; i < A; i++) cin >> VA.at(i);
  for (int i = 0; i < B; i++) cin >> VB.at(i);
  for (int i = 0; i < M; i++) cin >> VC.at(i).at(0) >> VC.at(i).at(1) >> VC.at(i).at(2);
  int tmp, minA = VA.at(0), minB = VB.at(0);
  for (int i = 1; i < A; i++) minA = min(minA, VA.at(i));
  for (int i = 1; i < B; i++) minB = min(minB, VB.at(i));
  tmp = minA + minB;
  int minC = 10000000;
  for (int i = 0; i < M; i++) minC = min(minC, VA.at(VC.at(i).at(0) - 1) + VB.at(VC.at(i).at(1) - 1)- VC.at(i).at(2));
  cout << min(tmp, minC) << endl;
  return 0;
}

Measured memory_bytes: 9560
#include <stdio.h>
#include <stdlib.h>
     
long long inv;
int *B;
     
long long countup(int *A, int p, int r);
     
int main(int argc, char *argv[])
{
  int n, i, j;
  int *A;
     
  inv = 0;
     
  scanf("%d", &n);
  A = (int *)malloc(sizeof(int) * n);
  B = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
     
  inv = countup(A, 0, n - 1);
     
  printf("%lld\n", inv);
     
  return 0;
}
     
long long countup(int *A, int p, int r)
{
  int q = p + (r-p)/2;
  int i, j, k, tmp;
  long long ct = 0;
     
  if (r - p < 3) {
    for (i = p; i < r; i++) {
      for (j = r; j > i; j--) {
    if (A[j] < A[j-1]) {
      tmp = A[j-1];
      A[j-1] = A[j];
      A[j] = tmp;
      ct++;
    }
      }
    }
    return ct;
  }
  ct += countup(A, p, q);
  ct += countup(A, q+1, r);
     
  i = p;
  j = q + 1;
  for (k = p; k <= r; k++) {
    if (i >= q + 1 || j >= r + 1) {
      if (i >= q + 1) B[k] = A[j++];
      else B[k] = A[i++];
    } else {
      if (A[i] > A[j]) {
    B[k] = A[j];
    ct += q - i + 1;
    j++;
      } else {
    B[k] = A[i];
    i++;
      }
    }
  }
  for (k = p; k <= r; k++) A[k] = B[k];
  return ct;
}



Measured memory_bytes: 3272
import numpy as np
n, m, q = map(int, input().split())
kukan = np.zeros((n+1, n+1))
for _ in range(m):
    l, r = map(int, input().split())
    kukan[r][l] += 1

# まず終点の側から考える
# iまでに終わる線分の数はi-1までの累積和
for i in range(1, n+1):
    kukan[i] += kukan[i-1]
# 次に始点の側から考える
# i以降に始まる線分の数はi-1までの総和
for i in range(1, n+1):
    kukan[:, i] += kukan[:, i-1]
# print(kukan)
for i in range(1, q+1):
    p, q = list(map(int, input().split()))
    print(int(kukan[q][q] - kukan[q][p-1] - kukan[p-1][q] + kukan[p-1][p-1]))


Measured memory_bytes: 15196
N,M = map(int,input().split())
MOD = 10 ** 9 + 7
import sys
frac_list = [0 for i in range(100)]

def comb_cal(n,r):
    tmp = 1
    for i in range(r):
        tmp *= (n - i)
    for i in range(r):
        tmp //= r - i
    return tmp

frac = []
while True:
    for i in range(2,int(M**(1/2))+1):
        if M % i == 0:
            frac.append(i)
            M //= i
            break
    else:
        break
if M > 1:
    frac.append(M)
def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())
c = counter(frac)
ans = 1
for x in c:
    ans *= (comb_cal(x[1]+N-1,x[1]) % MOD)
    ans %= MOD
print(ans)



Measured memory_bytes: 3444
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = new int[N][];

            for (var i = 0; i < N; i++)
            {
                array[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }

            array = array.OrderBy(z => z[1]).ToArray();

            var current = 0L;
            for (var i = 0; i < N; i++)
            {
                current += array[i][0];
                if (current > array[i][1])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}

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

using namespace std;
#define ll long long
#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--)
const ll mod = 1e9 + 7;
typedef pair<int,int>           PI;
typedef pair<ll,ll>             PL;
typedef vector<PI>               vip; 
typedef vector<int>             vi;
typedef vector<vi>              vvi;
typedef vector<ll>              vl;
typedef vector<vl>              vvl;






int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vl a(x);
    vl b(y);
    vl c(z);
    REP(i,x){
        cin >> a[i];
    }
    REP(i,y){
        cin >> b[i];
    }
    REP(i,z){
        cin >> c[i];
    }

    sort(a.begin(),a.end(), greater<ll>());
    sort(b.begin(),b.end(), greater<ll>());
    sort(c.begin(),c.end(), greater<ll>());

    map<tuple<int,int,int>, bool> mp;

    priority_queue<tuple<ll,int,int,int> > que;
    tuple<ll,int,int,int> t = make_tuple(a.at(0)+b.at(0)+c.at(0), 0, 0, 0);
    que.push(t);
    REP(i,k){
        tuple<ll,int,int,int> N = que.top();
        que.pop();
        ll total = get<0>(N);
        int A = get<1>(N);
        int B = get<2>(N);
        int C = get<3>(N);
        if(mp.find(make_tuple(A,B,C)) == mp.end()){//not found
            mp.emplace(make_tuple(A,B,C), true);
        }else{
            i--;
            continue;
        }
        cout << total << endl;
        if(A+1 < x && B < y && C < z ){
        que.push(tuple<ll,int,int,int>(a.at(A+1)+b.at(B)+c.at(C), A+1, B, C) );
        }
        if(A < x && B+1 < y && C < z ){
        que.push(tuple<ll,int,int,int>(a.at(A)+b.at(B+1)+c.at(C), A, B+1, C) );
        }
         if(A < x && B < y && C+1 < z ){
        que.push(tuple<ll,int,int,int>(a.at(A)+b.at(B)+c.at(C+1), A, B, C+1) );
        }
        
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int A, B;
  cin >> A >> B;
  string b, w;
  int k = 50;
  loop(2 * k) {
    b += "#";
    w += ".";
  }

  vector<string> v(2 * k);
  rep(i, 0, k) {
    v[i] = b;
    v[i + k] = w;
  }

  int x = 0, y = 0, d = 2;
  auto inrange = [&](int x, int y) {
    return 0 <= x and x < 2 * k and 0 <= y and y < 2 * k;
  };
  int cnt = 0;
  while (cnt < A - 1) {
    if (inrange(x, y)) {
      v[x][y] = '.', cnt++;
      y += 2;
    } else {
      x += 2;
      y = 0;
    }
  }
  x = 2 * k - 1, y = 0;
  cnt = 0;
  while (cnt < B - 1) {
    if (inrange(x, y)) {
      v[x][y] = '#', cnt++;
      y += 2;
    } else {
      x -= 2;
      y = 0;
    }
  }

  cout << 2 * k << " " << 2 * k << endl;
  rep(i, 0, v.size()) cout << v[i] << endl;

  return 0;
}


Measured memory_bytes: 896
n = gets.to_i
a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)

asum = a.inject(:+)
bsum = b.inject(:+)

if bsum > asum
  puts "-1"
else
  diff = a.map.with_index {|v, idx| v - b[idx] }

  lacks = diff.select {|d| d < 0 }
  remains = diff.select {|d| d > 0 }.sort.reverse

  count = lacks.size
  lacksum = lacks.empty? ? 0 : lacks.inject(:+)

  while lacksum < 0
    count += 1
    lacksum += remains.shift
  end

  puts count
end

Measured memory_bytes: 17556
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    if((A-K)>=0){
        P2(A-K, B);
    }else{
        K = max(A+B-K, (ll)0);
        P2(0, K);
    }
    return 0;
}

Measured memory_bytes: 3636
using System;
class Ma {
    
public static void Main(string[] args) {
    
   var n = int.Parse(Console.ReadLine());
   
   int a = 0, h = 0, m = 0 , s = 0;
   h = n / 3600;//h
   a = n % 3600; 
   m = a / 60;//m
   s = a % 60;//
    
 Console.WriteLine("{0}:{1}:{2}", h, m, s); // 文字や数値の出力   
    
}    
    

}


Measured memory_bytes: 19944
from sys import stdin

N, M, C = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]
cnt = 0
for i in range(N):
    if sum([int(x)*B[j] for j, x in enumerate(stdin.readline().rstrip().split())])+C > 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 2940