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

typedef long long ll;

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

    int a,b;
    cin >> a >> b;
    for(int i=1;i<100000;i++){
        int uku = (int)(i*0.08);
        int ushi = (int)(i*0.1);
        if(uku==a && ushi==b){
            cout << i << endl;
            return 0;
        } 
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N 10000
int isPrime();
int main(){
  int i,n,x[N],count = 0,y;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
for(i=0;i<n;i++){
  y = x[i];
  if(isPrime(y) == 1) count++;
}
printf("%d\n",count);
return 0;
    }

int isPrime(int x){
  int i,re=1;
  if(x == 2)  re=1;
  else if(x<2 || x%2 == 0) re =  0;

else{
for(i=3;i<=sqrt(x);i+=2){
    if(x%i == 0) re=0;
  }
}
return re;
}


Measured memory_bytes: 2056
m, n = [ int(v) for v in input().split() ]
s = input()
t = input()


def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcm(a,b):
	return a * b // gcd(a,b)

g = gcd(m,n)

ds = [ v  for i, v in enumerate(s) if i % (m/g) == 0 ]
dt = [ v  for i, v in enumerate(t) if i % (n/g) == 0 ]
print( lcm(m,n) if ds == dt else -1 )

Measured memory_bytes: 41712
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	string s;
	cin >> s;
	s.erase(unique(s.begin(),s.end()),s.end());
	cout << SIZE(s)-1 << endl;
	return 0;
}


Measured memory_bytes: 512
from itertools import permutations
import numpy as np

lis = [int(input()) for i in range(5)]
total = np.inf
now = 0
for a,b,c,d,e in permutations(lis,5):
    now = ((a-1)//10+1)*10+((b-1)//10+1)*10+((c-1)//10+1)*10+((d-1)//10+1)*10+e
    total = min(total,now)
    #print(now)
    #print(total)

print(total)

Measured memory_bytes: 26760
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		long x = Long.parseLong(scan.next());

		long ans = x/11;
		x-=ans*11;
		ans*=2;
		if (0 < x && x <= 6)ans+=1;
		else if (6 < x  && x<11)ans+=2;
		System.out.print(ans);
}
}
//end


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

int n, lty[200020];
double ans;

int main() {
	scanf("%d", &n);
	n *= 2;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &lty[i]);
	}
	std::sort(lty + 1, lty + n + 1);
	for (int i = 1; i <= n; i++) {
		ans += lty[i] / (n - 1 * 1.0) * (i - 1);
	}
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
const int inf   = 510101010;
const int mod=1e9+7;
const ll longinf=1LL<<60;

int main(){
  int n;cin>>n;
  pint p[n];
  rep(i,n){
    ll a,b;cin>>a>>b;
    p[i]=pint(a+b,b);
    }
  sort(p,p+n);
  ll dp[5010];
  rep(i,n+1)
    dp[i]=longinf;
  dp[0]=0;
  rep(i,n){
    for(int j=n;j>=0;j--){
      if(dp[j]<=p[i].first-p[i].second)
        dp[j+1]=min(dp[j]+p[i].second,dp[j+1]);
      }
    }
  rep(i,n){
    if(dp[n-i]!=longinf){
      cout<<n-i<<endl;
      break;
      }
    }
  return 0;
  }


Measured memory_bytes: 384
if __FILE__ == $0
  n = gets.to_i
  n.times do 
    nums = gets.rstrip.split('').map{|i| i.to_i}
    max_num = nums.sort.reverse.join.to_i
    min_num = nums.sort.join.to_i
    puts max_num - min_num
  end
end

Measured memory_bytes: 6104
/*
	Author :- Vipin Kumar
*/
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>

#define int long long
#define endl "\n"
#define Point pair<int,int>
#define x first
#define y second

const int mod=(int)1e9+7;
const int inf=(int)1e18;
const int mx=1e5+5;
const int mx_seive=1e6+5;

using namespace std;

// Helper Functions Starts

vector<int> primeFactors(int n) 
{ 
    vector<int> ret;
	int flag = 0;
	while(n%2 == 0){
		n = n / 2;
		if(flag == 0){
			ret.push_back(2);
			flag = 1;
		}
	} 
    for (int i = 3; i <= sqrt(n); i = i+2) 
    { 
        int flag = 0;
        while (n%i == 0) 
        { 
			if(flag == 0){
				ret.push_back(i);
				flag = 1;
			} 
            n = n/i; 
        } 
    } 
    if (n > 2)
	{
        ret.push_back(n);
    }
    return ret;
}

bool prime[mx_seive];
void SieveOfEratosthenes() 
{
	int n = mx_seive - 1;
	memset(prime, true, sizeof(prime));
	prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
        {
            for (int i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}

int power[mx_seive];
void powerMod(int n){
	power[0] = 1;
	for(int i=1;i<mx_seive;i++){
		power[i] = (power[i-1] * n) % mod;
	}
}

void printArr(int arr[],int n){
	for(int i=0;i<n;i++){
		cout<<arr[i]<<" ";
	}
	cout<<endl;
}

void printVec(vector<int> arr){
	for(int i=0;i<arr.size();i++){
		cout<<arr[i]<<" ";
	}
	cout<<endl;
}

// Helper Functions ends;

// Global Variables

map<int,int> mp;

// Global Variable Ends

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	#endif
	
//	SieveOfEratosthenes();
//	powerMod(5);

	int a,b;
	cin>>a>>b;
	cout<<a+(b/2);
	
	return 0;
}

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

int main() {
    array<bool, 2000000> is_prime;
    vector<int> prime;
    fill(is_prime.begin(), is_prime.end(), true);
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<is_prime.size(); ++i) {
        if(is_prime[i]) {
            prime.push_back(i);
            for(int j=i+i; j<is_prime.size(); j+=i) {
                is_prime[j] = false;
            }
        }
    }

    int n;
    while(cin >> n, n) {
        if(is_prime[n]) {
            cout << 0 << endl;
            continue;
        }
        for(int i=0; i<prime.size()-1; ++i) {
            if(prime[i] < n && n < prime[i+1]) {
                cout << prime[i+1] - prime[i] << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll A, P;
	cin >> A >> P;

	ll ans = ans = (A * 3 + P) / 2;


	cout << ans << endl;

	//system("pause");
}


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

int main()
{
  int N, K;
  bool n[10] = {};
  cin >> N >> K;
  for(int i = 0; i < K; i++){
    int y;
    cin >> y;
    n[y] = true;
  }
  int x = N;
  while(1){
    stringstream ss;
    ss << x;
    string str = ss.str();
    bool flag = false;
    for(int i = 0; i < (int)str.size(); i++)
      if(n[str[i]-'0']){
        flag = true;
        break;
      }
    if(!flag) break;
    x++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n,k, = map(int,input().split())
list = []
sum = 0
for i in range(n):
    a,b = map(int,input().split())
    list.append([a,b])

list.sort()
for i in range(n):
    sum = sum + list[i][1]
    if sum >= k:
        break
print(list[i][0])

Measured memory_bytes: 20104
#include <iostream>
#include <string>
#define L '('
#define R ')'

int main(void) {
    using std::cin;
    using std::string;
    int n;
    cin >> n;
    string s;
    cin >> s;

    int nest   = 0;
    int need_l = 0;
    for (auto &se : s) {
        if (nest == 0 && se == R) {
            need_l++;
            nest++;
        }
        if (se == L)
            nest++;
        else
            nest--;
    }
    int need_r = nest;

    for (int i = 0; i < need_l; ++i) std::cout << L;
    std::cout << s;
    for (int i = 0; i < need_r; ++i) std::cout << R;
    std::cout << '\n';

    return 0;
}


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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 1005

#define PI 3.14159265358979323846264338327950
#define ll  long long int
int n , x;
int p[MAXX];
bool used[MAXX];

int main()
{
    FAST;
    cin >> x >> n;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        used[p[i] + 100] = true;
    }
    int ans = x;
    ans ++;
    ans --;
    ans ++;
    ans --;
    
    for(int i = 0; i < 101; i++){
        if(!used[x - i + 100]){
            ans = x - i;
            break;
        }
        if(!used[x + i + 100]){
            ans = x + i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nk = br.readLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);

		System.out.println(n % k == 0 ? 0 : 1);

	}

}


Measured memory_bytes: 21204
#include <cstdio>
#define ll long long
ll n,x;
inline ll work(ll l1,ll l2){
	if (!l2) return -l1;
	return work(l2,l1%l2)+2*(l1/l2)*l2;
}
int main() {
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",work(x,n-x)+n);
	return 0;
}

Measured memory_bytes: 128
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush

import collections
# T = int(stdin.readline())
# for i in range(T):
    #N=int(stdin.readline())
N,M=list(map(int,stdin.readline().split()))
hill=list(map(int,stdin.readline().split()))

dc=collections.defaultdict(list)
#vis=set()
for m in range(M):
    A,B=list(map(int,stdin.readline().split()))
    dc[A].append(B)
    dc[B].append(A)

ans=0
for k,ls in dc.items():

    f=0
    z=0
    for h in ls:

        if hill[k-1]<=hill[h-1]:
            f=1
            break

    if not f:
      #  print(k)
        ans+=1  
#print(ans)
ans+=(N-len(dc.keys()))
print(ans)            

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

using namespace std;
typedef long long ll;
const int N = 1e5+5;
const ll oo = 1e18;
const ll mod = 1e9+7;
const int INF = 1 << 30;


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
    
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    
    return 0;
}


Measured memory_bytes: 256
def check(s):
  if s % 2 == 0:
    return s//2
  else:
    return 3*s+1

s = int(input())
count = 0
a = [s]
n = s
while count < 1:
  n = check(n)
  length = len(a)
  a.append(n)
  if length+1 != len(set(a)):
    print(len(a))
    break

Measured memory_bytes: 3060
l = [int(i) for i in input().split()]

a = 0
b = 0
for i in range(len(l)):
  if (l[i] == 5):
    a = a + 1
  elif (l[i]) == 7:
    b = b + 1
  else:
    pass

if (a==2 and b ==1):
  print("YES")
else:
  print("NO")

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int H, W;
    int A[505][505];
    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> A[i][j];
        }
    }
    vector<pair<Pi, Pi>> output;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j < W; j++) {
            if (A[i][j] & 1) {
                output.emplace_back(Pi(i, j), Pi(i, j + 1));
                A[i][j + 1]++;
            }
        }
    }
    for (int i = 1; i < H; i++) {
        if (A[i][W] & 1) {
            output.emplace_back(Pi(i, W), Pi(i + 1, W));
            A[i + 1][W]++;
        }
    } 
    cout << output.size() << endl;
    for (auto x : output) {
        cout << x.first.first << " " << x.first.second << " " << x.second.first << " " << x.second.second << endl;
    }

    return (0);
}

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

int main()
{
	string str;
	while(cin >> str)
	{
		for(int i = 0; i < str.size(); i++)
		{
			if(str[i] != '@')
			{
				cout << str[i];
				continue;
			}
			for (int j = 0; j < str[i + 1] - '0'; j++)
			{
				cout << str[i + 2]; 
			}
			i += 2;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3088
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    s = set(s)


    if 'a' in s and 'b' in s and 'c' in s:
        print('Yes')
    else:
        print('No')
    

solve()

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>

using namespace std;

int main(){

    int n;
    int ans = 0, cnt = 0;

    cin >> n;

    int a[n];

    for(int i = 0; i < n; i ++){
        cin >> a[i];
        if(i == 0){
            ans = a[0];
        }
        cnt = 0;
        while(a[i] % 2 == 0){
            a[i] /= 2;
            cnt++;
        }
        ans = min(ans,cnt);
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long f[100+1];
int main(){
    int n;
    cin>>n;
    f[1]=2;
    f[2]=1;
    for(int i=3;i<=n+1;i++){
        f[i]=f[i-1]+f[i-2];
        //cout<<f[i]<<" ";
    }
    cout<<f[n+1];
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
 
int main(void) {
    int i,alpha[26]={0};
    char string[1201];
    while (fgets(string,sizeof(string),stdin)!=NULL) {
        for (i=0; i<strlen(string); i++) {
            if (isalpha(string[i])) {
                if (islower(string[i])) {
                    alpha[string[i]-'a']++;
                } else {
                    alpha[string[i]-'A']++;
                }
            }
        }
    }
    for (i=0; i<26; i++) printf("%c : %d\n",i+'a',alpha[i]);
    return 0;
}



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

using namespace std;

int N, X, Y;


int main()
{

	cin >> N;
	cin >> X;
	cin >> Y;

	auto d = vector<vector<int>>(N+1,vector<int>(N+1));
	auto ans = vector<int>(N+1);
	for (int i = 1; i <= N; i++) {
		for (int j = i+1; j <=N; j++) {
			d[i][j] = j - i;
			if (j <= X) { continue; }
			if (i >= Y) { continue; }

			int sc = abs(X - i) + abs(Y - j) + 1;
			d[i][j] = min(d[i][j],sc);


		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			ans[d[i][j]]++;
		}
	}

	for (int k = 1; k < N; k++) {
		cout << ans[k] << endl;
	}


	
	return 0;
}

Measured memory_bytes: 16000
N = int(input())

bucket_sort = [0] * 101

for i in range(N):
  d = int(input())

  if bucket_sort[d] != 1:
    bucket_sort[d] = 1

ans = 0
#import pdb; pdb.set_trace()

for k in bucket_sort:
  ans +=  k

print(ans)

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

int main(){
  ll a,b,q;
  cin >>a >>b >>q;
  vector<ll>s(a),t(b),x(q);
  for(ll i=0;i<a;i++)cin >> s[i];
  for(ll i=0;i<b;i++)cin >> t[i];
  for(ll i=0;i<q;i++)cin >> x[i];
  
  for(ll i=0;i<q;i++){
    
    ll ans=LLONG_MAX;
    auto iter1=lower_bound(s.begin(),s.end(),x[i]);
    auto iter2=lower_bound(t.begin(),t.end(),x[i]);
    
    ll slength=distance(s.begin(),iter1);
    ll tlength=distance(t.begin(),iter2);
    cerr<<slength <<" "<<tlength<<endl;
    
    for(ll j=max(slength-1,(ll)0);j<=min(slength,a-1);j++){
      
      for(ll k=max(tlength-1,(ll)0);k<=min(tlength,b-1);k++){
        ll sansa=abs(s[j]-t[k])+abs(t[k]-x[i]);
        
        ll tansa=abs(s[j]-t[k])+abs(s[j]-x[i]);
        
        ans=min({ans,sansa,tansa});
      }
    }
    cout <<ans<<endl;
  }
}


Measured memory_bytes: 3712
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
		int q= sc.nextInt();
      	String s = sc.next();

        int[] sum = new int[s.length()];
        sum[0] = 0;
        for (int i =1; i<n; i++) {
            if (s.charAt(i-1) == 'A' && s.charAt(i) == 'C') {
                sum[i] = sum[i-1] + 1;
            }
            else {
                sum[i] = sum[i-1];
            }
        }
                               
        for (int i =0; i<q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            
            int result = sum[r-1] - sum[l-1];
            System.out.println(result);
        }
        sc.close();
    }


}

Measured memory_bytes: 66464
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long X = sc.nextLong();
		long Y = sc.nextLong();

		sc.close();

		int ans = 0;
		while (X <= Y) {
			ans++;
			X <<= 1;
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

using namespace std;

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	string s,p,q;
	for(char i='1';i<=n+'0';i++){
		s.push_back(i);
	}
	for(long long i=0;i<n;i++){
		char tmp;
		cin>>tmp;
		p.push_back(tmp);
	}
	for(long long i=0;i<n;i++){
		char tmp;
		cin>>tmp;
		q.push_back(tmp);
	}
	vector<string> hoge;

	do{
		hoge.push_back(s);
	}while(next_permutation(s.begin(),s.end()));

	sort(hoge.begin(),hoge.end());

	long long np,nq;

	for(long long i=0;i<hoge.size();i++){
		if(hoge.at(i)==p) np=i;
		if(hoge.at(i)==q) nq=i;
	}

	cout<<abs(np-nq)<<endl;

	return 0;
}


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

const int INF=(1 << 20);

int N, M;
int a[1000], b[1000];
int c[1000][13];
int cbit[1000];

int dp[4096];

signed main() {
  cin >> N >> M;
  for(int i=0; i<M; i++) {
    cin >> a[i] >> b[i];
    for(int j=0; j<b[i]; j++) {
      cin >> c[i][j];
      cbit[i] |= 1<<(c[i][j]-1);
    }
  }

  fill(dp, dp+4096, INF);

  dp[0] = 0;
  for(int i=0; i<M; i++) for(int opened=0; opened<(1<<N); opened++) 
      dp[opened | cbit[i]] = min(dp[opened | cbit[i]], dp[opened] + a[i]);

  cout << (dp[(1<<N) - 1] == INF ? -1 : dp[(1<<N) - 1]) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int h,w,n;cin>>h>>w>>n;
  vector<vector<char>> c(h,vector<char>(w));
  vector<vector<int>> a(h,vector<int>(w,0));
  rep(i,h){
    rep(j,w){
      cin>>c[i][j];
      if(c[i][j]=='#'){
        a[i][j]=n;
        n--;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(a[i][j]){
        for(int k=j-1;k>=0;k--){
          if(a[i][k])break;
          a[i][k]=a[i][j];
        }
        for(int k=j+1;k<w;k++){
          if(a[i][k])break;
          a[i][k]=a[i][j];
        }
      }
    }
  }
  rep(j,w){
    rep(i,h){
      if(a[i][j]){
        for(int k=i-1;k>=0;k--){
          if(a[k][j])break;
          a[k][j]=a[i][j];
        }
        for(int k=i+1;k<h;k++){
          if(a[k][j])break;
          a[k][j]=a[i][j];
        }
      }
    }
  }
  rep(i,h){
    rep(j,w){
      cout<<a[i][j]<<" ";
    }cout<<endl;
  }
}

Measured memory_bytes: 1280
n = int(input())
ans = 0
ma1, mi1 = -10000000000, 10000000000
ma2, mi2 = -10000000000, 10000000000
for i in range(n):
    x, y = map(int, input().split())
    ma1 = max(ma1, x - y)
    mi1 = min(mi1, x - y)
    ma2 = max(ma2, x + y)
    mi2 = min(mi2, x + y)
    ans = max(ans, ma1 - mi1, ma2 - mi2)
print(ans)

Measured memory_bytes: 9076
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
vis = {}
def dfs(i):
    if i in vis:
        return vis[i]
    vis[i] = True
    for j in g[i]:
        if dfs(j):
            return True
    vis[i] = False
    return False
for i in range(n):
    if dfs(i):
        print(0)
        break
else:
    print(-1)

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


int min(int a, int b)
{
    if(a>=b){
        return b;
    }
    else{
        return a;
    }
    
}
int main()
{
    int n,a,b,r= 0;
    cin >> n >> a >> b;
    
    r=min(a*n,b);
    cout << r << endl;
    return 0;
}

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

int main() {
  int X;
  cin >> X;
  int flag=0;
  for(int i=X;i<=100005;i++){
    flag = 1;
    for(long long j=2;j*j<=i;j++){     
      if(i % j == 0){
        flag=0;
        break;
      }
    }
    if(flag == 1){
      cout << i;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N, M;
    LL K;
    cin >> N >> M >> K;
    vector<LL> sumA(N), sumB(M);
    LL A=0;
    LL B=0;
    LL tmp = 0;
    REP(i,N){
        cin >> tmp;
        A += tmp;
        sumA[i] = A;
    }

    REP(i,M){
        cin >> tmp;
        B += tmp;
        sumB[i] = B;
    }

    int max_ans = 0; 
    int j = M;
    FOR(i, 0, N + 1){
        LL Aval;
        if(i==0){Aval = 0;}
        else{Aval = sumA[i-1];}

        LL r = K - Aval;
        if(r < 0){break;}

        while(j != 0 && sumB[j-1] > r){
            j--;
        }

        chmax(max_ans, (i+j));
    }

    cout << max_ans << endl;
    return 0;
}

Measured memory_bytes: 6392
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();

		int[] city = new int[n];

		for (int i = 0; i < m; i++) {
			scanner.nextLine();
			int a = scanner.nextInt();
			int b = scanner.nextInt();

			city[a - 1]++;
			city[b - 1]++;
		}
		for (int i = 0; i < n; i++) {
			System.out.println(city[i]);
		}
		scanner.close();
	}
}


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

typedef long long ll;

int main() {
ll N, cap;   cin >> N;  
ll bn = 1000000000000001;
for (int i = 0; i < 5; i++) {
    cin >> cap;
    bn = min(bn, cap);
}

cout << 4 +  (N + bn - 1)/ bn << endl;  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集
struct UnionFind{
  vector<int> par;
  vector<int> siz;

  UnionFind(int sz_): par(sz_), siz(sz_) {
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  void init(int sz_){
    par.resize(sz_);
    siz.resize(sz_);
    for(int i=0; i<sz_; ++i) par[i] = i, siz[i] = 1;
  }

  int root(int x){
    if(x == par[x]) return x;
    return par[x] = root(par[x]);
  }

  bool merge(int x, int y){
    x = root(x), y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return siz[root(x)];
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(4);

  int N, Q; cin >> N >> Q;
  UnionFind uf(N);
  REP(i,Q){
    int t, u, v;
    cin >> t >> u >> v;

    if(t == 0){
      uf.merge(u, v);
    }else{
      if(uf.issame(u, v)){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
  }
  return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

const int MOD = 1e9+7;

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

	string s;cin >> s;
	if(s == "ABC") cout << "ARC\n";
	else cout << "ABC\n";
 	return 0;
}

Measured memory_bytes: 3648
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)


k = int(input())
s = 0
for a in range(1,k+1):
    for b in range(a,k+1):
        t = gcd(a,b)
        for c in range(b,k+1):
            v = gcd(t,c)
            l = len(set([a,b,c]))
            if(l == 1):s += v
            elif(l == 2):s += v * 3
            else:s += v * 6
print(s)


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    ll a, b, k;
    cin >> a >> b >> k;

    int l;
    for(ll i = 0; i < k; i++){
        if(a + i > b) break;
        cout << a + i << endl;
        l = a+ i;
    }
    if(l > b - k){
        for(ll i = l+1; i <= b; i++){
            cout << i << endl;
        }
    }
    else{
        for(ll i = 0; i < k; i++){
            cout << b - k + 1 + i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n,t,a;
  cin>>n>>t>>a;
  int ans;
  int abskion = 100000000;
  int num;
  rep(i,n) {
    int k; cin>>k;
    num = t*1000 - (k * 6);
    if(abs(num - a*1000) < abs(abskion - a*1000)) {
      abskion = num;
      ans = i+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/
int main(){
  ll x,y; cin >>x >> y;
  if(labs(x-y)>=2)
    cout << "Alice" << endl;
  else
    cout << "Brown" << endl;
}

Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
using namespace std;

const long long N = 1e6 + 5, MOD = 1e9 + 7;

long long dp[N][2][2];

void test() {
    int n;
    cin >> n;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i][1][1] = (dp[i - 1][1][1] * 10 + dp[i - 1][1][0] + dp[i - 1][0][1]) % MOD;
        dp[i][1][0] = (dp[i - 1][1][0] * 9 + dp[i - 1][0][0]) % MOD;
        dp[i][0][1] = (dp[i - 1][0][1] * 9 + dp[i - 1][0][0]) % MOD;
        dp[i][0][0] = (dp[i - 1][0][0] * 8) % MOD;
    }
    cout << dp[n][1][1] << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 34732
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
string s;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	while(cin>>s)
	cout<<(char)(s[0]-32);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}

void solve()
{
  //code begins from here//
  ll x;
  cin>>x;
  if(x>=30) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
     }

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
    //cin>>testcase;
    while(testcase--) solve();
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  int n; cin >> n;
  set<char> st;
  for(int i = 0; i < n; ++i){
    char c; cin >> c;
    st.insert(c);
  }
  cout << (st.size() == 3 ? "Three" : "Four") << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
// #define LOCAL_DEFINE
// #define LOCAL
#define deb(a) cout << #a << " = " << a << '\n'
#define deb2(a, b) cout << #a << " = " << a << ", " << #b << " = " << b << '\n'
#define rep(var,start,end) for(int var=start;var<end;var++)
#define erep(var,start,end) for(int var=start;var<=end;var++)
#define rrep(var,start,end) for(int var=start;var>=end;var--)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pci pair<char,int>
#define pll pair<ll,ll>
#define test int t;cin>>t;while(t--)

ll modularExponentiation(ll n, ll p, ll M){
    ll res = 1;
    while(p){
        if(p&1)
            res = (res * n)%M;
        n = (n*n)%M;
        p >>= 1;
    }
    return res;
}
const int W = 100002;
ll dp[101][W];
void solve(){
    int n,w;
    cin >> n >> w;
    int we[n], no[n];
    for(int i = 0; i < n; ++i){
        cin >> we[i] >> no[i];
    }    
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= w; ++j){
            if(j >= we[i-1])
                dp[i][j] = max({dp[i][j], dp[i-1][j - we[i-1]] + no[i-1], dp[i-1][j]});
            else dp[i][j] = dp[i-1][j];
            ans = max(ans, dp[i][j]);
        }
    }
    // for(int i = 0; i <= n; ++i){
    //     for(int j = 0; j <= w; ++j){
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    cout << ans;
}

int main()
{
    bs;
    #ifdef LOCAL
    freopen("Contest/input.txt","r",stdin);
    freopen("Contest/output.txt","w",stdout);
    #endif
    solve();
    // test{
    //    solve(); 
    // }
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}

Measured memory_bytes: 81768
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H==0&&W==0) break;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          if(i%2==0){
            if(j%2==0){
              System.out.printf("#");
            }else{
              System.out.printf(".");
            }
          }else{ 
            if(j%2==0){
              System.out.printf(".");
            }else{
              System.out.printf("#");
            }
          }
        }
         System.out.printf("\n");
      }
    System.out.printf("\n");
    }
  }
}

Measured memory_bytes: 60468
#include<stdio.h>
int main()
{
	int n,a[100];
	int i,j,x=0,m=-1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		if(m<=a[i]){
			m=a[i];
		}
	}
	for(i=0;i<n;i++){
		x+=a[i];
	}
	printf("%d\n",x-m+(m/2));
	return 0;
}

Measured memory_bytes: 1708
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int main()
{
	while(~scanf("%d", &n))
	{
		for(long long i = 1; i <= n; i++)
		{
			if(i * i > n) {
				printf("%lld\n", (i - 1) * (i - 1));
				break;
			}
			if(i * i == n) {
				printf("%lld\n", i * i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    int n;
    cin>>n;
    ll a[300030];
    for(int i=0; i<n; i++) cin>>a[i];
    ll ans=0;
    for(int i=0; i<60; i++){
        ll c=0;
        for(int j=0; j<n; j++){
            if(a[j]&(1ll<<i)) c++;
        }
        ans+=(c*(n-c)%MOD*((1ll<<i)%MOD));
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
 
int main(void)
{
 
  long int a, b, r, x, tmp;
  scanf("%ld %ld",&a,&b);
 
  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最小公倍数を出力 */
  printf("%ld", x/b);
 
  return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;
typedef pair<int,int> P;

int main() {
    int N, M;
    cin >> N >> M;
    vector<P>students(N);
    vector<P>checkpoints(M);
    for (int i=0; i<N; i++) cin >> students[i].first >> students[i].second;
    for (int i=0; i<M; i++)cin >> checkpoints[i].first >> checkpoints[i].second;

    for (int i=0; i<N; i++){
        int ans = 0;
        int last_dis = INF;
        int sx, sy;
        sx = students[i].first;
        sy = students[i].second;

        for (int j=0; j<M; j++){
            int dis;
            dis = abs(checkpoints[j].first - sx) +  abs(checkpoints[j].second - sy);
            if (dis < last_dis){
                last_dis = dis;
                ans = j;
            }
        }

        cout << ans+1 << endl;
    }
}

Measured memory_bytes: 256
import math
import numpy as np

N = int(input())
A = np.array([int(input()) for _ in range(N)])
S = np.sum(A)
MOD = 998244353


# dp0[i][j]: number of ways to obtain sum j for one of colors using first i integers.
# i = 0, 1, ..., N
# j = 0, 1, ..., S
dp0 = np.zeros((N + 1, S + 1), dtype=np.int64)

# dp1[i][j]: number of ways to obtain sum j for one of colors using first i integers,
#     but this time we use only TWO colors.
#     This will be used to find the number of cases when
#         (sum of R)= (sum of G) = S/2 & (sum of B) = 0 

dp1 = np.zeros((N + 1, S // 2 + 1), dtype=np.int64)

# using 0 integer to obtain sum=0
dp0[0, 0] = 1
dp1[0, 0] = 1


for i, x in enumerate(A):

    # If we do not use the next integer x, e.g. not for R, the sum of R is same, but possible ways are doubled
    #     because x can be used for either G or B
    dp0[i+1, :] += dp0[i, :] * 2 % MOD

    # Then we update the case when we use the next integer x.
    #     Lets say, sum=p was obtained for 4 different ways without using current integer x,
    #     then sum=p+x can also be obtained for 4 different ways.
    dp0[i+1, x:] += dp0[i, :-x]

    # If we do not use the next integer x, e.g. not for R, the sum of R is same, and possible ways are the same
    #     because this time we use only TWO colors. (say R and G, we dont use x for R, then automatically x goes for G)
    dp1[i+1, :] += dp1[i, :] % MOD

    # Then we update the case when we use the next integer x.
    dp1[i+1, x:] += dp1[i, :-x]


# count cases: (R >= S / 2)
not_satisfy = np.sum(dp0[N][math.ceil(S/2):])

# count cases: (R = S / 2) & (B = S / 2)
double_reduct = 0 if S % 2 == 1 else dp1[N][S/2]

# total cases = 3 ** N

ans = (3 ** N - 3 * not_satisfy + 3 * double_reduct) % MOD
print(ans)



Measured memory_bytes: 328924
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	int X = max(A,C);
	int Y = min(B,D);
	if(Y - X < 0) {
		cout << 0 << endl;
	}
	else {
		cout << Y - X << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
 public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  ArrayList<Integer> code =new ArrayList<Integer>();
  ArrayList<Integer> tmp =new ArrayList<Integer>();
  ArrayList<Integer> initial =new ArrayList<Integer>();
  int a=0,n=0,r=0;
do{
  n=sc.nextInt();
  for(int j=0;j<n;j++){
    code.add(j,n-j);
  }
  r=sc.nextInt();
  for(int i=0;i<r;i++){
    int p=sc.nextInt();
    int c=sc.nextInt();
    for(int k=0;k<p+c-1;k++){
      tmp.add(k,code.get(k));
    }
    for(int l=0;l<c;l++){
      code.set(l,tmp.get(p-1+l));
    }
    for(int m=0;m<p-1;m++){
      code.set(m+c,tmp.get(m));
    }
    }
    initial.add(a,code.get(0));
    a++;
  }while(n!=0&&r!=0);
  for(int h=0;h<a-1;h++){
    System.out.println(initial.get(h));
  }
 }
}

Measured memory_bytes: 49324
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  string S; cin >> S;
  reverse(all(S));
  vector<string> T = {"dream", "dreamer", "erase", "eraser"} ;
  rep(i,4) reverse(all(T[i]));
  int jd = 0;
  while (jd < 4){
    rep(i,4){
      if(S.substr(0,T[i].size()) == T[i]){
        S = S.substr(T[i].size());
        if (S.size() == 0 ) { cout << "YES" << endl; return 0;}
        jd = 0; break;
      }
      jd++;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 1000000000000000000
#define maxn 1000001
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<" "<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 256