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

int main(){
  int N;
  cin >> N;
  int d[N] = {};
  for(int i = 0;i < N;i++){
    cin >> d[i];
  }
  sort(d,d+N);
  int a = d[(N / 2)] - d[N / 2 - 1];
  cout << (a*(a>=0)) << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int cnt = 0;
        for (int i = 10000 ; i <= 99999 ; i++) {
            if (i >= A && i <= B) {
                int [] a = new int[5];
                int n = i;
                a[0] = n %10;
                n /= 10;
                a[1] = n %10;
                n /= 10;
                a[2] =n %10;
                n /= 10;
                a[3] = n %10;
                n /= 10;
                a[4] = n %10;
                if (a[0] == a[4] && a[1] == a[3]) {
                     cnt++;
                }
            }
        }
        System.out.println(cnt);
    }

}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main(){
  double a;
  string s;
  cin >> a >> s;
  for(int i = 0; i < s.size(); i++) a = (a * 10) + (s[i] - '0');
  int ve = (int)sqrt(a);
  printf("%s\n", (ve * ve == (int)a) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}



int dp[200001];

int rs(int a,int b,int m)
{
  int an=1;
  while(b>0)
  {
    if(b%2!=0) an = (a%m*an%m)%m;
    b/=2;
    a = (a%m *a%m)%m;
  }
  return an;
}

void solve()
{
 
string s;
cin >> s;

int n = sz(s),vl=2019;

for(int j=n-1;j>=0;j--)
{
  int bs = rs(10,n-1-j,vl);

  dp[j] = dp[j+1]+ ((s[j]-'0')%vl*bs%vl)%vl;
  dp[j]%=vl;
}

int an=0;
map<int,int>mp;
mp[0]=1;
for(int j=n-1;j>=0;j--)
{
  an+=mp[dp[j]];
  mp[dp[j]]++;
}
// forf(j,0,n) cout<<dp[j]<<" ";
// cout<<endl;
cout<<an<<endl;
}

int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }


Measured memory_bytes: 5272
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int a[4];
    cin>>s;
    for(int i=0;i<4;i++){
        a[i]=s[i]-'0';
    }
    if(a[0]*10+a[1]<=12&&a[0]*10+a[1]){
        if(a[2]*10+a[3]<=12&&a[2]*10+a[3]){
            cout <<"AMBIGUOUS"<<endl;
        }
        else{
            cout << "MMYY"<<endl;
        }
    }
    else{
        if(a[2]*10+a[3]<=12&&a[2]*10+a[3]){
            cout <<"YYMM"<<endl;
        }
        else{
            cout << "NA"<<endl;
        }
    }
    return 0;
}



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

int N, a[109];
int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    sort(a, a + N, greater<int>());
    int ret = 0;
    for(int i = 0; i < N; i++) ret += a[i] * (i & 1 ? -1 : 1);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
SC = [lr() for _ in range(M)]
for x in range(1000):
    x = str(x)
    if len(x) != N:
        continue
    bl = True
    for s, c in SC:
        s -= 1
        c = str(c)
        if x[s] != c:
            bl = False; break
    if bl:
        print(''.join(x)); exit()

print(-1)


Measured memory_bytes: 38256
#!/usr/bin/env ruby

D = gets.chomp.to_i
C = gets.chomp.split.map(&:to_i)

S = []

D.times do |i|
  S[i] = gets.chomp.split.map(&:to_i)
end

T = []

D.times do |i|
  T[i] = gets.chomp.to_i - 1
end

score = 0
last_days = Array.new(26, 0)

T.each.with_index(1) do |t, day|
  score += S[day-1][t]

  last_days[t] = day

  last_days.each_with_index do |last_day, i|
    score -= C[i] * (day - last_day)
  end

  puts score
end


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

void Ins(int* a, int n);

int main(void){
	int n;
	int a[200];
	cin >> n;

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


	for(int i=0; i<n; i++){
		if(i!=n-1)printf("%d ", a[i]);
		else printf("%d\n", a[i]);
	}
	Ins(a, n);


	return 0;
}


void Ins(int* a, int n){
	for(int i=1; i<n; i++){
		int key = a[i];
		int j = i-1;
		while(j>=0 && a[j] > key){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;

		for(int i=0; i<n; i++){
			if(i!=n-1)printf("%d ", a[i]);
			else printf("%d\n", a[i]);
		}
	}
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}

int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
ll n,x,m;
cin>>n>>x>>m;
ll val=0;
ll ar[100011];
memset(ar,-1,sizeof(ar));
vector<ll>vi;
while(ar[x]==-1)
{
	vi.pb(x);
	ar[x]=val;
	val++;
	x=pows(x,2,m);
}
ll tot=0;
for(ll i=0;i<val;i++)
{
tot+=vi[i];	
}
if(n<=val)
{
	ll df=0;
	for(ll i=0;i<n;i++)
	{
		df=df+vi[i];
	}
	cout<<df<<endl;
	return 0;
}
ll rep=val-ar[x];
ll c=n-val;
ll rem=c/rep;
ll mde=c%rep;
ll sum=0;
for(ll i=ar[x];i<vi.size();i++)
{
	sum=sum+vi[i];
}
ll dl=0;
for(ll i=0;i<mde;i++)
{
	dl=dl+vi[i+ar[x]];
}
ll ans=tot+(sum*rem)+(dl);
cout<<ans<<endl;
}



 

Measured memory_bytes: 4680
// abc149_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif
    
    int A, B;
    cin >> A >> B;
    int ans = (A-1)*(B-1);
    print(ans);

    return 0;
}


Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
	let xs = input.trim().split(' ').map(v=>parseInt(v,10));
    let A = xs[0] * xs[1];
    let B = xs[2] * xs[3];
    
    if(A >= B){
       console.log(A);
    }else if(A <= B){
       console.log(B);
    }
    
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    vector<ll> a(3);
    rep(i,3)cin>>a[i];
    sort(all(a));

    ll count=0;
    while(a[2]!=a[1])
    {
        a[1]++;
        a[0]++;
        count++;
    }
    while(a[2] - a[0] > 2){a[0]+=2;count++;}
    if(a[2]-a[0]==2){a[0]+=2;count++;}
    else if(a[2]-a[0]==1){
        a[2]++;a[1]++;a[0]+=2;
        count+=2;
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
alist = []
for _ in range(5):
    alist.append(int(input()))


#%%
# n, alist = 5, [3, 2, 4, 3, 5]


#%%
if n <= min(alist):
    print(5)
else:
    print((n-1)//min(alist)+5)

Measured memory_bytes: 2940
H, W, K = map(int, input().split())
lp = []
for i in range(pow(2, W-1)):
    if not(any((i >> j) & (i >> (j+1)) for j in range(W))):
        lp.append(i)
llp = len(lp)
d = [0] * W
for n in range(W):
    d[n] = len(list(filter(lambda x: (x >> n) & 1, lp)))

p =  1000000007
def gf_inv(n):
    return pow(n, p - 2, p)

dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for h in range(1, H + 1):
    for w in range(W):
        if w == 0:
            dp[h][w] = dp[h-1][w] * (llp - d[w])
            if W != 1:
                dp[h][w] += dp[h-1][w+1] * d[w]
        elif w == W - 1:
            dp[h][w] = dp[h-1][w] * (llp - d[w-1]) + dp[h-1][w-1] * d[w-1]
        else:
            dp[h][w] = (
                    dp[h-1][w] * (llp - d[w-1] - d[w]) +
                    dp[h-1][w-1] * d[w-1] +
                    dp[h-1][w+1] * d[w]
            )
        dp[h][w] %= p
print(dp[H][K-1])

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

typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 200005

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int i,n,k,a[N];
	cin>>n>>k;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,greater<int>());
	int sum=0;
	for(i=0;i<k;i++)
		sum+=a[i];

	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,w,h,tree[128][128],i,j,k,l,maxt,t,dw,dh,cal[128][128];
	while(1){
		scanf("%d",&n);
		if(!n)break;
		maxt=0;w=0;h=0;
		for(i=0;i<128;i++)for(j=0;j<128;j++)tree[i][j]=0;
		scanf("%d %d",&w,&h);
		while(n--){
			scanf("%d %d",&i,&j);
			tree[i][j]=1;
		}
		scanf("%d %d",&dw,&dh);
		for(i=1;i<=w-dw+1;i++){
			for(j=1;j<=h-dh+1;j++){
				t=0;
				for(k=i;k<=i+dw-1;k++){
					for(l=j;l<=j+dh-1;l++){
						if(tree[k][l])t++;
					}
				}
				if(t>maxt)maxt=t;
			}
		}
		printf("%d\n",maxt);
	}
	return 0;
}

Measured memory_bytes: 1092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int a=sc.nextInt();
		int cnt=0;
		for(int i=0; i<4; i++) {
			if(a%10==2) {
				cnt++;
			}
			a/=10;
		}
		System.out.println(cnt);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    int n;
    cin >> n;
    int T;
    cin >> T;
    vector<pair<int,int>> p;
    for(int i = 0; i < n; i++){
        int c,t;
        cin >> c >> t;
        p.emplace_back(make_pair(c,t));
    }
    sort(p.begin(),p.end());
    for(int i = 0; i < n; i++){
        if(p[i].second <= T){
            cout << p[i].first << endl;
            return 0;
        }
    }
    cout << "TLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, d;
int s;

int main(void) {
    scanf("%d", &n);
    d=n;
    while(n) {
        s += (n%10);
        n/=10;
    }

    if(d%s) printf("No");
    else printf("Yes");

    return 0;
}


Measured memory_bytes: 128
using System;

class Program
{
	static void Main(string[] args)
	{
		var money = int.Parse(Console.ReadLine());
		var cakePrice = int.Parse(Console.ReadLine());
		var doughnutPrice = int.Parse(Console.ReadLine());

		var rest = (money - cakePrice) % doughnutPrice;
		Console.WriteLine(rest);
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int max = (n - 1) * (n - 2) / 2;
    if (k > max) {
        cout << "-1" << endl;
    }
    else {
        int reduce = max - k;
        cout << reduce + n - 1 << endl;
        for (int i = 2; i <= n; i++) {
            cout << 1 << " " << i << endl;
        }
        int first = 2;
        int second = 3;
        while (reduce) {
            cout << first <<  " " << second << endl;
            if (second == n) {
                first++;
                second = first + 1;
            }
            else {
                second++;
            }
            reduce--;
        }

    }
    return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0001&lang=jp
 *
 *
 */
class Main{
    public static void main(String[] a) throws IOException{

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

        	int[] data = new int[10];
        	for (int i=0; i<data.length; i++) {
        		String line = br.readLine();
        		int value = Integer.parseInt(line);
        		data[i] = value;
        	}

        	Arrays.sort(data);

        	System.out.println(data[9]);
        	System.out.println(data[8]);
        	System.out.println(data[7]);

        }

    }

}

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

int main(void){
    ll n,a,b;
    cin >> n >> a >> b;
    
    ll t = n/(a+b);
    ll plus = n-t*(a+b);
    if(plus>a) plus = a;

    cout << t*a + plus << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int X,Y;
    scanf("%d",&X);
    scanf("%d",&Y);
    int ans = 0;
    if( (X+Y) % 3 != 0){
        cout << 0 << endl;
    }
    else{
        int k = (X+Y)/3;
        int l = X - k;

        COMinit();
        int ans = COM(k,l);
        printf("%d\n",ans);
     //   cout << ans << endl;
    }
}



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

constexpr double EPS = 1e-10;
typedef complex<double> Point;
typedef Point Vector;
typedef pair<Point, Point> Segment;
typedef Segment Line;
typedef pair<Point, double> Circle;
typedef vector<Point> Polygon;
double dot(Vector a, Vector b){
	return real(a) * real(b) + imag(a) * imag(b);
}
double cross(Vector a, Vector b){
	return real(a) * imag(b) - imag(a) * real(b);
}
Point project(Line l, Point p){
	Vector base = l.second - l.first;
	base /= abs(base);
	double r = dot(p - l.first, base);
	return l.first + r * base;
}
Point reflect(Line l, Point p){
	return p + (project(l, p) - p) * 2.0;
}
int ccw(Point p0, Point p1, Point p2){
	Vector v = p1 - p0, w = p2 - p0;
	if(cross(v, w) > EPS) return 1; // COUNTER_CLOCKWISE
	if(cross(v, w) < -EPS) return -1; // CLOCKWISE
	if(dot(v, w) < -EPS) return 2; // ONLINE p2 - p0 - p1
	if(norm(v) + EPS < norm(w)) return -2; // ONLINE p0 - p1 - p2
	return 0; // ONLINE p0 - p1 - p2
}
bool isOrthogonal(Vector v1, Vector v2){
	double t = abs(dot(v1, v2));
	return t <= EPS;
}
bool isParallel(Vector v1, Vector v2){
	double t = abs(cross(v1, v2));
	return t <= EPS;
}
bool intersect(Segment s1, Segment s2){
	int t = ccw(s1.first, s1.second, s2.first) * ccw(s1.first, s1.second, s2.second);
	int u = ccw(s2.first, s2.second, s1.first) * ccw(s2.first, s2.second, s1.second);
	return (t == 0 || t == -1 || t == -4) && (u == 0 || u == -1 || u == -4);
}
Point getCrossPoint(Segment s1, Segment s2){
	assert(intersect(s1, s2));
	assert(!isParallel(s1.second - s1.first, s2.second - s2.first));
	Vector base = s2.second - s2.first;
	double d1 = abs(cross(base, s2.first - s1.first));
	double d2 = abs(cross(base, s2.first - s1.second));
	return s1.first + (s1.second - s1.first) * d1 / (d1 + d2);
}
double getDistancePL(Point p, Line l){
	return abs(cross(p - l.first, l.second - l.first)) / abs(l.second - l.first);
}
double getDistancePS(Point p, Segment s){
	if(dot(s.second - s.first, p - s.first) < 0.0) return abs(p - s.first);
	if(dot(s.first - s.second, p - s.second) < 0.0) return abs(p - s.second);
	return getDistancePL(p, Line(s));
}
double getDistanceSS(Segment s1, Segment s2){
	if(intersect(s1, s2)) return 0.0;
	return min({getDistancePS(s2.first, s1), getDistancePS(s2.second, s1), getDistancePS(s1.first, s2), getDistancePS(s1.second, s2)});
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int q;
	cin >> q;
	while(q--){
		double x[4], y[4];
		for(int i=0; i<4; ++i) cin >> x[i] >> y[i];
		Point p0(x[0], y[0]), p1(x[1], y[1]), p2(x[2], y[2]), p3(x[3], y[3]);
		cout << setprecision(14) << getDistanceSS(Segment(p0, p1), Segment(p2, p3)) << "\n";
	}
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(N, 0);
    vector<bool> ACed(N, false);
    int ac = 0, wa = 0;
    for (int i = 0; i < M; i++)
    {
        int p;
        string s;
        cin >> p >> s;
        if (ACed[p])
            continue;
        if (s == "AC")
        {
            ACed[p] = true;
            ac++;
            wa += a[p];
        }
        else if (s == "WA")
            a[p]++;
    }
    cout << ac << " " << wa << endl;
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    cin >> n;
    if (n % 10 == 1)
        n += 8;
    else if (n % 10 == 9)
        n -= 8;

    if ((n / 10) % 10 == 1)
        n += 80;
    else if ((n / 10) % 10 == 9)
        n -= 80;

    if ((n / 100) % 10 == 1)
        n += 800;
    else if ((n / 100) % 10 == 9)
        n -= 800;

    cout << n << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,x,count;
  

  while(1){
  cin >> n >> x;
  if(n==0 && x==0)break;

  count=0;
  for(int i=1;i<n+1;i++){
    for(int j=i+1;j<n+1;j++){
      for(int k=j+1;k<n+1;k++){
	if(x==i+j+k){
	  count++;
	  //	  cout << i << " " << j << " " <<  k << endl ;
	}
      }
    }
  }
  
  cout << count << endl ; 
  }
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

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

    bool flag = false;
    int idx;
    REP(i, s.size()) {
        if(s[i] == 'C') {
            flag = true;
            idx = i;
            break;
        } 
    }

    if(flag) {
        REPN(i, idx, s.size()) {
            if(s[i] == 'F') {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
 
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
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;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

ll dp[201][100001];

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;
    int N, X;
    cin >> N >> X;
    vector<int> S(N);
    REP(i, N) {
        cin >> S[i];
    }
    SORT(S);
    REVERSE(S);
    dp[0][X] = 1;
    REP(i, N) {
        REP(j, 100001) {
            dp[i + 1][j % S[i]] += dp[i][j];
            dp[i + 1][j % S[i]] %= MOD;
            dp[i + 1][j] += dp[i][j] * (N - i - 1);
            dp[i + 1][j] %= MOD;
        }
    }
    ll res = 0;
    REP(j, 100001) {
        res += dp[N][j] * j;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 156544
/*
Written by Kabir Kanha Arora
@kabirkanha
 */

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] factors = new long[N + 1];
        for (int i = 1; i <= N; ++i) {
            for (int j = i; j <= N; j += i) {
                factors[j]++;
            }
        }
        long sum = 0;
        for (int i = 1; i <= N; ++i) {
            sum += (i * factors[i]);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 116184
#!/usr/bin/env python3
H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]

# yoko
for i in range(H):
    for j in range(W-1):
        if (M[i][j] == '#' or M[i][j] == 'M') and (M[i][j+1] == '#' or M[i][j+1] == 'M'):
            M[i][j] = 'M'
            M[i][j+1] = 'M'

#tate
for j in range(W):
    for i in range(H-1):
        if (M[i][j] == '#' or M[i][j] == 'M') and (M[i+1][j] == '#' or M[i+1][j] == 'M'):
            M[i][j] = 'M'
            M[i+1][j] = 'M'

ret = 0
for m in M:
    ret += m.count('#')

if ret == 0: print('Yes')
else: print('No')


Measured memory_bytes: 9248
n, m = map(int,input().split())
a = [int(i) for i in input().split()]+[-1]
b = [int(i) for i in input().split()]+[-1]
a.sort(reverse=True)
b.sort(reverse=True)
mod = 10**9+7

if not len(a) == len(set(a)) or not len(b) == len(set(b)):
    print(0)
    exit()

na = 0
nb = 0
ans = 1
for i in range(n*m):
    if a[na] == n*m-i and b[nb] == n*m-i:
        na += 1
        nb += 1
    elif a[na] == n*m-i:
        na += 1
        ans = ans*nb%mod
    elif b[nb] == n*m-i:
        nb += 1
        ans = ans*na%mod
    else:
        ans = ans*max(0,na*nb-i)%mod

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 2e5 + 10;
string arr[MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int cnt = 0;
    for(int i = 0; i < n; i ++) {
        if(i == 0 || arr[i] != arr[i - 1]) {
            cnt ++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 9892
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    COMinit();
    int N;
    cin >> N;
    vector<ll> x(N);
    rep(i,N)cin >> x[i];
    ll p = 1LL;

    for(ll i = 1;i<N;i++){
        p*=i;
        p%=mod;
    }
    ll ans = 0;
    
    ll tm = 0;

    for(int i=0;i<N-1;i++){
        ll diff = x[i+1] - x[i];
        //tm += comb.inv(i + 1LL);
        tm += inv[i+1];
        tm %= mod;
        ans += diff * tm;
        ans %= mod;
    }
    cout << (ans*p)%mod << endl;
}

Measured memory_bytes: 13056
#include <iostream>
#include <iomanip>

int main(int argc, const char * argv[]) {
    int a, b;
    std::cin >> a >> b;
    int d = a / b;
    int r = a % b;
    double f = (double)a / b;
    std::cout << d << " " << r << " " << std::fixed << f << std::endl;
    return 0;
}

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

int main(){
    int N; cin >> N;
    cout << N * (N - 1) / 2 - N / 2 << endl;

    if(N % 2 == 0){
        for(int i = 1; i < N; i++){
            for(int j = i + 1; j <= N; j++){
                if(i + j == N + 1) continue;

                cout << i << " " << j << endl;
            }
        }
    }else{
        for(int i = 1; i < N; i++){
            for(int j = i + 1; j <= N; j++){
                if(i + j == N) continue;

                cout << i << " " << j << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	while(1){
		int n,y=0,Max=0,flag = 0;
		char s[100][51]={},q[100][51]={};
		cin >> n;
		if(n==0)	break;
		for(int i=0;i<n;i++){
			cin >> s[i];
			y = 0;
			for(int x=0;x<51;x++){
				if(y==0){
					q[i][y] = s[i][0];
					y++;
				}
				if(s[i][x]=='a'||s[i][x]=='i'||s[i][x]=='u'||s[i][x]=='e'||s[i][x]=='o'){
					q[i][y] = s[i][x+1];
					y++;
					flag = 1;
				}
				if(flag == 0)	q[i][1]=='\0';
			}
		}
		for(int x=0;x<n;x++){
			for(int y=0;y<n;y++){
				if(x!=y){
					for(int i=0;i<51;i++){
						if(strncmp(q[x],q[y],i)==0){
							if(Max<i)	Max = i;
						}
					}
				}
			}
		}
		if(Max == 50){
			cout << "-1\n";
		}
		else{
			cout << Max+1 << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3020
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N,num[30000],oneSize=0,tenSize=0,sum=0;
	bool one[10]={0},ten[100]={0},hun[1000]={0};
	vector<int> One,Ten;
	string S;
	
	cin>>N>>S;
	for(int i=0;i<N;i++)num[i]=S[i]-'0';
	for(int i=0;i<N;i++){
		for(int j=0;j<tenSize;j++){
			if(!hun[10*Ten[j]+num[i]]){
				hun[10*Ten[j]+num[i]]=true;
				sum++;
			}
		}
		for(int j=0;j<oneSize;j++){
			if(!ten[10*One[j]+num[i]]){
				ten[10*One[j]+num[i]]=true;
				Ten.push_back(10*One[j]+num[i]);
				tenSize++;
			}
		}
		if(!one[num[i]]){
			one[num[i]]=true;
			One.push_back(num[i]);
			oneSize++;
		}
	}
	cout<<sum;
	return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;            typedef vector<ll> vl;
typedef vector<vi> vvi;         typedef vector<vl> vvl;
typedef pair<int, int>     pii;    typedef pair<ll, ll> pll;
typedef vector<pii> vii;         typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 998244353
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
    while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
    vector<int> dp(100, 0);
    for(int i = 1; i*(i+1)<200; i++)
        dp[(i*(i+1))/2]++;
    for(int i = 1; i<100; i++)
        dp[i] += dp[i-1];
    ll n; cin>>n;
    ll ans = 0;
    for(ll i = 2; i*i<=n; i++){
        int cntr = 0;
        while(n%i==0)
            n = n/i, cntr++;
        ans = ans + dp[cntr];
    }
    if(n>1) ans = ans + 1;
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef KARAN
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    // init();
    int t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 3652
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean yes = true;
		if(S.equals("AAA") || S.equals("BBB")) yes = false;
		if(yes) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}




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

namespace AtcoderSubmit
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a = line[0];
            var b = line[1];
            var result = default(string);
            if(a % k == 0) {
                result = "OK";
            }
            else {
                result = (b - a + a % k >= k) ? "OK" : "NG";
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28216
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		String S = in.nextLine();

		int ans = 0;
		int left = 0;
		int right = S.length() - 1;

		while(left < right) {
			if(S.charAt(left) == S.charAt(right)) {
				left++;
				right--;
			}else {
				if(S.charAt(left) == 'x') {
					ans++;
					left++;
				}else if(S.charAt(right) == 'x'){
					ans++;
					right--;
				}else {
					ans = -1;
					break;
				}
			}
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 27340
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  
  string s;
  cin>>s;
  if(s=="ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
  
  return 0;
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys


def solve(N: int, L: int):

    taste = []
    taste_abs = []

    for i in range(1, N + 1):
        taste.append(L + i - 1)
        taste_abs.append(abs(L + i - 1))

    idx_delete = taste_abs.index(min(taste_abs))
    taste.pop(idx_delete)
    result = sum(taste)

    print(result)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    solve(N, L)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);

	if(a<b)
		printf("a < b\n");

	else if(a>b)
		printf("a > b\n");

    else
		printf("a == b\n");

	return 0;
}



Measured memory_bytes: 2140
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<usize> = (0..n).map(|_| sc.read()).collect();
    let mut b: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    let mut ans = 0;
    for k in (0..30).rev() {
        ans *= 2;
        let t = 1 << k;
        let t2 = t * 2;
        let t2m = t2 - 1;
        b.sort_by_key(|&bi| bi & t2m);

        let mut ans_i = 0;
        for &a in &a {
            let a = a & t2m;
            let s1 = b.binary_search_by_key(&(1 * t * 2 - 1), |&b| ((b & t2m) + a) * 2).err().unwrap();
            let s2 = b.binary_search_by_key(&(2 * t * 2 - 1), |&b| ((b & t2m) + a) * 2).err().unwrap();
            let s3 = b.binary_search_by_key(&(3 * t * 2 - 1), |&b| ((b & t2m) + a) * 2).err().unwrap();

            let q = n - s3 + s2 - s1;
            ans_i = ans_i ^ (q % 2);
        }
        ans += ans_i;
    }

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

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
        where
            T: std::str::FromStr,
            T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 11640
#include <bits/stdc++.h>
using namespace std;
#define rep(n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for (int i=0;i<(n);i++)
#define rep3(i,a,b) for (int i=a;i<(b);i++)
#define out(ans) cout << ans << endl;
#define outs(ans) cout << ans;
using ll = long long;

int main(){

    //imput n, a(n), b(n)
    int n;
    cin >> n;
    vector <string> s(n);
    rep(n){ cin >> s[i]; }

    //main process
    int ac=0,wa=0,tle=0,re=0;
    rep(n){
        if(s[i]=="AC"){
            ac++;
        }else if(s[i]=="WA"){
            wa++;
        }else if(s[i]=="TLE"){
            tle++;
        }else if(s[i]=="RE"){
            re++;
        }
    }
    out("AC x "<<ac)
    out("WA x "<<wa)
    out("TLE x "<<tle)
    outs("RE x "<<re)

    return 0;
}










    /*
    Editer: hybs
    Lang: C++
    */


Measured memory_bytes: 6356
N = int(input())
A = list(map(int, input().split()))

while True:
    A.sort()
    t = sum(A)
    for i in range(1, N):
        if A[i] % A[0] == 0:
            A[i] = A[0]
        else:
            A[i] = A[i] % A[0]
    if sum(A) == t:
        break
print(A[0])


Measured memory_bytes: 14252
use proconio::input;
use std::cmp::{max, min};

const MAX_L: usize = 100_000;
const BASE_SIZE: usize = 1 << 10;

fn main() {
    input! {
        n: usize,
        vw: [(u32, usize); n],
        q: usize,
        vl: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for vlq in vl {
        println!("{}", calc(&vw, vlq.0 - 1, vlq.1, &dp));
    }
}

fn make_dp(vw: &Vec<(u32, usize)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push(
        (0..=MAX_L)
        .map(|i| if i < vw[0].1 { 0 } else { vw[0].0 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1;
                let v = if i < w { 0 } else { dp[p][i - w] + vw[c].0 };
                max(dp[p][i], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    vw: &Vec<(u32, usize)>,
    u: usize, 
    l: usize,
    dp: &Vec<Vec<u32>>
) -> u32 {
    if u < dp.len() {
        dp[u][l]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1;
        let pv1 = calc(vw, p, l, dp);
        let pv2 = if l < w { 0 } else { calc(vw, p, l - w, dp) + vw[u].0 };
        max(pv1, pv2)
    }
}


Measured memory_bytes: 413116
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200005)
#define MOD (1000000000l + 7l)
#define OO (1050000000)
#define OOL (1100000000000000000)

//global
int a[N];

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n;
	cin >> n;
	n *= 2;
	rep(i,0,n){
		cin >> a[i];
	}
	sort(a,a+n);
	int ans = 0;
	rep(i,0,n){
		if(i%2 == 0) ans += a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
def main(argv)
	n = gets.chomp.to_i
  
  a = [0] * n
	n.times{|i| a[i] = gets.chomp.to_i}
  
  max_1 = a.max
  cnt_1 = a.count(max_1)
  
  b = a.dup
  b.delete(max_1)
  max_2 = b.size == 0 ? -1 : b.max
  cnt_2 = b.size == 0 ? -1 : b.count(max_2)
  
  n.times do |i|
    if cnt_1 == 1 then
      puts ((a[i] == max_1) ? max_2 : max_1).to_s
    else
      puts max_1.to_s
    end
  end
end

if self.to_s === 'main'
	main(ARGV)
end

Measured memory_bytes: 6268
n = int(input())
a = list(map(int,input().split()))
ans = 1
b = 0
for i in range(n):
    if a[i] == 0:
        b = 1
        print(0)
if b == 0:
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

Measured memory_bytes: 21696
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef long double     ld;
typedef string          str;
#define all(x)			(x).begin(),(x).end()
#define Sort(x)			sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define endl            '\n'
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MAX1 = 2e5 + 7;

ll a, b, c, T, d, e, l, r, x, y, z, mid, cnt, flag, mod = 1e9+7, num[MAX1];
string s, t;
vector <ll> vec;

int main(){
	fast_io;
	cin >> a;
	cout << fixed << setprecision(7) << 1.0*((a+1)/2)/a;
    return 0;
}
/*                          now or never                         */


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
	
	int A[N], B[N], C[N-1]; F0R(i, N) cin>>A[i];
	
	F0R(i, N) cin >> B[i];
	
	F0R(i, N-1) cin >> C[i];
	
	int ans = 0; F0R(i, N) ans += B[i];
	
	FOR(i, 1, N) if (A[i] - 1 == A[i-1]) ans += C[A[i-1]-1];
	
	cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256