akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> a(n,0); 
    vector<int> b(n,0); 
    vector<int> c(n,0); 
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    vector<vector<long long>> cost(3,vector<long long>(n,0));

    cost[0][0]=a[0];
    cost[1][0]=b[0];
    cost[2][0]=c[0];

    for(int i=0; i<n-1; i++){
        cost[0][i+1]=max(cost[1][i]+a[i+1],cost[2][i]+a[i+1]);
        cost[1][i+1]=max(cost[0][i]+b[i+1],cost[2][i]+b[i+1]);
        cost[2][i+1]=max(cost[0][i]+c[i+1],cost[1][i]+c[i+1]);
    }
    cout<<max({cost[0][n-1],cost[1][n-1],cost[2][n-1]})<<endl;
    return 0;
}

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

using namespace std;

int i,j,k;

int main(){
    long n,k,ans;
    ans=0;
    cin>>n>>k;

    n=n%k;
    ans=min(n,k-n);
    
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(100010), D(100010);
    for(int i = 1; i <= N; i++) cin >> A.at(i);
    for(int i = 1; i <= N; i++){
        int e1 = abs(A.at(i - 1) - A.at(i));
        int e2 = abs(A.at(i) - A.at(i + 1));
        int e3 = abs(A.at(i - 1) - A.at(i + 1));
        D.at(i) = e1 + e2 - e3;
    }
    ll ans = 0;
    for(int i = 0; i <= N; i++){
        ans += abs(A.at(i + 1) - A.at(i));
    }

    for(int i = 1; i <= N; i++){
        cout << ans - D.at(i) << endl;
    }
}

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

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;
    cout << H * W - W * h - H * w + h * w << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MAX_M = 100000;
int find_num[MAX_M+1] = {};

ll f(ll n, ll x, ll m){
    ll ans = 0;
    for(ll i=0; i<n; ++i){
        ans += x;
        x = (x*x)%m;
    }
    return ans;
}

int main()
{
    ll n, x, m;
    cin >> n >> x >> m;
    if(n<=MAX_M){
        cout << f(n, x, m);
        return 0;
    }
    ll y = x;
    int cnt = 1;
    while(find_num[y] == 0){
        find_num[y] = cnt;
        cnt++;
        y = (y*y)%m;
    }
    // 周期
    const int interval = cnt - find_num[y];
    const ll interval_sum = f(MAX_M+interval, x, m) - f(MAX_M, x, m);
    const ll interval_num = (n-MAX_M)/interval;
    const ll remain_num = n - interval_num * interval;
    cout << interval_sum * interval_num + f(remain_num, x, m);
    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int s;
    cin>>s;
    int arr[s];
    for(int i = 0; i <s;++i){
        cin>>arr[i];
    }

    for(int i = s-1; i >=0; i-=2){
        cout<<arr[i]<<" ";
    }

    for(int i = s%2? 1 : 0 ; i<s; i+=2){
        cout<<arr[i]<<" ";
    }


    return 0;
}


Measured memory_bytes: 4360
inf = input().split()
N = int(inf[0])
K = int(inf[1])
line = [int(v) for v in input().split()]

ans = 0
if K<N:
  for k in range(K+1):
    for i in range(k+1):
      item = line[:i]+line[N-k+i:]
      item.sort()
      count = 0
      while count<K-k and item:
        if item[0]>0:
          break
        item = item[1:]
        count += 1
      s = sum(item)
      if s>ans:
        ans = s
else:
  line = [i for i in line if i>0]
  ans = sum(line)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
long long ans,s[10000001],x=1,y=1,n,sum;
int main()
{
//	freopen("1.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);		
		sum+=s[i];
	}
	if(sum%10!=0) ans=sum;
	for(int i=1;i<=n;i++)
	{
		x=sum-s[i];
		if((x%10)!=0) ans=max(ans,x);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#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 n;
  cin >> n;
  n = n % 1000;
  if(n==0){
    cout << 0 << endl;
  }else{
    cout << 1000 - n << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define prin(ans) cout << ans << endl
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 105
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef map<ll, ll> Map;

ll N, M;
Map mp;
ll fact[100101];
ll rfact[100101];


ll modPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

void pdiv(ll n) {
    for(ll i=2; i<=n; i++) {
        while(n%i==0) {
            mp[i]++;
            n/=i;
        }
    }
}


int main(void) {
    cin >> N >> M;
    pdiv(M);
    ll ans=1;
    ll i;
    
    fact[0]=rfact[0]=1;
    for(i=1; i<=100035; i++) {
        fact[i]=i*fact[i-1]%MOD;
        rfact[i]=modPow(fact[i], MOD-2);
    }
    
    
    for(auto it=mp.begin(); it!=mp.end(); it++) {
        ans*=fact[N+it->second-1]*rfact[N-1]%MOD*rfact[it->second]%MOD;
        ans%=MOD;
    }
    
    prin(ans);
}

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

int main(){
  string word;
  int n;
  cin >> word;
  cin >> n;
  for (int i = 0; i < n; i++){
    string order;
    int a, b;
    cin >> order >> a >> b;
    // cout << "####" << endl;
    if (order == "replace"){
      string replace_word;
      cin >> replace_word;
      word.replace(a, (b - a + 1), replace_word);
      // cout << "word:" << word << endl;
    }else if (order == "reverse"){
      reverse(&word[a], &word[b + 1]);
      // cout << "word:" << word << endl;
    }else{
      string print_str = word.substr(a, (b - a + 1));
      cout << print_str << endl;
      // cout << "word:" << word << endl;
    }
    // cout << "####" << endl;
  }
  // cin >> word;
  // int a, b;
  // cin >> a >> b;
  // reverse(&word[a], &word[b]);
  // cout << word << endl;
}


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

#define MOD 1000000007

int main() {
	string s; cin >> s;
	vector<vector<long long>>  dp(s.size() + 1, vector<long long>(13, 0));
	dp[0][0] = 1;
	for (int i = 0; i < s.size(); i++) {
		int x;
		if (s[i] == '?') { x = 10; }
		else { x = s[i] - '0'; }//?でなければ0～9の数字が入る。

		for (int j = 0; j < 10; j++) {
			if (x != 10 && x != j) {//dpテーブルを遷移させないで良い(文字列的にありえない数字)
			}
			else {
				for (int k = 0; k < 13; k++) {//10倍するのは、i+1においてあり得る整数で判定するから。
					dp[i + 1][(k * 10 + j) % 13] = (dp[i + 1][(k * 10 + j) % 13] + dp[i][k]) % MOD;
				}
			}
		}
	}

	cout << dp[s.size()][5] << endl;

	return 0;
}

Measured memory_bytes: 13696
while input = gets
  a,b,c,d,e,f = input.chomp.split(" ").map(&:to_f)
  l = d/a

  m = (l*c-f)
  n = (l*b-e)
  #print l
  #print m
  #print n
  
  if a != 0
    y = m/n
    x = (c-b*y)/a
  else a == 0
    y = c/b if b != 0
    x = (f-e*(c/b))/d
  end
  printf("%.3f %.3f\n", x, y)
end




Measured memory_bytes: 6864
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String n = sc.next();
			
			for(int i = 0 ; i < n.length() ; i++ ) {
				if ( n.charAt(i) == '7') {
					System.out.println("Yes");
					return;
				}
			}
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 35540
N = int(input())
R = list(int(input())for _ in range(N))
def gcd(a,b):
        if a < b:
            c = b
            b = a
            a = c
        while b != 0:
            c = a % b
            a = b
            b = c
        return a
def lcm(a,b):
    c = a*b//gcd(a,b)
    return c
p = R[0]
for i in range(N):
    p = lcm(p,R[i])
print(p)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    ll t = 0;
    rep(i,m) t += b[i];    // bの合計

    // 尺取法
    int j = m;    // bはmから減らしていく
    int ans = 0;
    rep(i, n+1) {    // aは0からnまで増やしていく
        if (i>0) t += a[i-1];   // i個までの累計になるように足す 0個は0
        while (j>0 && t>k) {    // t<=k または j==0 で抜ける
            --j;
            t -= b[j];
        }
        if (t>k) break;    // bが0番まで行っても　t>k の場合はだめ
        ans = max(ans, i+j);
    }
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main()
{
  int N, T, A, h;
  cin >> N >> T >> A;
  vector<int> c(N);
  rep(i, N)
  {
    cin >> h;
    c[i] = abs(T * 1000 - h * 6 - A * 1000);
  }
  cout << distance(c.begin(), min_element(all(c))) + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n;
    cin>>n;
    int a,b, ans=0, counter=0;
    cin>>a;
    rep(i,(n-1)){
        cin>>b;
        if(a>=b) counter++;
        else{
            ans=max(ans,counter);
            counter=0;
        }
        a=b;
    }
    ans=max(ans,counter);
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N ;
  cin  >> N ;
   
  vector <int> vec(N);
  vec.at(0) = 0 ;       
   for (int i=1 ; i<N ; i++){
     cin >> vec.at(i);     //上司を代入
   } 
  
  sort(vec.begin(),vec.end() );
  
  vector<int> Me(N,0) ;  // 自分が上司の回数
  
   int k=1;
    for (int j=0 ; j<N ; j++){
      if( k==vec.at(j) ){
       Me.at(k-1)++; 
        
      }
      if(k<vec.at(j) ){
       
      
        k++;
        if(k=vec.at(j) ){
        Me.at(k-1)++;
        }
      }
    }
    
    
     
  
  
  
     
   
  
      
    
  
  for (int p=0 ; p<N ; p++) {
    cout << Me.at(p) << endl; 
  }
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int cnt = 0;
const int INF = 1001001001;
//int l[500005/2+2], r[500005/2+2];

void merge(vector<int> &a, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  vector<int> l(n1+1), r(n2+1);
  rep(i, n1) {
    l[i] = a[left + i];
  }
  rep(i, n2) {
    r[i] = a[mid+i];
  }
  l[n1] = INF;
  r[n2] = INF;
  int i = 0;
  int j = 0;
  for (int k=left; k<right; ++k) {
    cnt++;
    if (l[i] <= r[j]) {
      a[k] = l[i];
      i++;
    } else {
      a[k] = r[j];
      j++;
    }
  }
}

void mergeSort(vector<int> &a, int left, int right) {
  if (left+1 < right) {
    int mid = (left + right) / 2;
    mergeSort(a, left, mid);
    mergeSort(a, mid ,right);
    merge(a, left, mid, right);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i,n) cin >> s[i];

  mergeSort(s, 0, n);
  rep(i,n) {
    printf("%d%c", s[i], (i == n-1 ? '\n':' '));
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 6808
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n,m;
string a[100];
string b[100];
int flag;
int ff;
int main()
{
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>b[i];
	rep(i,n-m+1)
	{
		rep(j,n-m+1)
		{
			ff=1;
			rep(k,m)
			{
				rep(l,m)
				{
					if(a[i+k][j+l]!=b[k][l])
					{
						ff=0;
					}
				}
			}
			if(ff)flag=1;
		}
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MAX int( 1e5 +5)



int main(){
    llong n,w;
    cin >> n >> w;
    llong ans[MAX];
    REP(i,MAX) ans[i] = w + 1;
    ans[0] = 0;

    REP(i,n){
        llong cost,valu;
        scanf("%lld%lld",&cost,&valu);
        REPR(j,n * 1000 -valu){
            ans[j + valu] = min(ans[j + valu],ans[j] + cost);
        }
    }
    llong res=0;
    REP(i,n * 1000+1) if(ans[i] <=w) res = i;
    cout << res << endl;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;

  return 0;
}

Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]
A = sorted(A)[::-1]
B = sorted(B)[::-1]
C = sorted(C)[::-1]

List = []

for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            else:
                List.append(A[i]+B[j]+C[k])

List = sorted(List)[-1:-K-1:-1]
for i in range(K):
    print(List[i])

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

using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::greater;

int A[100'010];// Damage by slashing by katana_i.
int B[100'010];// Damage by throwing by katana_i.

// Compute minimum number of attack to kill the monster.
int main() {
	// Input
	int N;// Number of katana.
	int H;// Hit point of monster.
	cin >> N >> H;
	for(int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}
	// Calculation
	sort(A, A + N, greater<int>());
	sort(B, B + N, greater<int>());
	int counter = 0;
	for(int i = 0; i < N; ++i) {
		if(B[i] < A[0]) break;
		++counter;
		H -= B[i];
		if(H <= 0) break;
	}
	if(H > 0) {
		counter += (H / A[0]) + ((H % A[0]) != 0);
	}
	// Output
	cout << counter << endl;
	return 0;
}

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

int main() {
  int N, Q, B, C, T;
  long long Sum=0;
  cin >> N;
  vector<int> A(100001,0);
  rep(i, N){
    cin >> T;
    A.at(T)++;
    Sum+=T;
  }
  cin >> Q;
  rep(i, Q){
    cin >> B >> C;
    Sum+=A.at(B)*(C-B);
    A.at(C)+=A.at(B);
    A.at(B)=0;
    cout << Sum << endl;
  }
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,k;cin>>a>>b>>k;
  ll cnt = 0;
  for(ll i=1111;;i--){
    if(a%i == 0 && b%i == 0)cnt++;
    if(cnt == k){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

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

using namespace std;

int main(){
    int N;
    int arr[110];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> arr[i];

    sort(arr, arr+N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0) Alice += arr[i];
        else Bob += arr[i];
    }

    cout << Alice - Bob << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    
    val msg = when(n){
        1 -> "Hello World"
        2 -> {
            val a = readLine()!!.toInt()
            val b = readLine()!!.toInt()
            a + b
        }
        else -> "hiroponi"
    }
    
    println(msg)
}


Measured memory_bytes: 31688
#include <iostream>
#include <vector>
#include <string>
int main(void) {
	int a, b;
	std::cin >> a >> b;
	if (a > 9 || b > 9) { std::cout << "-1" << std::endl; }
	else { std::cout << a * b << std::endl; }
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int A[1000010];

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

	string S;
	cin >> S;

	reverse(all(S));

	int ans = 0;
	rep(i, 0, SZ(S) + 1)
	{
		if (i < SZ(S))
		{
			A[i] += S[i] - '0';
		}
		if (A[i] >= 10)
		{
			A[i] -= 10;
			A[i + 1]++;
		}

		if (A[i] == 5)
		{
			ans += A[i];
			if (i + 1 < SZ(S) && S[i + 1] > '4')
			{
				A[i + 1]++;
			}
		}
		else if (A[i] < 5)
		{
			ans += A[i];
		}
		else
		{
			ans += 10 - A[i];
			A[i + 1]++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

constexpr ll MOD = 998244353;

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

	vector<int> A(N);
	rep(i, N)
	{
		cin >> A[i];
	}

	vector<vector<ll>> dp(N, vector<ll>(S+1, 0));
	if (A[0] <= S) dp[0][A[0]] = 1;
	dp[0][0] = 2; // 空集合とA[0]だけの集合でA[0]を使わない場合

	rep_init(i, 1, N)
	{
		rep(j, S+1)
		{
			if (A[i] <= j) (dp[i][j] += dp[i-1][j-A[i]]) %= MOD;
			(dp[i][j] += 2 * dp[i-1][j]) %= MOD;//i-1までのやつ、A[i]を加えた部分集合のうちA[i]を使わない場合を考えるので二倍する
		}
	}

	cout << dp[N-1][S] << endl;

	return 0;
}


Measured memory_bytes: 73728
#include <bits/stdc++.h>
using namespace std;
const long long int INF =  1LL<<60; 
int main() {
    while(true) {
        int N, K;
        cin >> N >> K;
        if(N == 0 && K == 0) {
            break;
        }
        vector<int> a(N);
        for(int i = 0; i < N; i++) {
            cin >> a[i];
        }
        int max = 0;
        vector<int> s(N+1);
        for(int i = 0; i < N; i++) {
            s[i+1] = s[i] + a[i];
        }
        long long int res = -INF;
        for(int i = 0; i+K <= N; i++) {
            long long int value = s[i+K] - s[i];
            if(res < value) {
                res = value;
            }
        }
            cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
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 (a>b) { a=b; return 1; } return 0; }
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin>>s;
int n=s.size();
vector<ll> a(n+1,0);
for(int i=0;i<n;i++){
    if(s[i]=='<')a[i+1]=a[i]+1;
}
for(int i=n-1;i>=0;i--){
    if(s[i]=='>')a[i]=max(a[i],a[i+1]+1);
}
ll ans=0;
for(int i=0;i<=n;i++){
   ans+=a[i];
}
cout<<ans<<endl;
}



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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int x;
    cin >> x;

    string ans;
    if (x >= 1200){
        ans = "ARC";
    } else {
        ans = "ABC";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long int gcd(long long int x, long long int y)
{
  long long int t;

  while (y != 0) {
    t = x % y;
    x = y;
    y = t;
  }
  return x;
}

int main (int argc, char* argv[])
{
  long long int a, b;
  while (scanf("%lld %lld", &a, &b) != EOF) {
    printf("%lld %lld\n", gcd(a, b), (long)a*b/gcd(a, b));
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B, C, D;

int main(void){
    
    scanf("%d %d %d %d", &A, &B, &C, &D);
    
    if(A + B > C + D) printf("Left\n");
    else if(A + B < C + D) printf("Right\n");
    else printf("Balanced\n");
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;

int main() {
	int N,K;
	cin >>N>> K;
	int ans=0;
	int t = 0;
	for (size_t i = 0; i < N; i++)
	{
		cin >> t;
		ans += min(abs(K - t), abs(t))*2;
	}
	cout << ans;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


const int pmax = pow(10,5);

vector<bool> isp(pmax, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=pmax; i++) {
    if (isp[i]) for(int j=2; i*j<=pmax; j++) isp[i*j] = false;
  }
}

ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll gcd_all(ll arr[], int N) {
  ll result = 0;
  rep(i,N) result = gcd(result, abs(arr[i]));
  return result;
}

int main() {
  int N; cin >> N;
  ll a[N+1]; rep(i,N+1) cin >> a[N-i];

  sieve();
  ll pos = 0; while(a[pos]==0) pos++;
  ll gcda = gcd_all(a,N+1);
  rep(p,N+1) {
    if (!isp[p]) continue;
    ll tmpa[N+1]; memcpy(tmpa, a, sizeof(a));
    for (int j=N; j-(p-1)>=0; j--) {
      tmpa[j-(p-1)] += tmpa[j];
      tmpa[j] = 0;
    }
    bool ok = true;
    rep(j,N+1) if (tmpa[j]%p!=0) ok = false;
    if (ok&&a[0]%p==0) cout << p << endl;
  }
  for (int p=1; p*p<=gcda; p++) {
    if (!isp[p]) continue;
    if (gcda%p==0) {
      if (p>=N+1) cout << p << endl;
      while(gcda%p==0) gcda /= p;
    }
  }
  if (gcda>=N+1&&gcda!=1) cout << gcda << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> Q;

const int inf1=1e9+9;
const ll inf2=8e18+9;
const ll mol=1e9+7;
const int maxn=1e5+9;
const ll maxx=1e5+9;

int n,q,num;
ll b,c,cnt[maxn];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&num),cnt[num]++;
    ll sum=0;
    for(ll i=0;i<maxx;i++) sum+=cnt[i]*i;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%lld%lld",&b,&c);
        sum+=(c-b)*cnt[b];
        cnt[c]+=cnt[b];
        cnt[b]=0;
        printf("%lld\n",sum);
    }
}


Measured memory_bytes: 4024
def main():
  import sys
  input=sys.stdin.buffer.readline
  h,w=map(int,input().split())
  s=input()
  a=b=x=y=s[0]==35
  d=[(b,a)]
  d_add=d.append
  for i in range(1,w):
    f=s[i]==35
    b+=a^f
    a=f
    d_add((b,a))
  for _ in range(h-1):
    s=input()
    f=s[0]==35
    y+=x^f
    b=y
    a=x=f
    p=[(b,a)]
    p_add=p.append
    for i in range(1,w):
      f=s[i]==35
      b+=a^f
      c,g=d[i]
      c+=f^g
      if b>c:b=c
      a=f
      p_add((b,a))
    d=p
  print(b+1>>1)
main()

Measured memory_bytes: 3064
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition)
import Data.Char (isSpace)
import qualified Data.Set as S
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import qualified Data.ByteString.Char8 as B

-- utility functions

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

enumKSubStrings :: Int -> B.ByteString -> S.Set B.ByteString
enumKSubStrings k bs = S.unions $ map (enum . B.take k) (B.tails bs) where
  enum bs = foldr S.insert S.empty (tail $ B.inits bs)

main = do
  bs <- B.getLine
  k <- read <$> getLine
  B.putStrLn . (!!(k-1)) . S.toList . enumKSubStrings k $ bs


Measured memory_bytes: 3580
def ris():
    return map(int, input().split())

def rs():
    return input()

n, k, c = ris()
s = rs()

i=0
rk = k
l1=[]
while(rk):
    if s[i]=='o':
        l1.append(i)
        rk-=1
        i+=c
    i+=1

i=n-1
rk=k
l2=[]
while(rk):
    if s[i]=='o':
        l2.append(i)
        rk-=1
        i-=c
    i-=1

for i1,i2 in zip(l1,reversed(l2)):
    if i1==i2:
        print(i1+1)






Measured memory_bytes: 20644
import math
a, b, C = map(int, input().split())
S = a*b*math.sin(math.radians(C))/2
L = a+b+math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))
h = b*math.sin(math.radians(C))
print(S)
print(L)
print(h)


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


int main() {

    ll N;
    cin >> N;

    ll a, b;
    vl A(N);
    ll ans = 0;
    rep(i, N) {
        cin >> a >> b;
        A[i] = a + b;
        ans -= b;
    }

    sort(A.begin(), A.end(), greater<ll>());

    rep(i, N) if(i%2==0) ans += A[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4012
H, W = gets.split.map(&:to_i)
row = H.times.map { gets.chomp.chars }
row.size.times do |i|
    row[i].size.times do |j|
        if row[i][j] == '#'
            if i == 0
            # 1行目
                if j == 0
                    # 左上角
                    if row[i][j+1] == '.' && row[i+1][j] == '.'
                        puts 'No'
                        exit
                    end
                elsif j == (W-1)
                    # 右上角
                    if row[i][j-1] == '.' && row[i+1][j] == '.'
                        puts 'No'
                        exit
                    end
                else
                    if row[i][j+1] == '.' && row[i][j-1] == '.' && row[i+1][j] == '.'
                        puts 'No'
                        exit
                    end
                end
            elsif i == (H-1)
            # 最終行
                if j == 0
                    # 左下角
                    if row[i][j+1] == '.' && row[i-1][j] == '.'
                        puts 'No'
                        exit
                    end
                elsif j == (W-1)
                    # 右下角
                    if row[i][j-1] == '.' && row[i-1][j] == '.'
                        puts 'No'
                        exit
                    end
                else
                    if row[i][j+1] == '.' && row[i][j-1] == '.' && row[i-1][j] == '.'
                        puts 'No'
                        exit
                    end
                end
            else
                if row[i][j+1] == '.' && row[i][j-1] == '.' && row[i+1][j] == '.' && row[i-1][j] == '.'
                    puts 'No'
                    exit
                end
            end
        end
    end
end
puts 'Yes'

Measured memory_bytes: 1916
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD2 1000000007
#define MOD 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int fact[1100000];
Int revfact[1100000];
Int rev[1100000];

void init(){
    Int m = MOD;
    fact[0] = 1;
    revfact[0] = 1;
    rev[0] = 0;
    rev[1] = 1;
    for(int i = 1;i < 1100000;i++){
        fact[i] = fact[i-1] * i % m;
        if(i>1)rev[i] = MOD / i * (MOD-rev[MOD % i]) % MOD;
        revfact[i] = revfact[i-1] * rev[i] % MOD;
    }
}

Int comb[1100][1100];

Int nCk(Int n, Int k){
    if(n < k)return 0;
    if(comb[n][k] != 0)return comb[n][k];
    Int &res = comb[n][k];
    return res = fact[n] * revfact[n-k] % MOD * revfact[k] % MOD;
}

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    Int res = mod_pow(x, a / 2, m);
    res = res * res % m;
    if(a % 2)res *= x;
    return res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}

Int aall, ball;
Int n, ans;
Int a[440], b[440];
Int dp[440][440][2][2];

int main(){
    init();
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i] >> b[i];
        aall += a[i];
        ball += b[i];
    }

    dp[0][0][0][0] = 1;
    for(int i = 1;i <= n;i++){
        int id = i % 2;
        for(int asum = aall;asum >= 0;asum--){
            for(int cnt = 0;cnt <= ball;cnt++){
                for(int p = 0;p < 2;p++){
                    if(asum-a[i-1] < 0)continue;
                    Int pw = 1;
                    for(int use = 0;use < b[i-1];use++){
                        if(cnt-use >= 0){
                            Int tmp =  nCk(cnt, use) % MOD * pw %  MOD;
                            dp[asum][cnt][p][0] += dp[asum-a[i-1]][cnt-use][p^1][0] * tmp % MOD;
                            dp[asum][cnt][p][1] += dp[asum-a[i-1]][cnt-use][p^1][1] * tmp % MOD;
                        }
                        else break;
                        pw = pw * a[i-1] % MOD;
                    }
                    if(cnt-b[i-1]+1 >= 0)
                        dp[asum][cnt][p][1] += dp[asum-a[i-1]][cnt-b[i-1]+1][p^1][0] * nCk(cnt, b[i-1]-1) % MOD * pw %  MOD;
                    dp[asum][cnt][p][0] %= MOD;
                    dp[asum][cnt][p][1] %= MOD;
                }
            }
        }
    }

    for(int asum = 0;asum <= aall;asum++){
        Int rev_asum_pow = 1;
        for(int cnt = 0;cnt <= ball;cnt++){
            rev_asum_pow = rev_asum_pow * rev[asum] % MOD;
            for(int p = 0;p < 2;p++){
                Int x = dp[asum][cnt][p][1] * rev_asum_pow  % MOD * (cnt+1) % MOD * aall % MOD * rev[asum] % MOD;
                if(p == 1)ans += x;
                else ans -= x;
                ans %= MOD;
            }
        }
    }
    if(ans < 0)ans += MOD;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 37504
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ab_s = Array.(to_list @@ init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a - 1, b - 1)
let cs = Array.make n 0
let _ = List.(iter (fun (a, b) -> if a = 0 then cs.(b) <- 1) ab_s; print_endline @@ if exists (fun (a, b) -> b = n - 1 && cs.(a) = 1) ab_s then "POSSIBLE" else "IMPOSSIBLE")

Measured memory_bytes: 16512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

ll gcd(ll n, ll m){

    if(m > n)  return gcd(m, n);

    ll r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}

ll lcm(ll n, ll m){
    return n / gcd(n, m) * m;
}

int main(){

    int n; cin >> n;

    ll t[n];
    for(int i=0; i<n; i++){
        cin >> t[i];
    }

    ll ans = lcm(t[0], 1LL);
    for(int i=1; i<n; i++){
        ans = lcm(ans, t[i]);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
import math
from functools import lru_cache
from operator import mul
from functools import reduce


def resolve():
    import sys
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    def combinations_count(n, r, mod=10**9+7):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n-r)
        return fact[n] * factinv[r] * factinv[n-r] % mod
    
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

    A.sort()
    B = A[::-1]

    sum = 0
    for i in range(K-1, N):
        sum += combinations_count(i, K-1) * A[i] % MOD - combinations_count(i, K-1) * B[i] % MOD

    print(sum % MOD)


if __name__ == "__main__":
    resolve()

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200005

int N,K,A[maxn];
int num[maxn];

int main(){
	fast;
	
	cin>>N>>K;
	FOR(i,1,N) cin>>A[i];
	
	FOR(i,1,K){
		bool done = 1;
		FOR(j,1,N) if (A[j] != N) done = 0;
		if (done) break;
		
		mem(num,0);
		
		FOR(j,1,N){
			num[max((ll)1,j - A[j])]++;
			num[min((ll)N+1,j + A[j] + 1)]--;
		}
		int curnum = 0;
		FOR(j,1,N){
			curnum += num[j];
			A[j] = curnum;
		}
		//~ curnum = 0;
		//~ DEC(j,N,1){
			//~ curnum -= num[j];
			//~ A[j] += curnum;
		//~ }
		
	}
	FOR(i,1,N) cout<<A[i]<<' ';
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 100001
using namespace std;

ll n;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    vector<int> a( n,0 );
    vector<int> b( n,0 );
    vector<int> c( n,0 );
    for(int i =0;i<n; i++){
        cin>>a[i];
    }
    for(int i =0;i<n; i++){
        cin>>b[i];
    }
    for(int i =0;i<n; i++){
        cin>>c[i];
    }
    
    sort(a.begin(), a.end() );
    sort(c.begin(), c.end() );
    ll ans;
    for(int i =0;i<n; i++){
        auto tt = lower_bound(a.begin(), a.end(), b[i] );
        auto ss = upper_bound(c.begin(), c.end(), b[i]) ;
        ll t = tt - a.begin();
        ll s = c.end() - ss; 
        ans += t*s;
    }
    cout<< ans  <<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

int main () {
  int N, T;
  cin >> N >> T;
  vi filtered_c;
  rep(i,N) {
    int c, t;
    cin >> c >> t;
    if (t > T) continue;
    filtered_c.pb(c);
  }
  if (filtered_c.empty()) {
    cout << "TLE" << endl;
  }
  else {
    cout << *min_element(rng(filtered_c)) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#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>;

struct UnionFind{
    vector<int>p,r;
    UnionFind(int n){
        p.resize(n,-1);
        r.resize(n,1);
    }
    int find(int x){
        if(p[x]==-1)return x;
        else return p[x]=find(p[x]);
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(r[x]>r[y])swap(x,y);
        if(r[x]==r[y])r[y]++;
        p[x]=y;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

int main(){
    int n,q;
    cin>>n>>q;
    UnionFind uf(n);
    rep(i,q){
        int p,a,b;
        cin>>p>>a>>b;
        if(p==0){
            uf.unite(a,b);
        }
        else{
            cout<<(uf.same(a,b)?"1":"0")<<endl;
        }
    }
}


Measured memory_bytes: 4716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

	int n,m,cnt[30];
int main(){
	cin >> n;
	int ans = 0;
	cu(i,0,n){
		int x;
		cin >> x;
		ans = gcd(ans, x);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	if(A==5&&B==5&&C==7) printf("YES");
	else if(A==5&&B==7&&C==5) printf("YES");
	else if(A==7&&B==5&&C==5) printf("YES");
	else printf("NO");
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

long long getRandom(long long a,long long b){
    long long ret = (long long)rand()*(long long)rand();
    ret %= (b - a + 1);
    ret += a;
    return ret;
}

int main()
{
    ll l=in(),r=in();
    ll mn=2020;
    for(ll i=l;i<=min(r,l+3000);i++)
    {
        for(ll j=i;j<=min(r,l+3000);j++)
        if(i!=j)
        mn=min(mn,(i*j)%2019);
    }
    pt(mn);
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = 998244353;

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1)ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    VEC(int, a, n);

    bool ok = true;
    if(a[0] != 0)ok = false;
    map<int, int> mp;

    rep(i, n){
        mp[a[i]]++;
    }

    int now = 0;
    for(auto m : mp){
        if(now != m.first)ok = false;
        now++;
    }

    ll res = 1;
    ll p;
    if(mp[0] != 1)ok = false;

    if(ok){
        for(auto m : mp){
            if(m.first > 0)res = res * mpow(p, m.second) % MOD;
            p = m.second;
        }
    }
    else res = 0;
    cout << res;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
	#define endl "\n"
	#define ll long long int
	
	using namespace std;
	
	signed main()
	{

	std::ios::sync_with_stdio(false);
	
	int n; cin>>n;
	int a[n],b[n];
	int f=0;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; ++i)
	{
		if(a[i]!=b[i])
			f++;
	}
	if(f<3)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
	}


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

int main() {
  int h,w;
  while(true) {
    cin >> h >> w;
    if(h==0&&w==0) break;
    rep(i,h) {
      rep(j,w) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3100