akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,n;cin>>n;
	if(n==3){cout<<"22 3 5"<<endl;return 0;}
	cout<<"2 3 4 9";n-=4;
	int sta;
	for(sta=6;sta<30000;sta+=6){
		if(n<=1){break;}
		cout<<" "<<sta+2<<" "<<sta+4;n-=2;
	}
	for(sta=12;sta<30000;sta+=12){
		if(n<=1){break;}
		cout<<" "<<sta+3<<" "<<sta+9;n-=2;
	}
	for(sta=6;sta<=30000;sta+=6){
		if(n<=0){break;}
		cout<<" "<<sta;n--;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
	int n = 0;
	cin >> n;
	long long sum = 0;
	for(int i=1; i<n; i++)
	{
		sum += i;
	}
	
	cout << sum << endl;
	return 0;
}

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

int main()
{
  int N;
  while (cin >> N && N != 0) {
    string s;
    cin >> s;
    vector<pair<int,int> > v(N);
    for (int i = 0; i < N; i++) {
      cin >> v[i].first >> v[i].second;
      --v[i].first; --v[i].second;
    }

    for (vector<pair<int,int> >::const_reverse_iterator it = v.rbegin(); it != v.rend(); ++it) {
      const int gap = abs(it->first - it->second);
      swap(s[it->first], s[it->second]);
      s[it->first] = ((s[it->first]-'a'+gap)%26)+'a';
      s[it->second] = ((s[it->second]-'a'+gap)%26)+'a';
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
 
void main() {
	auto data = readln().split();
	auto M = data[1].to!long(), N = data[0].to!long();
	long[] A, B;
	foreach (i; 0 .. M) {
		data = readln().split();
		B ~= data[1].to!long(), A ~= data[0].to!long();
	}
	
	long[] list = N.iota().array;
	long[] size = repeat(1L, N).array;
	
	ulong root(ulong island) {
		auto parent = list[island];
		return parent == island ? island : ( list[island] = root(list[island]) ) ;
	}
	
	
	ulong unite(ulong island1, ulong island2) {
		auto root1 = root(island1), root2 = root(island2);
		if (root1 == root2) return 0;
		else {
			auto result = size[root1] * size[root2];
			list[root1] = root2;
			size[root2] += size[root1];
			return result;
		}
	}
	
	long[] results; results ~= N * (N-1) / 2;
	foreach_reverse(bridge; 1 .. M) {
		results ~= results[$-1] - unite(A[bridge]-1, B[bridge]-1);
	}
	foreach_reverse(num; results) { writeln(num); }
}



Measured memory_bytes: 8828
#include<iostream>
using namespace std;
string s[1000];
int N;
main()
{
	while(cin>>N,N)
	{
		for(int i=0;i<N;i++)cin>>s[i];
		int M=-1;
		for(int i=0;i<N;i++)
		{
			int id=0;
			while(s[i][id]=='.')id++;
			id--;
			if(id>=0)s[i][id]='+';
			if(id>M)M=id;
		}
		for(int k=0;k<=M;k++)
		{
			int pre=-1;
			for(int i=0;i<N;i++)
			{
				if(k<s[i].size()&&s[i][k]=='+')
				{
					if(pre>=0)
					{
						for(int j=pre+1;j<i;j++)s[j][k]='|';
					}
					pre=i;
				}
				else if(k>=s[i].size()||(s[i][k]>='a'&&s[i][k]<='z'))
				{
					pre=-1;
				}
			}
		}
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<s[i].size();j++)
			{
				if(s[i][j]=='.')s[i][j]=' ';
			}
		}
		for(int i=0;i<N;i++)cout<<s[i]<<endl;
	}
}



Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
//b
int main(){
  
  int64_t X; cin >> X;
  int64_t a=100;
  int count=0;
  rep(i, 3760){
    a *= 1.01;
    count++;
    if(a >= X){
      cout << count << endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 3620
n,m = map(int, input().split())
h = list(map(int, input().split()))
r = []
for i in range(m):
    r.append(list(map(int,input().split())))

ln =[]# 展望台iがどことつながっているか
for i in range(n+1):
    ln.append([])

line= [1]*n
for i in r:
    a,b = i[0],i[1]
    ln[a].append(b)
    ln[b].append(a)

for i in  range(1,n+1):
    iH = h[i-1]
    for j in ln[i]:
        if h[j-1] >= iH:
            line[i-1]= 0
print(sum(line))

Measured memory_bytes: 42048
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (3000)
#define MAX_M (100000)
#define pb push_back
const int INF = 1001001001;
struct P
{
	int len, p;
	
	P(int a, int b){
		len = a;
		p = b;
	}	
	
	bool operator < (const P& t) const {
		return len > t.len;
	}
};

int n;
vector<P> v[MAX_N];
int d[MAX_N];
int d2[MAX_N][MAX_N];

void search(int s)
{
	//d[s] = 0;
	
	priority_queue<P> que;
	que.push(P(0, s));
	while (!que.empty()){
		P p = que.top(); que.pop();
		if (d[p.p] <= p.len) continue;
		d[p.p] = p.len;
		for (int i = 0; i < v[p.p].size(); i++){
			int to = v[p.p][i].p;
			int len = p.len + v[p.p][i].len;
			if (d[to] > len){
				que.push(P(len, to));
			}
		}
	}
}

int main()
{
	int m, k;
	scanf("%d %d %d", &n, &m, &k);
	
	for (int i = 0; i < m; i++){
		int a, b, l;
		scanf("%d %d %d", &a, &b, &l);
		a--; b--; l *= 2;
		
		v[a].pb(P(l, b));
		v[b].pb(P(l, a));
	}
	
	vector<int> s;
	for (int i = 0; i < k; i++){
		int a;
		scanf("%d", &a);
		a--;
		s.pb(a);
	}
	
	fill(d, d + n, INF);
	int maxi = 0;
	for (int i = 0; i < s.size(); i++){
		search(s[i]);
	}
	//memset(d2, 0, sizeof(d2));
	for (int j = 0; j < n; j++){
		for (int k = 0; k < v[j].size(); k++){
			if (!d2[j][v[j][k].p]){
				d2[j][v[j][k].p] = (d[j] + d[v[j][k].p] + v[j][k].len) / 2;
			}
			else {
				d2[j][v[j][k].p] = min(d2[j][v[j][k].p], (d[j] + d[v[j][k].p] + v[j][k].len) / 2);
			}
		}
	}
	
	for (int j = 0; j < n; j++){
		maxi = max(maxi, d[j]);
		//printf("%d ", d[j]);
	}
	//puts("");
	for (int j = 0; j < n; j++){
		for (int k = 0; k < n; k++){
			maxi = max(maxi, d2[j][k]);
			//printf("%d ", d2[j][k]);
		}
		//puts("");
	}
	
	printf("%d\n", (maxi + 1) / 2);
	
	return 0;
}

Measured memory_bytes: 39292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    int cur = 0;
    while (cur < S.size()) {
        if (cur + 1 < S.size() && S[cur] == 'h' && S[cur + 1] == 'i') {
            cur += 2;
        } else {
            break;
        }
    }
    if (cur < S.size()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split(" "))
A = [int(input()) for _ in range(M)]

l = [0]*(N+10)
l[0] = 1
for a in A:
    l[a] = -1

for i in range(N):
    if l[i] == -1:
        continue
    if l[i+1] != -1:
        l[i+1] = (l[i+1]+l[i])%(10**9+7)
    if l[i+2] != -1:
        l[i+2] = (l[i+2]+l[i])%(10**9+7)

print(l[N])

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

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif






// v[1]がルート
template <typename T>
struct SegmentTree {
	vector<T> v;
	int ofs;
	using F = function<T(T&, T&)>;
	const F comb;
	const T unit;
	SegmentTree( int n, F comb, const T& unit ) : comb(comb), unit(unit) {
		for ( ofs = 1; ofs < n; ofs *= 2 )
			;
		v = vector<T>(ofs*2,unit);
	}
	
	
	void update( int i, const T& x ){
		i += ofs;
		v[i] = x;
		i /= 2;
		
		while ( i ){
			v[i] = comb( v[i*2], v[i*2+1] );
			i /= 2;
		}
	}
	
	//  begin .. end-1 の区間の計算結果を得る
	T range( int begin, int end ){
		return range2( begin, end, 1, 0, ofs );
	}
	
	// v[node] は 区間 l .. r-1 の計算結果を持っている
	T range2( int begin, int end, int node, int l, int r ){
		if ( end <= l || r <= begin )
			return unit;
		if ( begin <= l && r <= end )
			return v[node];
		T lval = range2( begin, end, node*2,   l,       (l+r)/2 );
		T rval = range2( begin, end, node*2+1, (l+r)/2, r       );
		return comb(lval,rval);
	}
};


int comb(int a, int b){return a+b;}

const ll CMAX = 500000;

struct query {
	ll l;
	ll r;
	ll i;
	ll result;
};


int main(){
	ll n, q;
	cin >> n >> q;
	
	vector<ll> c(n);
	rep(i,n){
		cin >> c[i];
		c[i]--;
	}
	
	// query
	vector<query> qu(q);
	rep(i,q){
		cin >> qu[i].l >> qu[i].r;
		qu[i].i = i;
		
		// 0-index
		qu[i].l--;
		qu[i].r--;
		
		// [)
		qu[i].r++;
	}
	sort(qu.begin(),qu.end(), [&](const query &l, const query &r){return l.r<r.r;});
	
	
	
	// https://hama-du-competitive.hatenablog.com/entry/2016/10/01/001418
	SegmentTree<int> s(n,comb,0);
	
	vector<ll> lastAppeared(CMAX);
	rep(i,CMAX)
		lastAppeared[i] = -1;
	
	int r = 0;
	for ( auto &qy : qu ){
		while ( r < qy.r ){
			ll color = c[r];
			if ( lastAppeared[color] != -1 ){
				s.update(lastAppeared[color],0);
			}
			lastAppeared[color] = r;
			s.update(lastAppeared[color],1);
			r++;
		}
		qy.result = s.range(qy.l, qy.r);
	}
	
	sort(qu.begin(),qu.end(), [&](const query &l, const query &r){return l.i<r.i;});
	
	for ( auto &qy : qu ){
		cout << qy.result << endl;
	}
	
	return 0;
}




Measured memory_bytes: 31244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a= sc.nextInt(), b = sc.nextInt(), x = sc.nextInt();
		System.out.println((x >= a && x <= a + b) ? "YES" : "NO");
	}

}

Measured memory_bytes: 26928
def gcd(a, b):
    if (a % b == 0):
        return b
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(ans, t)

print (ans)

Measured memory_bytes: 3060
class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1] * n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x,y = y,x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self,x):
        return -self.parents[self.find(x)]

    def same(self,x,y):
        return self.find(x) == self.find(y)

    def members(self,x):
        root = self.find(x)
        return [i for i in range(self.n)if self.find(i) == root]

    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r:self.members(r) for r in self.roots()}

N,M = map(int,input().rstrip().split(" "))
uft = UnionFind(N)
ans = 0
for i in range(M):
    a,b = map(int,input().rstrip().split(" "))
    uft.union(a-1,b-1)
for i in range(N):
    ans = max(ans,uft.size(i))
print(ans)

Measured memory_bytes: 80000
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >>c;
    cout << min((a+b),min((b+c),(a+c)));

    return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

l,r = LI()
m = 2019

end = min(l+2019,r)

ar = []
for i in range(l,end):
    for j in range(i+1,end+1):
        ar.append((i*j)%m)
print(min(ar))

# ans = (l * r) % m
# print(ans)

# N = I()
#A,B = LI()
#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

# if ans:
#     print('Yes')
# else:
#     print('No')

Measured memory_bytes: 99452
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll x, y, n1, n2, n3;
  cin >> x >> y >> n1 >> n2 >> n3;
  vll a(n1), b(n2), c(n3);
  for(auto &it : a) cin >> it;
  for(auto &it: b) cin >> it;
  for(auto &it: c) cin >> it;
  sort(all(a));
  sort(all(b));
  sort(all(c), greater<ll>());
  ll curra = n1 - x , currb = n2 - y, currc = 0;
  for(ll i = 0; i < n3; i++) {
  	ll aa = 0, bb = 0;
  	if(curra < n1)aa = c[currc] - a[curra];
  	if(currb < n2)bb = c[currc] - b[currb];
  	if(aa >= bb and aa > 0) {
  		a[curra] = c[currc];
  		curra++;
  		currc++;
  	} else if(bb > aa and bb > 0) {
  		b[currb] = c[currc];
  		currb++;
  		currc++;
  	}
  }
  ll ans = 0;
  for(ll i = n1 - x; i < n1; i++){ ans+= a[i]; }
  for(ll i = n2 - y; i < n2	; i++){ ans+= b[i]; }
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000000000;
double pi=3.141592653589793;
//setprecision(20) <<

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

class Point{
public:
	long long x;
	long long y;
	long long dis;
	Point(long long _x,long long _y,long long _dis){
		x=_x;
		y=_y;
		dis=_dis;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	string s_=s;
	int ans=2*n;
	for(int i=0;i<=n;i++){
		string now=s+t;
		if(i!=n)s.pop_back();
		//cout<<now.substr(0,n)<<endl;
		if(now.substr(n-i,n)==t&&now.substr(0,n)==s_){
			//cout<<now<<endl;
			ans=min(ans,(int)now.length());
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


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

    for (int i = 0; i < N+1; i++) {
        for (int j = 0; j < N+1; j++) {
            if(4*i+7*j==N){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll x,y,z;
	cin>>x>>y>>z;

	cout<<z<<" "<<x<<" "<<y<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>  
#include <cstdlib>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i,N) {
        int a;
        cin >> a;
        ++mp[a-1];
        ++mp[a];
        ++mp[a+1];
    }
    int ans = -1000;
    for(auto& p:mp) {
        if (p.second > ans) {
            ans = p.second;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int dp[1 << 10][331];
int n, s;

int dfs (int t, int sum, int k) {
    if (t == 0) return sum == s ? 1 : 0;
    if (s < sum) return 0;
    if (dp[t][s-sum] >= 0) return dp[t][s-sum];
    int res = 0;
    for (int i = 0; i < 10; i++) {
        if ((t & (1 << i)) > 0) {
            res += dfs(t-(1<<i), sum + i * k, k-1);
        }
    }

    return dp[t][s-sum] = res;
}

int main ()
{
    for (int i = 0; i < (1 << 10); i++) {
        for  (int j = 0; j <= 330; j++) {
            dp[i][j] = -1;
        }
    }
    while (cin >> n >> s) {
        if (s > 330) {
            cout << 0 << endl;
            continue;
        }
        int res = 0;
        for (int i = 1; i < (1 << 10); i++) {
            int t = i, count = 0;
            while (t) {
                count += t % 2; t /= 2;
            }
            if (n == count) res += dfs(i,0,count);
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 2480
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <cassert>
#include <iostream>
using namespace std;
typedef long long ll;

#define REP(i,n) for (int i=0;i<(int)(n);++i)
#define FOR(i,k,n) for (int i=k;i<(int)(n);++i)
#define FOREQ(i,k,n) for (int i=k;i<=(int)(n);++i)

#define MEMSET(v,h) memset((v),(h),sizeof(v))

struct Node {
    int index;
    string str;
    Node(int index, string str) : index(index), str(str) {;}
    bool operator<(const Node &rhs) const {
        if (str.size() != rhs.str.size()) { return str.size() > rhs.str.size(); }
        return str > rhs.str;
    }
};

int n, a, s, g;
vector<pair<int, string> > graph[50];
char str[100];
bool visit[500][50];
string strs[500][50];

int main() {
    while (scanf("%d %d %d %d", &n, &a, &s, &g), n) {
        REP(i, 500) {
            REP(j, n) {
                strs[i][j] = "}";
            }
        }
        REP(i, n) { graph[i].clear(); }
        REP(i, a) {
            int x, y;
            scanf("%d %d %s", &x, &y, str);
            graph[x].push_back(make_pair(y, str));
        }
        MEMSET(visit, false);
        string ans = "}";
        priority_queue<Node> que;
        que.push(Node(s, ""));
        while (!que.empty()) {
            Node node = que.top();
            que.pop();
            //cout << node.index << " " << node.str << endl;
            if (visit[node.str.size()][node.index]) { continue; }
            visit[node.str.size()][node.index] = true;
            if (node.index == g) {
                ans = min(ans, node.str);
            }
            REP(i, graph[node.index].size()) {
                int to = graph[node.index][i].first;
                string nstr = node.str + graph[node.index][i].second;
                if (nstr.size() > 12 * n) { continue; }
                if (visit[nstr.size()][to]) { continue; }
                if (strs[nstr.size()][to] < nstr) { continue; }
                strs[nstr.size()][to] = nstr;
                que.push(Node(to, nstr));
            }
        }
        if (ans != "}" && ans.size() <= 6 * n) {
            cout << ans << endl;
        } else {
          puts("NO");
        }
    }
}

Measured memory_bytes: 10000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    A, B = list(map(int, input().split()))

    if A < 6:
        print("0")
    elif A < 13:
        print(str(int(B / 2)))
    else:
        print(B)


if __name__ == '__main__':
    main()

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

int main() {
  string a,b;
  cin >> a >> b;
  if(a.at(0)==b.at(2) && a.at(1)==b.at(1) && a.at(2)==b.at(0)){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
	int n, i, b, x, count, answer;
        double s;
	double a[200];
	scanf("%d", &n);
	for (i = 0; i<n; i++){
            scanf("%lf", &a[i]);  //ここまで配列の準備
            b =  b + a[i];
        }
        b = b*1000;
        s = b;
 	x = b / n; //平均の１００倍
        
        for(i = 0; i<n; i++){
            count = (a[i]*1000)-x;
            if (count<0){
                  count = -1 * count;
            }
            if (count<s){
                    answer = i;
                    s = count;
            }
        }
 
	printf("%d\n", answer);
 
	return 0;
}

Measured memory_bytes: 128
read = input
n = int(read())
s = read()
SW = [0 for i in range(n)]
SB = [0 for i in range(n)]
for i,c in enumerate(s):
    if i == 0:
        SW[i] = 1 if c == '.' else 0
        SB[i] = 1 if c == '#' else 0
    else :
        SW[i] = SW[i-1] + 1 if c == '.' else SW[i-1]
        SB[i] = SB[i-1] + 1 if c == '#' else SB[i-1]
cost = n
for i in range(n):
    pass
#     print(i, SW[i], SB[i])
for i in range(n + 1):
    startW = 0
    endW = i # left W is [0,i)
    startB = i 
    endB = n # right B is [i, n)
#     print(i)
    if i == 0: # all B 
        cost = min(cost, SW[n-1])
    elif i == n: # all W
        cost = min(cost, SB[n-1])
    else:
        cost = min(cost, 
                   SB[i-1] + (SW[n-1] - SW[i-1])
                  )
#     print(i, cost)
print(cost)
    

Measured memory_bytes: 13032
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b, d;

int f(int x) {
	if (x==-1) return 0;
	return x/d+1;
}

signed main() {
	cin >> a >> b >> d;
	cout << f(b) - f(a-1) << endl;
}


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

int ans(int n,string s,string t){
    if (n==1 & s!=t){
        return(2);
    }
    if(s==t){
        return(n);
    }
    int tosub = 0;
    for(int i=n;i>0;i--){
        if(s.substr(n-i,i) == t.substr(0,i)){
            tosub = i;
        }
    }
    return(2*n - tosub);
}

int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    cout<<ans(n,s,t);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
int dp[45];
void fibonacci(int);
int main(){
  int result;
  cin >> n;
  dp[0]=1;
  dp[1]=1;
  if(n!=0&&n!=1)  fibonacci(2);
  cout << dp[n] << endl; 
  return 0;
}
void fibonacci(int i){
  dp[i]=dp[i-1]+dp[i-2];
  if(n==i) return ;
  fibonacci(i+1);
}

Measured memory_bytes: 1160
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var result = n % 2 == 0;
            if (result) result = s.Substring(0, n / 2) == s.Substring(n / 2);
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] H = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            int cnt = 0;
            long max = 0;
            for (int j = 0; j < N; j++)
            { 
                if (max <= H[j])
                {
                    max = H[j];
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim], B[lim];

int main(){
    rep(i,1,3) {
        A[i] = sc();
    }
    B[1] = 1;
    B[3] = -1;
    lld k = sc();
    lld val = 0;
    rep(i,1,3) {
        if(k <= A[i]) {
            val += B[i] * k;
            k = 0;
        }
        else {
            val += B[i] * A[i];
            k -= A[i];
        }
    }
    prL(val);
    return 0;
}


Measured memory_bytes: 3832
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *a = map(int, read().split())
A = np.array(a)

counter = np.bincount(A)
B = counter.copy()
B[1:] += counter[:-1]
B[:-1] += counter[1:]

print(B.max())


Measured memory_bytes: 21408
#include "bits/stdc++.h"
#define puba push_back
#define ff first
#define ss second
#define bend(_x) begin(_x), end(_x)
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }




int main() {
    //freopen(TASK_NAME ".in", "r", stdin);
    //freopen(TASK_NAME ".out", "w", stdout);
    cerr << fixed << setprecision(15);
    cout << fixed << setprecision(15);
    
    string s;
    cin >> s;
    if (szof(s) >= 4 && s.substr(0, 4) == "YAKI") {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    
    
    #ifdef LOCAL
        cerr << "time: " << clock() << endl;
    #endif
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int coin,total;

    scanf("%d\n%d",&total,&coin);

    int x = total/500;

    int y = x * 500;

    if(y == total){

        printf("Yes\n");
    }
    else{

       int z = total-y;

        if(coin >= z){

            printf("Yes\n");

        }
        else{

            printf("No\n");
        }
        return 0;
    }
}



Measured memory_bytes: 1644
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	p := make([]int, m)
	s := make([]string, m)

	for i := 0; i < m; i++ {
		fmt.Scanf("%d %s", &p[i], &s[i])
	}

	a := map[int][]string{}
	for i := 0; i < m; i++ {
		strings, ok := a[p[i]]
		if !ok {
			strings = []string{}
		}

		a[p[i]] = append(strings, s[i])
	}

	totalAc := 0
	totalWa := 0
	for _, strings := range a {
		for i, ans := range strings {
			if ans == "AC" {
				totalWa += i
				totalAc += 1
				break
			}
		}
	}

	fmt.Printf("%d %d", totalAc, totalWa)
}


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

using namespace std;

int main()
{
    char s[30];
    scanf("%s",s);
    for(int i = 0; i < 19; i ++)
    {
        if(s[i] == ',')printf(" ");
        else printf("%c",s[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
//written by: rishav2416
#include <bits/stdc++.h>
#define ll long  long
#define lli long long int
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define arrinit(arr,n,k) for(ll c1=0;c1<n;c1++) arr[i]=k;
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define revrep(i,a,n) for(ll i=a; i>=n ; i--)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define INF 1e18a



ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}


std::string str="All Good Till Here";

/////////////////////////////////////////////////////////////////////////////////

int32_t main()
{
    fastio
	ll tt,i,j,x;
	//cin>>tt;
  tt=1;
	while(tt--)
	{
    string str;
    cin>>str;
    if(str=="ABC")cout<<"ARC\n";
    else cout<<"ABC\n";
	}
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int main(){
  int x,y;cin>>x>>y;
  if(4*x<y || (y&1)==1 || y<2*x)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}


Measured memory_bytes: 3604
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;

int modpow(int x, int n, int m) {
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> n;
  int ans = modpow(10,n,mod) - 2*modpow(9,n,mod) + modpow(8,n,mod);
  ans = (ans + 1LL*10*mod)%mod;
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 3540
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc_unlocked(i + '0', stdout);
}
 
int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    puti(arr[m]);
    fputc_unlocked('\n', stdout);
    return 0;
}

Measured memory_bytes: 1620
import sys
import math
import fractions
import bisect
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())
uf = UnionFind(N)
dame = [set() for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    uf.union(A, B)
    dame[A].add(B)
    dame[B].add(A)
for _ in range(K):
    C, D = map(int, input().split())
    C -= 1
    D -= 1
    if uf.same(C, D):
        dame[C].add(D)
        dame[D].add(C)


ans = []
for n in range(N):
    ans.append(uf.size(n) - len(dame[n]) - 1)

ans = map(str, ans)
print(" ".join(ans))


Measured memory_bytes: 70772
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);

    string[] inputa = Console.ReadLine().Split(' ');
		long c = long.Parse(inputa[0]);
		long d = long.Parse(inputa[1]);
		
		Console.WriteLine((a-c)*(b-d));
	}
}

Measured memory_bytes: 13140
N = int(input())
red_list = [list(map(int, input().split())) for i in range(N)]
blue_list = [list(map(int, input().split())) for i in range(N)]
ans = 0

def x_axis_evaluate(li):
    return li[0]

def y_axis_evaluate(li):
    return li[1]

red_list.sort(key=y_axis_evaluate,reverse=True)
blue_list.sort(key=x_axis_evaluate)

for b_item in blue_list:
    for r_item in red_list:
        if r_item[0] < b_item[0] and r_item[1] < b_item[1]:
            ans += 1
            red_list.remove(r_item)
            break

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define nav(...) "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
#define oo INT_MAX/2
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
	~debug() {cout<<endl;}
	template<class T> debug& operator<<(T x) {cout<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<< (pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x) {
		*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(all(x));}
};


bool solve(void) {

	int n;
	scanf("%d", &n);
	vector<int> A(n), B(n);
	for(int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	for(int i = 0; i < n; i++)
		scanf("%d", &B[i]);
	vector<int> p(n);
	for(int i = 0; i < n; i++)
		p[i] = i+1;
	int perm = 1, a = 0, b = 0;
	do {
		if(p == A)
			a = perm;
		if(p == B)
			b = perm;
	} while(perm++, next_permutation(all(p)));
	printf("%d\n", abs(a-b));
	return true;
}

int main(int argc, char* argv[]) {

	solve();

	return 0;
}


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

void main() {
	auto b = readln.split[0];
    if (b == "A") "T".writeln;
    if (b == "T") "A".writeln;
    if (b == "G") "C".writeln;
    if (b == "C") "G".writeln;
}


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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    int64_t N;
    cin >> N;
    vector<int64_t> num(60);
    for(int i=0; i<N; i++) {
        int64_t A;
        cin >> A;
        for(int j=0; j<60; j++) {
            if(A & (1LL << j)) {
                ++num.at(j);
            }
        }
    }

    int64_t ans = 0;
    for(int j=0; j<60; j++) {
        ans = (((((1LL << j) % MOD * num.at(j)) % MOD) * (N-num.at(j)) % MOD) + ans) % MOD;
    }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

int n;
char s[200005];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

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

  int l = 0, r = n - 1;
  int ans = 0;
  while (l < r) {
    while (l < r && s[l] == 'R') {
      l += 1;
    }
    while (l < r && s[r] == 'W') {
      r -= 1;
    }
    if (l < r) {
      ans += 1;
      l += 1;
      r -= 1;
    }
  }
  printf("%d\n", ans);
#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 4012
#include<stdio.h>

int main()
{
    int i,n,count=1,max;
    scanf("%d",&n);
    int ara[n];
    for(i=0; i<n; i++)
        scanf("%d",&ara[i]);
    max=ara[0];
    for(i=1; i<n; i++) {
        if(ara[i]<=max) {
            max=ara[i];
            count++;
        }
    }
    printf("%d",count);
}



Measured memory_bytes: 2508
data = [int(s) for s in input().split()]

N = data[0]
M = data[1]
X = data[2]
Y = data[3]

a = [int(i) for i in input().split()]
b = [int(j) for j in input().split()]

am = max(a)

bm = min(b)

x = am

i = 0
f = 0

if am >= bm:
    print("War")
    f = 1

else:
    while x < bm:
        
        if x in range(X,Y):
            
            print("No War")
            f = 1
            break
        x += 1


if f == 0:
    print("War")



Measured memory_bytes: 3064
N = int(input())
S = [[c for c in input()] for i in range(N)]
dic={}
for i in range(len(S)):
    S[i].sort()
    S[i] = str(S[i])
    if S[i] in dic:
        dic[S[i]] +=1
    else:
        dic[S[i]] = 1

comb=0
for i in dic.keys():
    if dic[i] !=0:
        comb = comb + dic[i]*(dic[i]-1)/2
print(int(comb))



Measured memory_bytes: 29072
//
//  main.cpp
//  20190808lesson
//
//  Created by Priscilla Leang on 8/8/19.
//  Copyright © 2019 Priscilla Leang. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int x, y, n, f;
    bool b1 = false;
//    cin>> x >> y;
//    if (x<=8 && y <= 8){
//        b1 = true;
//    }
//    if (b1 == true){
//        cout << "Yay!";
//    }
//    if (b1 == false){
//        cout << ":(";
//    }
    
    n = 0;
    cin>> x >> y >> n;
    int a1[x][y];
    int a2[n][3];
    for (int i = 0; i<x; i++){
        for (int j = 0;j<y; j++){
            a1[i][j] = 0;
            
        }
    }
    
    
    for (int i = 0; i<n; i++){
        for (int j = 0; j<3; j++){
            cin>> a2[i][j];
        
        }
        
    }
    
    f = 0;
    for (int i = 0; i< n; i++){
        f = a2[i][2];
        
        if (f == 1){
            
            for (int j = 0; j< a2[i][0]; j++){
                for (int k = 0; k<y; k++){
                    a1[j][k]++;
                }
            }
        }
        if (f == 2){
            
            for (int j = a2[i][0]; j< x; j++){
                for (int k = 0; k<y; k++){
                    a1[j][k]++;
                }
            }
        }
        if (f == 3){
          
            for (int j = 0; j<x; j++){
                for (int k = 0; k<a2[i][1]; k++){
                    a1[j][k]++;
                }
            }
        }
        if (f == 4){
       
            for (int j = 0; j<x; j++){
                for (int k = a2[i][1]; k<y; k++){
                    a1[j][k]++;
                }
            }
        }
    }
    f = 0;
    for (int i = 0; i<x; i++){
        for (int j = 0; j<y; j++){

            if (a1[i][j] == 0){
                f++;
            }
        }
    }
    
    cout << f;
    

    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = [int(i) for i in input().split()]

dp = [9999999999999999999999]*N

dp[0] = 0
for i in range(1,N):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i > 1:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

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


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

    if (X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}




Measured memory_bytes: 3632
<?php
list($a, $b, $x) = ints();
$ans = intdiv($b, $x) - intdiv($a, $x) + 1;
if ($a % $x) --$ans;
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604