akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;
    
int main()
{
    string S, T, U;
    ll A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (U == S) {
        A -= 1;
    }
    else if (U == T) {
        B -= 1;
    }
    cout << A << ' ' << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
        using namespace  std;
        int main(){         
          long long  A,B;
          cin>>A>>B;
  			for(int i=A;i>=1;--i){
            if(A%i==0 && B%i==0){
              cout<<A*B/i; break;
            }
            }        
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i++)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a,b;
  cin >> a >> b;
  int ct = 0;
  int now = a;
  
  while(now <= b){
    ct++;
    now *= 2;
  }
  
  cout << ct << endl;
}


Measured memory_bytes: 256
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


n, p = map(int,input().split())
a = list(map(int,input().split()))

even=0
odd=0
for i in a:
    if i%2 == 0:
        even+=1
    else:
        odd+=1
ans = 0
if p == 0:
    evens = 0
    i = 1
    while(i <= even):
        evens += cmb(even, i)

        i+=1

    ans += 1<<even
    i = 2
    while(i <= odd):
        ans += cmb(odd, i) + cmb(odd, i)*evens
        i+=2

    print(ans)

else:
    evens = 0
    i = 1
    while(i <= even):
        evens += cmb(even, i)

        i+=1

    i = 1
    while(i <= odd):
        ans += cmb(odd, i) + cmb(odd, i)*evens

        i+=2
    print(ans)

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main()
    {
        string N = Console.ReadLine();
        string A = Console.ReadLine();
        string[] a = (A.Split(' '));
        double[] an = new double[Convert.ToInt32(N)];
        double count = 0;

        for (int i = 0; i < Convert.ToDouble(N); i++)
        {
            an[i] = Convert.ToInt32(a[i]);
        }

        for (int i = 0; i < Convert.ToDouble(N)-1; i++)
        {
            if (an[i]>an[i+1])
            {
                count += an[i] - an[i + 1];
                an[i + 1] = an[i];
            }
        }

        Console.WriteLine(count);

    }
}

Measured memory_bytes: 43308
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    ll A[N];
    ll sum;
    int ans=0;
    bool dive=true;
    rep(i,N) {
        cin >> A[i];
        if(A[i]%2==1){
            dive=false;
        }
    }
    while(dive){
        sum=0;
        for(int i=0; i<N; i++){
            A[i]=A[i]/2;
            sum+=A[i];
            if(A[i]%2==1){
                dive=false;
            }
        }
        ans++;
        /*
        if(sum==0){
            dive=false;
        }
        cout << sum << endl;
        */
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

ll N,K;
ll ans;

int main() {
	ans = 0;

	cin >> N>> K;

	for (ll b = K + 1; b <= N; b++) {
		for (ll i = 0; (i*b) + K <= N;i++) {
			if (i*b + K == 0) {
				//a=0を除外
				ans += (i + 1)*b - (i * b + K + 1);
			}
			else if ((i+1)*b - 1 <= N) {
				ans += (i + 1)*b - (i * b + K);
			}
			else {
				ans += N - (i * b + K) + 1;
			}
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,v,b,w,t;
    cin >>a>> v>>b>>w>>t;
    long long x = abs(a-b);
    x-= (v-w)*t;
    string ans;
    if(x <=0)
    {
        ans ="YES";
    }
    else if(x>0)
    {
        ans ="NO";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    ll x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> ps(a), qs(b), rs(c);
    rep(i, a) cin>>ps[i];
    rep(i, b) cin>>qs[i];
    rep(i, c) cin>>rs[i];

    sort(ps.begin(), ps.end());
    sort(qs.begin(), qs.end());
    sort(rs.begin(), rs.end());
    reverse(ps.begin(), ps.end());
    reverse(qs.begin(), qs.end());
    reverse(rs.begin(), rs.end());

    priority_queue<ll, vector<ll>, greater<ll>> q;
    rep(i, x) q.push(ps[i]);
    rep(i, y) q.push(qs[i]);
    rep(i, c) {
        if (rs[i] > q.top()) {
            q.pop();
            q.push(rs[i]);
        }
        else break;
    }
    ll ans = 0;
    rep(i, x + y) {
        ans += q.top(); q.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4852
fun main(args: Array<String>) {
    val ans = solve()
    if (ans == null) {
        println(-1)
    } else {
        for (edge in ans!!) {
            println("${edge.first} ${edge.second}")
        }
    }
}

fun solve(): List<Pair<Int, Int>>? {
    val input = readLine()!!
    val n = input.length
    val bits = ("0" + input).map { it == '1' }.toBooleanArray()
    if (bits[n]) return null
    if (!bits[1]) return null
    for (i in 1..(n - 1)) {
        if (bits[i] && !bits[n - i]) return null
    }

    val edges = mutableListOf<Pair<Int, Int>>()
    var prev = 0
    for (i in 2..(n - 1)) {
        if (bits[i]) {
            if (prev == 0) {
                for (j in 1..(i - 1)) {
                    edges.add(Pair(j, i))
                }
            } else {
                edges.add(Pair(prev, i))
                for (j in (prev + 1)..(i - 1)) {
                    edges.add(Pair(j, i))
                }
            }
            prev = i
        }
    }
    edges.add(Pair(n - 1, n))

    return edges
}

Measured memory_bytes: 57212
n,m=map(int,input().split())
a=[]
k=[]
while True:
    try:
        dk,*d=list(map(int,input().split()))
        a.append(d)
        k.append(dk)
    except:
        break;
ans=set(a[0])
for i in range(1,n):
  ans=ans&set(a[i])

print(len(ans))

Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>

int Solve(int , int , int);
int a[20];

int main(){
  int m[200],q,i,n,j;

  scanf("%d",&n);
  if(n < 1 || 20 < n)exit(0);
  for(i = 0; i < n;i++){
    scanf("%d",&a[i]);
    if(a[i] < 1 || 2000 < a[i])exit(0);
  }
  scanf("%d",&q);
  if(q < 1 || 200 < q)exit(0);
  for(i = 0; i < q; i++){
    scanf("%d",&m[i]);
    if(m[i] < 1 || 2000 < m[i])exit(0);
  }

  for(i = 0; i < q;i++){
      if(Solve(0,m[i],n) == 1)printf("yes\n");
      else printf("no\n");
  }
  return 0;
}

int Solve(int i,int m,int n){
  int res;
    
  if(m == 0)return 1;
  if(i >= n)return 0;
  
  res = Solve(i+1,m - a[i],n) || Solve(i+1,m,n);

  return res;
}



Measured memory_bytes: 2108
n,m=map(int,input().split())
a = list(map(int,input().split()))+[1000000001]
b = list(map(int,input().split()))+[1000000001]
andlis=[]
orlis=[]
cura=0
curb=0
for _ in range(n+m):
    if a[cura]>b[curb]:
        orlis.append(b[curb])
        curb+=1
    elif a[cura]==b[curb]:
        andlis.append(a[cura])
        cura+=1
    elif a[cura]<b[curb]:
        orlis.append(a[cura])
        cura+=1
print(len(andlis),len(orlis))
for i in andlis:
    print(i)
for i in orlis:
    print(i)


Measured memory_bytes: 27140
import sys


def read_input(trans=int):
    return list(map(trans, input().split()))


X, N = read_input()
if N == 0:
    print(X)
else:
    list_p = read_input()

    for i in range(N+1):
        if X-i not in list_p:
            print(X-i)
            sys.exit()

        if X+i not in list_p:
            print(X+i)
            sys.exit()


Measured memory_bytes: 9188
#include<iostream>
using namespace std;
long long int gcd(long long int a, long long int b);
long long int lcm(long long int a, long long int b); 
long long int baikan(long long int a, long long int b, long long int c);
int main() {

	//C
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << b - a + 1 - baikan(a, b, c) -  baikan(a, b, d) + baikan(a, b, lcm(c, d)) << endl;
	return 0;
	//B
	/*int n, l;
	cin >> n >> l;
	int k = n * l + n * (n - 1) / 2;
	//cout << k;
	int i;
	int min = l;
	for (i = 0; i < n; i++) {
		if (abs(l + i) < abs(min)) {
			min =  l + i;
		}
	}
	cout << k - min << endl;
	return 0;
	*/

	//A
	/*
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
	*/
}

long long int gcd(long long int a, long long int b) {
	if (a == 0) {
		return b;
	}
	else if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
long long int lcm(long long int a, long long int b) {
	return a * b / gcd(a, b);
}
long long int baikan(long long int a, long long int b, long long int c) {
	long long int d = b - a + 1;
	if (((b - (d % c)) % c) <= (b % c)) {
		return (d - (d % c)) / c;
	}
	else {
		return (d - (d % c)) / c + 1;
	}
}

Measured memory_bytes: 3604
#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 main() {
  int h,w,m;
  cin>>h>>w>>m;
  vector<P> bomber(m);
  vector<int> row(h+1),row2(h+1);
  vector<int> column(w+1),column2(w+1);
  rep(i,m) {
    int a,b;
    cin>>a>>b;
    bomber[i]=make_pair(a,b);
    row[a]++;
    column[b]++;
  }
  int tmp = 0;
  int ind = 0;
  rep(i,h+1) {
    if (tmp < row[i]) {
      ind = i;
      tmp = row[i];
    }
  }
  int tmp2=0;
  int ind2=0;

  rep(i,w+1) {
    if (tmp2 < column[i]) {
      ind2 = i;
      tmp2 = column[i];
    }
  }

  rep(i,m) {
      if (bomber[i].first!=ind) {
          column2[bomber[i].second]++;
      }
  }

  rep(i,m) {
      if (bomber[i].second!=ind2) {
          row2[bomber[i].first]++;
      }
  }


  int ans=0,ans2=0;
  sort(row.begin(), row.end());
  reverse(row.begin(),row.end());
  sort(column.begin(),column.end());
  reverse(column.begin(), column.end());
  sort(row2.begin(), row2.end());
  reverse(row2.begin(),row2.end());
  sort(column2.begin(),column2.end());
  reverse(column2.begin(), column2.end());
  ans += row[0]+column2[0];
  ans2 += row2[0]+column[0];

  ans = max(ans,ans2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10308
from collections import defaultdict
N = int(input())
S = defaultdict(set)
march = 'MARCH'
for i in range(N):
    a = input()
    for j in range(5):
        if a[0] == march[j]:
            S[j].add(a)
sv = []
for i in S.values():
    sv.append(len(i))
if len(sv) < 3:
    print(0)
else:
    ans = 0
    for i in range(len(sv)-2):
        for j in range(i+1,len(sv)-1):
            for k in range(j+1,len(sv)):
                ans += sv[i]*sv[j]*sv[k]
    print(ans)

Measured memory_bytes: 14700
[n, k]= map(int, input().rstrip().split(" "))
ps = list(map(int, input().rstrip().split(" ")))

history = {}

top3 = []

result = 0

def calc_expect_sum(targets):
    return sum( (p+1) * 0.5 for p in targets)

prev_sum = calc_expect_sum(ps[0:0+k])
result = 0

if n == k:
    print(calc_expect_sum(ps))
else:
    for i in range(1,n-k+1):
        prev = ps[i-1]
        current = ps[i+k-1]
        diff = (current - prev) * 0.5
        new = prev_sum + diff
        if new > result:
            result = new
        prev_sum += diff
    
    print(result)




Measured memory_bytes: 69984
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int []a = new int[N];
    
    int ans = 0;
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      if(i % 2 == 0){
        if(a[i] % 2 !=0 ) {
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35568
#  --*-coding:utf-8-*--

MOD = 10**9 + 7

def getModInv(a, b):
    return 1 if (a == 1) else (1-b*getModInv(b%a, a))//a%b


N, K = map(int, input().split())
t1, t2 = 1,1
s1, s2 = 1,1

for m in range(1, min(K, N-1)+1):
    t1 = t1*(N-m)*(N-m+1)%MOD
    t2 = t2*m**2%MOD

    s1 = (s1*t2 + s2*t1)%MOD
    s2 = s2*t2%MOD

print(s1*getModInv(s2, MOD)%MOD)



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

using namespace std;

string f(int a, int b) {
    if (a * b & 1) {
        return "Odd";
    }
    return "Even";
}

int main() {

    int a;
    cin >> a;

    int b;
    cin >> b;

    string result = f(a, b);
    cout << result << endl;

    return 0;
}


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

typedef long long ll;
typedef pair<ll ,ll> pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll mod = 1000000009;
const ll INF = 1e18;//1*10^18

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int ReturnDigit(ll num)
{
  string number=to_string(num);
  return number.length();
}

ll rgbnum[5][5000];
int main() {
  ll i,j,k,l;
  ll n=0,ans=0;
  string s;
  cin >>n>>s; 

for(i=0; i<3; i++)
{
  for(j=0; j<4500; j++)
  {
    rgbnum[i][j]=0;
  }
}

  if(s[0]=='R')rgbnum[0][0]=1;
  if(s[0]=='G')rgbnum[1][0]=1;
  if(s[0]=='B')rgbnum[2][0]=1;

  for(i=1; i<n; i++)
  {
    for(j=0; j<3; j++)
    {
      rgbnum[j][i]=rgbnum[j][i-1];
    }

    if(s[i]=='R')
    {
      rgbnum[0][i]+=1;
    }else if(s[i]=='G')
    {
      rgbnum[1][i]+=1;
    }else
    {
      rgbnum[2][i]+=1;
    }

    // for(j=0; j<3; j++)
    // {
    //   cout<<j<<" "<<i<<" "<<rgbnum[j][i]<<endl;
    // }
    // cout<<endl;
  }

  for(i=0; i<n; i++)
  {
    for(j=i+1; j<n; j++)
    {
      if(s[i]!=s[j])
      {
        if(2*j-i<=n-1)
        {
              if(s[i]!='R' && s[j]!='R')
            {
              ans+=(rgbnum[0][2*j-i-1]-rgbnum[0][j])+(rgbnum[0][n-1]-rgbnum[0][2*j-i]);
            }else if (s[i]!='G' && s[j]!='G')
            {
              ans+=(rgbnum[1][2*j-i-1]-rgbnum[1][j])+(rgbnum[1][n-1]-rgbnum[1][2*j-i]);
            }else if(s[i]!='B' && s[i]!='B')
            {
              ans+=(rgbnum[2][2*j-i-1]-rgbnum[2][j])+(rgbnum[2][n-1]-rgbnum[2][2*j-i]);
            }
        }else
        {
          if(s[i]!='R' && s[j]!='R')
            {
              ans+=rgbnum[0][n-1]-rgbnum[0][j];
            }else if (s[i]!='G' && s[j]!='G')
            {
              ans+=rgbnum[1][n-1]-rgbnum[1][j];
            }else if(s[i]!='B' && s[i]!='B')
            {
              ans+=rgbnum[2][n-1]-rgbnum[2][j];
            }
        }
        
        
          
      }
      //  cout<<i<<' '<<j<<' '<<ans  <<endl;
    }
  }
  cout<<ans  <<endl;
}

Measured memory_bytes: 3748
#include <iostream>

int main()
{
  int A, B;
  std::cin >> A >> B;
  if (A>B) {
    int t = A; A = B; B = t;
  }
  for (int i=0; i<B; i++) std::cout << A;
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
int main()
{
	long long a, b,nowA,nowB,ans;
	cin >> a >> b;

        ans=a*b;
 
	nowA = a, nowB = b;
	
	for (long long i = 0; i < a*b; i++)
	{
		if (nowA == nowB)
		{
			ans = nowA;
			break;
		}
		else if (nowA < nowB)
			nowA += a;
		else
			nowB += b;
	}
	
	cout << ans << std::endl;
}

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

using namespace std;

int main(){
    while(true){
    int n;
    scanf("%d", &n);
    if(n==0) return 0;
    vector<int> a(n), b(n);
    for(int i=0;i<n;++i) scanf("%d %d", &a[i],&b[i]);
    int as=0, bs=0;
    for(int i=0;i<n;++i){
        if(a[i]>b[i])as+=a[i]+b[i];
        else if(a[i]<b[i])bs+=a[i]+b[i];
        else {as+=a[i];bs+=b[i];}
    }
    printf("%d %d\n", as,bs);
    }
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,a,b;
    cin >> n >> a >> b;
    vi x(n);
    cin >> x;
    ll ans = 0;
    rep(i,n-1) ans += min(ll(x[i+1]-x[i])*a,ll(b));
    cout << ans << endl;
}

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

A.sort(reverse=True)
cnt = 0
idx = 0
ans = []
while cnt < N:
    if idx == 0:
        ans.append(A[idx])
        cnt += 1
    else:
        ans.append(A[idx])
        ans.append(A[idx])
        cnt += 2
    idx += 1
print(sum(ans[:N-1]))


Measured memory_bytes: 103040
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	string s;
	cin >> s;
	int count=0;
	int ans=0;
	SREP(i,s){
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
			count++;
			ans=max(ans,count);
		}else{
			count=0;
		}
	}
	cout << ans << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define all(c) (c).begin(), (c).end()
#define rep( i, a, n ) for( int i=a; i<n; i++ )
#define repp( i, a, n, p ) for( int i=a; i<n; i+=p )
#define per( i, a, n ) for( int i=n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define acc accumulate

int main () {
    ll n, m;
    cin >> n >> m;

    vector <ll> v(m);
    rep (i, 0, m ) cin >> v[i];
    ll sum = acc ( all(v), 0.0 );
    n -= sum;
    if ( n <0)cout << "-1" << endl;
    else cout << n << endl;
}


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

int N;
int A[100010];

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

    bool flag = false;
    for(int i = 0; i < N; i++)if(A[i] % 2)flag = true;

    if(flag)cout << "first" << endl;
    else cout << "second" << endl;

    return 0;
}


Measured memory_bytes: 640
// Bismillahir Rahmanir Rahim
// AtCoder-Traveling Salesman around Lake

#include<bits/stdc++.h>
using namespace std;
long long Max = 0;
int main(){
	int k,n;  cin>>k>>n;
	int a[n+5];
	for(int i = 0 ; i < n; ++i)
	  cin>>a[i];
	  
	  Max = k-a[n-1]+a[0];
	  
	  for(int i = 0; i < n-1; ++i){
	  	if(Max < a[i+1]-a[i])
	  	 Max = a[i+1]-a[i];
	  }
	cout<<k-Max<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
s = []
for i in range(n):
    s.append(V[i]-C[i])
s.sort(reverse=True)
res = 0
for a in s:
    if a >= 0:
        res += a
print(res)


Measured memory_bytes: 3060
//g++  5.4.0

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<double> arr(n);
    for(int i = 0; i < n; i++) cin >> arr[i];
    
    //dp[i] --> probability that 'i' heads so far
    vector<double> dp(n+1,0);
    dp[0] = 1;
    
    for(int i = 0; i < n; i++){
        for(int j = i+1; j >= 0; j--){
            dp[j] = (n == 0 ? 0 : dp[j-1])*arr[i] + dp[j]*(1 - arr[i]); 
        }
    }
    
    double ans = 0.0;
    for(int i = 0; i <= n; i++){
        int tails = n - i;
        if(i > tails){
            ans += dp[i];
        }
    }
    
    printf("%.10lf\n",ans);
    
    
}

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



int main() {
	int n;
	cin >> n;
	int *m1,*m2;
	m1 = (int*)malloc(sizeof(int)*n);
	m2 = (int*)malloc(sizeof(int)*n);
	for (int i = 0; i < n; i++)
		cin >> m1[i];
	for (int i = 0; i < n; i++)
		cin >> m2[i];
	int mx = 0;
	for (int i = 0; i < n; i++)
	{
		int tmp = 0;
		for (int j = 0; j <= i; j++)
			tmp += m1[j];
		for (int j = i; j < n; j++)
			tmp += m2[j];
		if (mx < tmp)
			mx=tmp;
	}
	cout << mx << endl;
	return 0;
}


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

int main() {
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define G(x, i) get<i>(x)
#define BITL(x, i) ((x) << (i))
#define BITR(x, i) ((x) >> (i))

using namespace std;

typedef tuple<int, int> i2;
typedef tuple<int, int, int> i3;
typedef tuple<int, int, int, int> i4;
typedef vector<int> vi;
typedef vector<i2> vi2;
typedef vector<i3> vi3;
typedef vector<vi> v2i;
typedef long long ll;
typedef tuple<ll, ll> l2;
typedef tuple<ll, ll> l3;
typedef vector<ll> vl;
typedef vector<l2> vl2;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  deque<char> d;
  for (char c : s)
    d.push_back(c);
  int k = 0;
  while (q--) {
    int t;
    cin >> t;
    if (t == 2) {
      int x;
      char y;
      cin >> x >> y;
      if ((!k && x == 1) || (k && x == 2)) {
        d.push_front(y);
      } else {
        d.push_back(y);
      }
    } else
      k = (k + 1) % 2;
  }
  if (k)
    reverse(d.begin(), d.end());
  for (char c : d)
    cout << c;
  cout << endl;
  return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
int main(){
	int n;
	int a[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k]){
					continue;
				}
				if(a[i]+a[j]>a[k]){
					if(a[i]+a[k]>a[j]){
						if(a[j]+a[k]>a[i]){
							ans++;
						}
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3620
import java.util.*;

class Main{
    public Main(){
        Scanner SC = new Scanner(System.in);

        int N = Integer.parseInt(SC.next());
        int K = Integer.parseInt(SC.next());

        Set<Integer> set = new HashSet<Integer>();
        for(int i=0;i<K;i++){
            int d = Integer.parseInt(SC.next());
            for(int j=0;j<d;j++){
                set.add(Integer.parseInt(SC.next()));
            }
        }
        System.out.println(N-set.size());
    }

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


Measured memory_bytes: 41552
N,K=map(int,input().split())
# a<bのとき(N-k)+(N-k-1)+...+1
ct=(N-K)*(N-K+1)//2
if K==0:
    ct-=N
# a>bのときsum_b(N-K)//b ただしb=k+1~
for b in range(K+1,N+1):
    ct+=(b-K)*(N//b-1)+max(0,N%b-K+1)
print(ct)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl '\n'

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

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

#define abs asdsa

int64_t abs(int64_t x) { return x > 0 ? x : -x; }

int n;
pair<int64_t, int64_t> a[MAXN];
set<int> p;

void read()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i].first >> a[i].second;
		p.insert((abs(a[i].first) + abs(a[i].second)) % 2);	
	}
}

inline int b(int64_t x, int64_t p) { return (x >> p) & 1ll; }

void solve()
{
	if(p.size() != 1)
	{
		cout << -1 << endl;
		return;
	}

	vector<int64_t> d;
	vector<string> ans(n, "");
	if(b(a[0].first, 0) == b(a[0].second, 0))
	{
		d.push_back(1);
		for(int i = 0; i < n; i++)
		{
			a[i].first--;
			ans[i].push_back('R');
		}
	}

	int64_t pw = 1;
	for(int tms = 0; tms < 35; tms++, pw *= 2)
	{
		d.push_back(pw);
		for(int i = 0; i < n; i++)
		{
			if(a[i].first & 1)
			{
				if(b(a[i].first, 1) == b(a[i].second, 1))
				{
					a[i].first++;
					ans[i].push_back('L');
				}
				else
				{
					a[i].first--;
					ans[i].push_back('R');
				}
			}
			else
			{
				if(b(a[i].first, 1) == b(a[i].second, 1))
				{
					a[i].second++;
					ans[i].push_back('D');
				}
				else
				{
					a[i].second--;
					ans[i].push_back('U');
				}
			}

			a[i].first /= 2;
			a[i].second /= 2;
		}
	}

	d.push_back(pw);
	for(int i = 0; i < n; i++)
	{
		if(a[i].first == -1) ans[i].push_back('L');
		if(a[i].first == 1) ans[i].push_back('R');
		if(a[i].second == 1) ans[i].push_back('U');
		if(a[i].second == -1) ans[i].push_back('D');
	}

	cout << d.size() << endl;
	for(int64_t i: d) cout << i << " ";
	cout << endl;
	for(auto s: ans) cout << s << endl;
}

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

	read();
	solve();
	return 0;
}




Measured memory_bytes: 512
s = input()
num_C = 0

for i in range(len(s)):
    if i == 0:
        if s[i] != 'A':
            print('WA')
            exit() 
    elif i >= 2 and i <= len(s)-2:
        if s[i] == 'C': num_C += 1
    else:
        if ord(s[i]) < ord('a') or ord(s[i]) > ord('z'):
            print('WA')
            exit()
if num_C != 1:
    print('WA')
    exit()
print('AC')

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, x, y, t, xx, yy, tt, dx, dy, dt, i;

int main() {
scanf("%d", &n);
x = y = t = 0;
for (i=0;i<n;i++) {
	scanf("%d %d %d", &tt, &xx, &yy);
	dx = abs(xx - x);
	dy = abs(yy - y);
	dt = tt - t;
	if (dx + dy > dt)  {
		printf("No\n");
		return 0;
	}
	if ((dx + dy) % 2 != dt % 2) {
		printf("No\n");
		return 0;
	}
	x = xx;
	y = yy;
	t = tt;
}
printf("Yes\n");
return 0;
}



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

namespace CSharp_Shell
{

    public static class Program 
    {
        public static void Main() 
        {
           var a=Console.ReadLine();
           var b=Console.ReadLine();
           if(a.Length<b.Length){Console.WriteLine("LESS"); return;}
           if(a.Length>b.Length){Console.WriteLine("GREATER"); return;}
           
           for(var i=0; i<a.Length; i++)
           {
               if(a[i]<b[i]){Console.WriteLine("LESS"); return;}
               if(a[i]>b[i]){Console.WriteLine("GREATER"); return;}
           }
           
           Console.WriteLine("EQUAL");
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x; cin >> x;
    ll res = 100;
    int count = 0;
    while(res < x){
        res *= 1.01;
        count++;
    }
    cout << count << endl;

}

Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#define N 100


int main(void){
  int flag,A[N],i,j,n,v,count=0;

  scanf("%d",&n);

  for(j=0;j<n;j++){
    scanf("%d",&A[j]);
  }

  flag = 1;
  i = 0;
 
  flag = 0;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(A[j]<A[j-1]){   
	v=A[j];
	A[j]=A[j-1];
	A[j-1]=v;
	count++;
	flag = 1;
      }
    }
  }
    for(j=0;j<n-1;j++){
      printf("%d ",A[j]);
    }
    printf("%d", A[n-1]);
    printf("\n");
    printf("%d\n",count);

    return 0;
  }

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

int main(){
  int N, M;
  cin>>N>>M;
  vector<bool> finish(N+1);
  int point=0;
  int pena=0;
  vector<int> WAcount(N+1);
  for(int i=0; i<M; i++){
    int p;
    string s;
    cin>>p>>s;
    if(finish[p]==0){
      if(s=="WA"){
        WAcount[p]++;
      }
      if(s=="AC"){
        point++;
        pena+=WAcount[p];
        finish[p]=1;
      }
      } //0
  } //i
  cout<<point<<" "<<pena<<endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
    string s[105];
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < h; i++) {
		
		cout << s[i] << endl << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

bool memo[100000][11];//点、深さ
VV<> G(100000);
ll color[100000];

void dfs(ll p, ll dep, ll col){
    if(memo[p][dep]) return;
    memo[p][dep] = true;
    if(!dep){
		color[p] = col;
		return;
    }
    dfs(p, dep - 1, col);
    for(auto v:G[p]) dfs(v, dep - 1, col);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    REP(i, 100000)REP(j, 11) memo[i][j] = 0;
    ll n, m; cin >> n >> m;
    REP(i, m){
        ll a, b; cin >> a >> b; a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    ll q; cin >> q;
    V<> v(q), d(q), c(q);
    REP(i, q){
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    RREP(i, q){
        dfs(v[i], d[i], c[i]);
    }
    REP(i, n){
        cout << color[i] << endl;
    }
}

Measured memory_bytes: 13512
#include <iostream>
#include<algorithm>
#include<stdio.h>
#include<map>
#include<math.h>
#include<stdlib.h>
using namespace std;

int main() {
    
    string s;
    int n;
    
    cin >> s >> n;
    
    if(s.size() < n){
        
        cout << "";
        return 0;
        
    }
    
    string ans = "";
    
    for(int i = 0; i < s.size();i = i + n){
        
        ans = ans + s[i];
        
    }
    
    cout << ans<< endl;
}


Measured memory_bytes: 256
import Data.Array

main = do
  let f i = (i+3)*(i+2)*(i+1) `div` 6 - max (2*(i-9)*(i-8)*(i-7) `div` 3) 0 in
    let p = array (0,50) $ zip [0..50] $ [ f i | i <- [0..18]++[17,16..0]] ++ replicate 15 0 in
      let g x = show $ p!(read x::Int) in
        putStr . unlines . map g . lines =<< getContents

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>H>>W;
    vector<string> grid(H);
    rep(i,H) cin>>grid.at(i);
    vector<vector<int> > ve(H,vector<int>(W)), ho(H,vector<int>(W));
    //veは０～H-1文字目を見ていく
    rep(i,W){
        int temp = 0;
        int fromsave = 0;
        rep(j,H){
            if(grid.at(j).at(i) == '#'){
                reps(k,fromsave,j){
                    ve.at(k).at(i) = temp;
                }
                temp = 0;
                ve.at(j).at(i) = 0;
                fromsave = j+1;
            }else{
                ++temp;
            }
        }
        reps(k,fromsave,H) ve.at(k).at(i) = temp;
    }
    rep(i,H){
        int temp = 0;
        int fromsave = 0;
        rep(j,W){
            if(grid.at(i).at(j) == '#'){
                reps(k,fromsave,j){
                    ho.at(i).at(k) = temp;
                }
                temp = 0;
                ho.at(i).at(j) = 0;
                fromsave = j+1;
            }else{
                ++temp;
            }
        }
        reps(k,fromsave,W) ho.at(i).at(k) = temp;
    }
    int ans = 0;
    rep(i,H){
        rep(j,W){
            ans = max(ans,ve.at(i).at(j)+ho.at(i).at(j)-1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 37760
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

string str;
int n;
ll mem[N][3];

ll add(ll a, ll b) {
  a += b;
  a %= MOD;
  return a;
}

ll mul(ll a, ll b) {
  a = (a * b) % MOD;
  return a;
}

ll solve(int idx, int smaller) {
  if(idx == n)
    return smaller != 0;
  ll& ret = mem[idx][smaller];
  if(~ret)
    return ret;
  ret = 0;
  if(smaller == 2) {
    if(str[idx] == '1') {
//      ret += solve(idx + 1, 1);
      ret = add(ret, solve(idx + 1, 1));
//      ret += solve(idx + 1, 2) * 2;
      ret = add(ret, mul(solve(idx + 1, 2), 2));
    } else {
//      ret += solve(idx + 1, 2);
      ret = add(ret, solve(idx + 1, 2));
    }
  } else if(smaller == 1) {
//    ret += solve(idx + 1, 1);
    ret = add(ret, solve(idx + 1, 1));
//    ret += solve(idx + 1, 1) * 2;
    ret = add(ret, mul(solve(idx + 1, 1), 2));
  } else {
    // NOOO
  }
//  ret += solve(idx + 1, smaller == 2 ? (str[idx] == '1') ? 1 : smaller : smaller);
//  ret += solve(idx + 1, smaller) * 2;
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  cin >> str;
  n = str.size();
  memset(mem, -1, sizeof mem);
  cout << solve(0, 2);
}

Measured memory_bytes: 8272
<?php
$L=(int)trim(fgets(STDIN));

$p0=0;
$p1=0;
for($i=0;$i<$L;$i++){
  $C=explode(' ',trim(fgets(STDIN)));
  $c=strcmp($C[0],$C[1]);

  if($c<0) $p1+=3;
  elseif($c>0) $p0+=3;
  else{
    ++$p0;
    ++$p1;
  }
}

echo $p0,' ',$p1;
?>

Measured memory_bytes: 15344
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(n);
  vector<ll> a(n), b(n), c(n);
  rep(i, n){
    cin >> a[i];
  }

  rep(i, n){
    cin >> b[i];
  }
    rep(i, n){
    cin >> c[i];
  }
  sort(all(a));
  sort(all(b));
  sort(all(c));
  // dump(a);
  // dump(b);
  // dump(c);

  ll res = 0;

  rep(i, n){
    auto ac = lower_bound(all(a), b[i]);
    auto cc = upper_bound(all(c), b[i]);
    // dump(b[i]);
    // dump(ac - a.begin());
    // dump(cc - c.begin());
    res += (ac - a.begin()) * (c.end() - cc);
  }
  cout << res;
}
#endif


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

signed main(void)
{
	int n, k;
	cin >> n >> k;
	if (n % k == 0)
		cout << 0 << endl;
	else
		cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	
	int a, b, c;
	int Count = 0;
	cin >> a >> b >> c;

	for (int i = a; i <= b; i++){

		if (c%i == 0){
			Count++;
		}
	}
	cout << Count << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int top = 0,S[1000];
 
void push(int x){
	S[++top]=x;
}
 
int pop(){
	top--;
	return S[top+1];
}
 
int main(){
	int a,b;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			b=pop();
			a=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			b=pop();
			a=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}

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

int main () {
  int n, m;
  cin >> n >> m;
  vector <long long int> x(n);
  vector <long long int> y(m);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i);
  }
  for (int j = 0; j < m; j++) {
    cin >> y.at(j);
  }
  /*
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      long long int width = (x.at(i + 1) - x.at(i)) % 1000000007;
      long long int height = (y.at(j + 1) - y.at(j)) % 1000000007;
      long long int area = (width * height) % 1000000007;
      long long int num = (((((long long int)i + 1) * ((long long int)n - 1 - i)) % 1000000007) * ((((long long int)j + 1) * ((long long int)m - 1 - j)) % 1000000007)) % 1000000007;
      ans =  (ans + (area * num) % 1000000007) % 1000000007;
    //cout << ans << endl;
    }
  }
  */
  long long int ans_x = 0;
  for (long long int i = 0; i < n - 1; i++) {
    ans_x += ((x.at(i + 1) - x.at(i) % 1000000007)) * ((i + 1) * (n - 1 - i) % 1000000007) % 1000000007;
    ans_x = ans_x % 1000000007;
  }
  long long int ans_y = 0;
  for (long long int i = 0; i < m - 1; i++) {
    ans_y += ((y.at(i + 1) - y.at(i) % 1000000007)) * ((i + 1) * (m - 1 - i) % 1000000007) % 1000000007;
    ans_y = ans_y % 1000000007;
  }
  long long int ans = ans_x * ans_y % 1000000007;
  cout << ans << endl;
}


Measured memory_bytes: 1792
n = int(input())
li= list(map(int,input().split()))
a = min(li)
b = max(li)
all_li = []
for i in range(a,b+1):
    tmp = 0
    for l in li:
        tmp += (l-i)**2
    all_li.append(tmp)
print(min(all_li))

Measured memory_bytes: 38512
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int ne,tow;
};
node pth[200000+10];
int mp[100000+10],szp;
int vis[100000+10];
int n;
int deg[100000+10];
int root=-1;
int son[100000+10];
int bro[100000+10];
int dp[100000+10];
int left[100000+10];
void addpath(int i,int j){
	++szp;
	pth[szp].ne=mp[i];
	pth[szp].tow=j;
	mp[i]=szp;
	deg[i]++;
}

void dfs1(int i,int j){
	if (vis[i]!=0) return;
	vis[i]=j;
	int po=mp[i];
	while (po!=-1){
		if (vis[pth[po].tow]==0){
			bro[pth[po].tow]=son[i];
			son[i]=pth[po].tow;
		}
		dfs1(pth[po].tow,j+1);
		po=pth[po].ne;
	}	
}
void dfs2(int i){
	int j=son[i];
	if (j==-1){
		left[i]=1;
		dp[i]=1;
		return;
	}
	while (j!=-1){
		dfs2(j);
		left[i]+=left[j];
		dp[i]+=dp[j];
		j=bro[j];
	}
	j=son[i];
	if (j!=-1&&bro[j]!=-1)
	while (j!=-1){
		if (dp[j]==1&&left[j]==1){
			dp[i]--;
			return;
		}
		j=bro[j];
	}

}


int main(){
	scanf("%d",&n);
	for (int f1=0;f1<n;f1++){
		mp[f1]=-1;
		vis[f1]=0;
	}
	
	for (int f1=1;f1<n;f1++){
		int i,j;
		scanf("%d%d",&i,&j);
		addpath(i,j);
		addpath(j,i);
		if (deg[i]>2)root=i;
		if (deg[j]>2)root=j;
	}
	if (root==-1){
		printf("1\n");
		return 0;
	}
	for (int f1=0;f1<n;f1++){
		son[f1]=-1;
		bro[f1]=-1;
		left[f1]=0;
		dp[f1]=0;
	}
	dfs1(root,1);
	dfs2(root);
	printf("%d\n",dp[root]);
	//for (int f1=0;f1<n;f1++)printf("%d ",dp[f1]);
}
//

Measured memory_bytes: 5888
str = str(input())
num1 = int(str.split()[0])
num2 = int(str.split()[1])

wa = num1 + num2
sa = num1 - num2
seki = num1 * num2

if wa >= sa:
  if wa >= seki:
    print(wa)
  else:
    print(seki)
elif sa >= seki:
  print(sa)
else:
  print(seki)

Measured memory_bytes: 38256
x,y,z = map(int,input().split())
if x == 5 and y == 7 and z == 5:
  print('YES')
elif x == 5 and y == 5 and z == 7:
  print('YES')
elif x == 7 and y == 5 and z == 5:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 38384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String N = sc.nextLine(); 
        
        Double num = Double.parseDouble(N);
        
        if (num == 1){
            
            System.out.println(1.0);
        
            
        } else{
            // １より上の奇数2の場合
            if (num % 2 == 1 ){
                int cnt = 0;
            
                double ans = 0;
                
                for (int i = 1 ;i <= num ;i++) {
                    if ( i % 2 == 1){
                        cnt++;
                    }
                    
                }
                ans = cnt/num;
                System.out.println(ans);
            } else{
                System.out.println(0.5);
            }
        }
        
    }
}

Measured memory_bytes: 21844
/**
 * @Author:      G_bg
 * @DateTime:    2019-07-20 20:09:23
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 2e5+10;
int a[maxn],b[maxn],c[maxn];
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		c[i] = a[i];
		b[a[i]]++;
	}
	sort(c+1,c+n+1);
	for(int i = 1;i <= n;i++){
		if(c[n] == a[i]){
			if(b[a[i]] > 1) cout << a[i] << endl;
			else cout << c[n-1] << endl;
		}
		else cout << c[n] << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] sn = s.split("");
        if (sn[0].equals(sn[1]) && sn[1].equals(sn[2])) {
            System.out.println("Yes");
        } else if (sn[1].equals(sn[2]) && sn[2].equals(sn[3])) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 21972
#include <iostream>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int l=0, r=n-1, cnt=0;
    while(l<r){
      if (s[l] == 'R') l++;
      else if (s[r] == 'W') r--;
      else {
        l++; r--; cnt++;
      }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
map<ll, ll> pen;
map<ll, bool> done;
ll ans, acc;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n, m;
	cin >> n >> m;
	while (m--){
		ll a;string b;
		cin >> a >> b;
		if (done.find(a) != done.end())continue;
		if (b == "WA"){
			if (pen.find(a) == pen.end()){
				pen[a] = 1;
			}else {
				pen[a]++;
			}
		}else{
			if (pen.find(a) == pen.end()){
				acc++;
				done[a] = 1;
				continue;//ac first try
			}
			else {
				ans += pen[a];
				acc++;
				done[a] = 1;
			}
		}
	}
	cout << acc << ' ' << ans;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;

int a[100002], b[100002];
int main(){
	int n, k, ans = inf;
	scanf("%d%d", &n, &k);
	for(int i = 1;i <= n;i++)scanf("%d", &a[i]);
	
	int l = 0, r = 0, sum = 0;
	while(r <= n){
		if(r == n && sum < k)break;
		if(sum == k)ans = min(ans, r-l);
		if(sum < k){if(a[++r] <= k && b[a[r]]++ == 0)sum++;}
		else {if(a[++l] <= k && --b[a[l]] == 0)sum--;}
	}
	
	if(ans == inf)printf("0\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4012