akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;

public class Main {
    public static void main(String[] args) {
        FastReader reader = new FastReader();
        BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
        try {
            long x = reader.nextLong();
            long a, b;
            a = b = 0;
            boolean found = false;

            for (int i = -1000; i <= 1000; i++) {
                long aValue = (long) Math.pow((long) i, (long) 5);
                for (int j = -1000; j <= 1000; j++) {
                    long bValue = (long) Math.pow((long) j, (long) 5);
                    if (aValue - bValue == x) {
                        a = i;
                        b = j;
                        found = true;
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }

            log.write(a + " " + b + "\n");
            log.flush();
            log.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 26152
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
typedef  long long ll ;
const int maxn = 1e5+2;
int dp[maxn][3];
int main() {
    int n;
    cin>>n;
    int a[n+1][3];
    for(int i=1;i<n+1;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
    for(int i=1;i<n+1;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Linq;

namespace ABC042
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();

            int N = int.Parse(input[0]);
            int L = int.Parse(input[1]);

            string[] s = new string[N];
            for (int i = 0; i < N; i++)
            {
                s[i] = Console.ReadLine();
            }

            s = s.OrderBy(x => x).ToArray();

            string res = "";

            for (int i = 0; i < N; i++)
            {
                res += s[i];
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 14560
def comb(n, c) :
    ans = 1
    for i in range(1, c+1):
        ans *= (n - i + 1) / i
    return ans

# main関数
if __name__ == '__main__':

    n, a, b = map(int,input().split())
    l = map(int, input().split())

    items = {}
    for i in l :
        if i in items:
            items[i] = items[i] + 1
        else:
            items[i] = 1

    oitems = sorted(items.items(), key=lambda x: x[0], reverse=True)

    num = 0
    sum = 0
    ans = 0
    for i in oitems :
        if num + i[1] > a:
            if num == 0 or sum / num == i[0] :
                print(i[0])
                for j in range (a - num, min(b - num, i[1])+1) :
                    ans += comb(i[1], j)
                print(int(ans))
                break 
            else: 
                print("{:.6f}".format((sum + (a - num) * i[0]) / a))
                print(int(comb(i[1],a - num)))
                break 
        else :
            num += i[1]
            sum += i[0] * i[1]

Measured memory_bytes: 39280
n, m = map(int, input().split())
s = []
for _ in range(m):
    tmp = list(map(int, input().split()))
    s.append(tmp[1:])
p = list(map(int, input().split()))

ans = 0
for bit in range(0, 1 << n):
    flag = 1
    for i in range(m):
        on_count = 0
        for switch in s[i]:
            if bit & (1 << (switch-1)):
                on_count += 1
        if (on_count % 2) != p[i]:
            flag = 0
    if flag == 1:
        ans += 1
print(ans)

Measured memory_bytes: 3064
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
l = 0
r = n-1
res = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        res += 1
        l += 1
    elif s[r] == 'x':
        res += 1
        r -= 1
    else:
        print(-1)
        break
else:
    print(res)

Measured memory_bytes: 40812
import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._

  solve
  @tailrec
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n == 0) return
    val start = mutable.PriorityQueue()(Ordering.by[Human, Int](_.from).reverse)
    val end = mutable.PriorityQueue()(Ordering.by[Human, Int](_.to).reverse)
    start.enqueue(List.tabulate(n){_ ⇒
      val Array(m, a, b) = readLine.trim.split(' ').map(_.toInt)
      Human(m, a, b)
    }:_*)
    var currentWeight = 0
    while (currentWeight <= 150 && start.nonEmpty){
      val next = start.dequeue()
      while (end.nonEmpty && end.head.to <= next.from) {
        currentWeight -= end.dequeue().weight
      }
      currentWeight += next.weight
      end.enqueue(next)
    }
    println(
      if (currentWeight > 150) "NG" else "OK"
    )
    solve
  }
  case class Human(weight: Int, from: Int, to: Int)
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

int main() {
    int n;
    cin >> n;
    V<V<Pii>> v(n);
    REP(i, n) {
        int a;
        cin >> a;
        REP(j, a) {
            int x,y;
            cin >> x >> y;
            v[i].push_back({x-1, y});
        }
    }

    int maxi = 0;
    REP(bit, 1 << n) {
        bool f = true;
        int cnt = 0;
        REP(i, n) {
            if (bit & (1 << i)) {
                cnt++;
                FOR(j, v[i]) {
                    if (bool(bit & (1 << j->first)) ^ j->second) {
                        f = false;
                        break;
                    }
                }
            }
            if (!f) {
                break;
            }
        }
        if (f && maxi < cnt) {
            maxi = cnt;
        }
    }
    std::cout << maxi << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
	int n, i;
	char s[10000];
	
	scanf("%d %s", &n, s);
	int len=strlen(s);
	
	for(i=0; i<len; i++){
		s[i]=s[i]+n;
		if(s[i]>'Z'){ s[i]=s[i]-26; }
	}
	printf("%s", s);
	
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <cmath>


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

int main()
{
    int N;
    std::map<int, int, std::less<int>> A;
    std::cin >> N;
    for (int i = 0; i < N; i++)
    {
        int a;
        std::cin >> a;
        ++A[a];
    }

    constexpr int MAX_A = 1000000;
    std::vector<int> kusi(MAX_A+1, 0);
    for (auto [a, i] : A)
        kusi[a] = i;

    int ans = 0;
    if (kusi[1] > 1)
    {
        ans = 0;
    }
    else if (kusi[1] == 1)
    {
        ans = 1;
    }
    else
    {
        for (auto [a, i] : A)
        {
            if (i != 1) continue;

            int sqr_a = (int)std::sqrt(a);
            bool ok = true;
            for (int j = 2; ok && j <= sqr_a; ++j)
            {
                if (kusi[j] && a % j == 0) ok = false;
                if (kusi[a/j] && a % (a/j) == 0) ok = false;
            }

            if (ok) ++ans;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 16228
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
	
    // freopen("friday.in","r",stdin);
    // freopen("friday.out","w",stdout);

    
    int n;cin>>n;vector<pii> v(n);
    for(int i=0;i<n;i++)
    	cin>>v[i].ff>>v[i].ss;

    for(int i=0;i+2<n;i++){
    	int ans = 1;
    	for(int j=0;j<=2;j++){
    		ans = ans&&(v[i+j].ff==v[i+j].ss);
    	}
    	if(ans)
    	{
    		cout<<"Yes"<<endl;
    		return 0;
    	}
    }
    cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for _ in range (Q)]

dic = dict()
ans = sum(A)
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

for b,c in BC:
    if not (b in dic) or dic[b]==0:
        print(ans)
        continue
    
    sa = (c-b)*dic[b]
    ans += sa
    print(ans)

    if c in dic:
        dic[c] += dic[b]
    else:
        dic[c] = dic[b]
    dic[b] = 0





Measured memory_bytes: 101808
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>

typedef long long ll;
using namespace std;

ll x,k,d;
int main()
{	
	cin>>x>>k>>d;
	if(x<0) x=-x;
	ll ans=0;
	if(x/d>=k){
		ans=x-k*d;
	}
	else{
		ll num=x/d;
		ll a=x-num*d;
		ll b=abs(a-d);
		if(b<a) num+=1;
		ll temp=k-num;
		if(temp&1) ans=max(a,b);
		else ans=min(a,b);
	}
	
	cout<<ans<<endl;
	return 0;
 } 


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
signed main(){
	int a,b,c,d;
	cin>>a;
	f(i,a){
		if(i%2==0) cin>>b;
		else cin>>c;
		if(i==1) d=gcd(b,c);
		else if(i) d=gcd(d,gcd(b,c));
	}
	cout<<d<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 510;

int N, E, Q, G[MAX_N][MAX_N];

int dfs(int now, int g, vector<bool> &visited){
  visited[now] = true;
  if(now == g) return 1;
  REP(i, N){
    if(visited[i] || G[now][i] <= 0) continue;
    if(dfs(i, g, visited)){
      ++G[i][now];
      --G[now][i];
      return 1;
    }
  }
  return 0;
}

int flow(int s, int t){
  vector<bool> visited(N, false);
  return dfs(s, t, visited);
}

int main() {
  int ans = 0;
  cin >>N >>E >>Q;
  memset(G, 0, sizeof(G));
  REP(i, E){
    int f, t; cin >>f >>t;
    --f; --t;
    G[f][t] = G[t][f] = 1;
  }
  REP(i, Q){
    int m, f, t; cin >>m >>f >>t;
    --f; --t;
    if(m == 1) G[f][t] = G[t][f] = 1;
    else {
      if(G[f][t] == 2 && !flow(t, f)) { flow(N - 1, 0); flow(t, f); --ans; }
      else if(G[t][f] == 2 && !flow(f, t)) { flow(N - 1, 0); flow(f, t); --ans; }
      G[f][t] = G[t][f] = 0;
    }
    while(flow(0, N - 1)) ++ans;
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 2264
#include<iostream>

int main(void){
    int n, k;
    std::cin >> n >> k;
    std::string s;
    std::cin >> s;
    char ss = s[0];
    int i = 0;
    while(k != 0 && i != n){
        if(s[i] == ss){
            i++;
        }else{
            while(s[i] != ss && i != n){
                s[i] = ss;
                i++;
            }
            k--;
        }
    }

    int ans = 0;
    ss = s[0];
    for(int i = 1; i < n; i++){
        if(s[i] == ss) ans++;
        else ss = s[i];
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3732
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
       int N = sc.nextInt();
       int[][] A = new int[2][N];
       int[] ue = new int[N];
       int[] shita = new int[N];
       for(int i = 0; i < 2; i++){
           for(int j = 0; j < N; j++){
               A[i][j] = sc.nextInt();
               if(i == 0){
                   if(j==0){
                       ue[j] = A[i][j];
                   } else {
                       ue[j] = ue[j-1] + A[i][j];
                   }
               }
               if(i == 1){
                    if(j==0){
                        shita[j] = A[i][j];
                    } else {
                        shita[j] = shita[j-1] + A[i][j];
                    }
               }
           }
       }
       sc.close();
      
       int max = 0;
       for(int i = 0; i < N; i++){
            if(i != 0)
                max = Math.max(max, ue[i] + (shita[N-1] - shita[i-1]));
            else
                max = Math.max(max, ue[i] + (shita[N-1]));
       }
       System.out.println(max);
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
map<string,int> ma;
void in(string s) {
  if(!ma.count(s)) {
    int k=ma.size();
    ma[s]=k;
  }
}

int main() {
  int n,m;
  while(cin >> n >> m && n) {
    ma.clear();
    string r[3];
    for(int i=0; i<3; i++) {
      cin >> r[i];
      in(r[i]);
    }
    int d[n][n];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)d[i][j]=1<<29;
      d[i][i]=0;
    }
    for(int i=0; i<m; i++) {
      string s,t;
      int b,c;
      cin >> s >> t >> b >> c;
      in(s);in(t);
      d[ma[s]][ma[t]]=b/40+c;
      d[ma[t]][ma[s]]=b/40+c;
    }
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    cout << d[ma[r[0]]][ma[r[1]]]+d[ma[r[1]]][ma[r[2]]] << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long LL;

const LL mod=1e9+7;
LL jc1[200005],jc2[200005];
LL powmod(LL a,LL b,LL c)
{
    LL ans=1;
    while (b)
    {
        if (b&1) ans=ans*a%c;
        b/=2;
        a=a*a%c;
    }
    return ans;
}
LL work(LL n,LL m)
{
    //c(n+m-2,n-1)
    LL ans=jc1[n+m-2];
    ans=ans*jc2[n-1]%mod;
    ans=ans*jc2[m-1]%mod;
    return ans;
}
int main()
{
    LL n,m,a,b,ans=0;
    jc1[0]=1;jc2[0]=1;
    for (int i=1;i<=200000;++i) jc1[i]=jc1[i-1]*i%mod;
    jc2[200000]=powmod(jc1[200000],mod-2,mod);
    for (int i=200000-1;i>=1;--i) jc2[i]=jc2[i+1]*(i+1)%mod;
    cin>>n>>m>>a>>b;
    // n-a i 
    for (int i=b+1;i<=m;++i)
    {
        LL ln=n-a,lm=i;
        LL rn=a,rm=m-i+1;
//cout<<ln<<" "<<lm<<" "<<rn<<" "<<rm<<endl;
        LL dq=work(ln,lm)*work(rn,rm)%mod;
        ans=(ans+dq)%mod;
    }  
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n, x;
int a[N];
int mn[2001][2001];

int main(){
  scanf("%d %d", &n, &x);
  for(int i = 0; i < n; ++i){
    scanf("%d", a + i);
    mn[0][i] = a[i];
  }
  for(int i = 1; i < n; ++i){
    for(int j = 0; j < n; ++j){
      mn[i][j] = min(mn[i - 1][(j - 1 + n) % n], a[j]);
    }
  }
  ll ans = (ll)1e18;
  for(int s = 0; s < n; ++s){
    ll cur = s * 1ll * x;
    for(int i = 0; i < n; ++i){
      cur += mn[s][i];
    }
    ans = min(ans, cur);
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 16640
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numRow = sc.nextInt();
        int numCol = sc.nextInt();
        int[][] mat = new int[numRow][numCol];
        int[] vecIn = new int[numCol];
        int[] vecOut = new int[numRow];
        int i, j;
        for (i = 0; i < numRow; i++) {
            for (j = 0; j < numCol; j++) {
                mat[i][j] = sc.nextInt();
            }
        }
        for (j = 0; j < numCol; j++) vecIn[j] = sc.nextInt();
        for (i = 0; i < numRow; i++) {
            for (j = 0; j < numCol; j++) {
                vecOut[i] += mat[i][j] * vecIn[j];
            }
            System.out.println(vecOut[i]);
        }
    }
}


Measured memory_bytes: 40332
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

ll wazu = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    reverse(N.begin(), N.end());

    if (N[0] == '3') { cout<<"bon"<<endl; }
    else if (N[0] == '0' || N[0] == '1' || N[0] == '6' || N[0] == '8') { cout << "pon" << endl; }
    else{ cout << "hon" << endl; }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> b(n-1);
    for (int& b_i : b) {
        cin >> b_i;
    }
    int max_sum = b[0] + b[n-2];
    for (int i = 1; i < n-1; ++i) {
        max_sum += min(b[i-1], b[i]);
    }
    cout << max_sum << endl;
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;


int main(){
    int N; cin >> N;
    vi C(N), V(N);
    for(auto &x : V) cin >> x;
    for(auto &x : C) cin >> x;
    int ans=0;
    for(int i=0; i<N; i++){
        if(V[i] >= C[i]) ans+=V[i]-C[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
N, M = map(int,input().split())
li1 = []
li2 = []
for i in range(M):
    L, R = map(int,input().split())
    li1.append([L,R])
    li2.append([R,L])
li1.sort()
li2.sort(reverse=True)
if (li2[M-1][0])<(li1[M-1][0]):
    print("0")
    exit()
print((li2[M-1][0])-(li1[M-1][0])+1)

Measured memory_bytes: 30284
/*input
12345 678901
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}


void solve(){
	 int a,b;cin >> a >> b;
	 if(a > (b/2)){
	 	cout << b/2 << endl;
	 	return;
	 }
	 if(b%2)b--;
	 int one = b-(2*a);
	 int give = (one)/2;
	 int ans = min(a+(give)/2,(b-give)/2);
	 cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll l, k;
    cin >> l >> k;

    vector<vector<ll>> dp(l+1, vector<ll>(2));
    dp[0][0] = 1;
    REP(i, l+1) REP(j, 2) {
        if(j == 0) {
            if(i+1<=l) dp[i+1][1] += dp[i][0];
            if(i+k<=l) dp[i+k][1] += dp[i][0];
        } else {
            if(i+1<=l) dp[i+1][0] += dp[i][1];
        }
    }

    ll ret = 0;
    FOR(i, 1, l+1) ret += dp[i][1];
    cout << ret << endl;

    return 0;
}


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

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100;
int const inf =    1000000000;
int const modulo = 1000000007;
int v[1 + nmax];

int lgpow(int a, int b) {
  if(b == 0)
    return 1;
  else if(b == 1)
    return a;
  else {
    int result = lgpow(a, b/ 2);
    if(b % 2 == 0)
      return 1LL * result * result % modulo;
    else
      return 1LL * result * result % modulo * a % modulo;
  }
}

std::pair<int,int> solve(int from, int to, int start) {
  int smin = inf;
  for(int i = from; i <= to; i++)
    smin = std::min(smin, v[i]);
  int last = from - 1;
  
  std::pair<int,int> sol;

  for(int i = from; i <= to; i++) {
    if(v[i] == smin) {
      if(last + 1 < i) {
        if(last == from - 1) { 
          sol = solve(last + 1, i - 1, smin);
          sol.first = sol.first * 2 % modulo;
        } else {
          std::pair<int,int> aux = solve(last + 1, i - 1, smin);
          sol.second = (1LL * sol.second * (2LL * aux.first + aux.second) + 1LL * sol.first * aux.second + 1LL * sol.first * aux.first) % modulo;
          sol.first = 1LL * sol.first * aux.first % modulo;
        }
      }
      if(i == from)
        sol = {2, 0};
      else {
        sol = {sol.first, (sol.first + 2LL * sol.second) % modulo};
      }
      last = i;
    }
  }

  if(last + 1 <= to) {
    if(last == from - 1) { 
      sol = solve(last + 1, to, smin);
      sol.first = sol.first * 2 % modulo;
    } else {
      std::pair<int,int> aux = solve(last + 1, to, smin);
      sol.second = (1LL * sol.second * (2LL * aux.first + aux.second) + 1LL * sol.first * aux.second + 1LL * sol.first * aux.first) % modulo;
      sol.first = 1LL * sol.first * aux.first % modulo;
    }
  }

  sol.first = 1LL * sol.first * lgpow(2, smin - start - 1)% modulo;

  return {sol.first, sol.second};
}

int main() {
  int n;
  std::cin >> n;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  std::pair<int,int> sol = solve(1, n, 0);
  std::cout << (sol.first + sol.second) % modulo;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int mod = 1000000007;
const int dx[2]={1,0}, dy[2]={0,1};

int main(){
    int h,w;
    cin >>h >>w;
    vector<string> a(h);
    rep(i,h) cin >>a[i];

    auto IN = [&](int y, int x){
        return 0<=y && y<h && 0<=x && x<w;
    };

    vector<vector<int>> dp(h,vector<int>(w));
    dp[0][0] = 1;
    rep(i,h)rep(j,w){
        rep(d,2){
            int ny = i+dy[d], nx = j+dx[d];
            if(IN(ny,nx) && a[ny][nx]=='.') (dp[ny][nx] += dp[i][j]) %= mod;
        }
    }
    cout << dp[h-1][w-1] << "\n";
    return 0;
}


Measured memory_bytes: 5248
MOD = 10 ** 9 + 7

N,K = map(int,input().split())

perm = [0] * (10**5)
perm[0] = 1
for l in range(1,10 ** 5):
    perm[l] = (perm[l-1] * (K-l-1)) % MOD

info = [[] for _ in range(N)]

def intminus(t):
    return int(t)-1

for i in range(N-1):
    a,b = map(intminus,input().split())
    info[a].append(b)
    info[b].append(a)

count = 1

for j in range(1+len(info[0])):
    count = (count * (K-j)) % MOD

stack = []
for p in info[0]:
    stack.append([0,p])

while stack:
    x = stack.pop(-1)
    count = (count * perm[len(info[x[1]])-1]) % MOD
    for xx in info[x[1]]:
        if xx == x[0]:continue
        stack.append([x[1],xx])

print(count)

Measured memory_bytes: 36148
import java.io.PrintWriter

import scala.annotation.tailrec
import scala.collection.immutable.Queue

object Main extends App {
  val sc = new FastScanner
  val N, M = sc.nextInt
  val graph = (0 until M).foldLeft(Vector.fill(N)(List.empty[Int])) { (acc, _) =>
    val A, B = sc.nextInt - 1
    acc.updated(A, B +: acc(A)).updated(B, A +: acc(B))
  }

  val room1 = 0
  val ps = loop(Vector.fill(N)(-1).updated(room1, room1), Queue.empty.enqueueAll(graph(room1).map(_ -> room1)))

  val out = new PrintWriter(System.out)
  out.println("Yes")
  ps.tail.foreach(p => out.println(p + 1))
  out.flush()

  @tailrec def loop(acc: Vector[Int], nexts: Queue[(Int, Int)]): Vector[Int] = nexts.dequeueOption match {
    case Some(((room, prev), rest)) if acc(room) == -1 =>
      loop(acc.updated(room, prev), rest.enqueueAll(graph(room).map(_ -> room)))
    case Some((_, rest)) =>
      loop(acc, rest)
    case _ => acc
  }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
object FastScanner {
  private def isPrintableChar(c: Int) = 33 <= c && c <= 126
}

class FastScanner {
  private[this] val in = System.in
  private[this] val buffer = new Array[Byte](1024)
  private[this] var ptr = 0
  private[this] var buflen = 0

  private def hasNextByte: Boolean =
    if (ptr < buflen) true
    else {
      ptr = 0
      buflen = in.read(buffer)
      buflen > 0
    }

  private def readByte: Byte =
    if (hasNextByte) {
      ptr += 1
      buffer(ptr - 1)
    } else -1

  def hasNext: Boolean = {
    while (hasNextByte && !FastScanner.isPrintableChar(buffer(ptr))) ptr += 1
    hasNextByte
  }

  def next: String = {
    if (!hasNext) throw new NoSuchElementException
    val sb = new java.lang.StringBuilder
    var b = readByte
    while (FastScanner.isPrintableChar(b)) {
      sb.appendCodePoint(b)
      b = readByte
    }
    sb.toString
  }

  def nextLong: Long = {
    if (!hasNext) throw new NoSuchElementException
    var n = 0
    var minus = false
    var b = readByte
    if (b == '-') {
      minus = true
      b = readByte
    }
    if (b < '0' || '9' < b) throw new NumberFormatException

    @tailrec def loop(): Long = {
      if ('0' <= b && b <= '9') {
        n *= 10
        n += b - '0'
        b = readByte
        loop()
      } else if (b == -1 || !FastScanner.isPrintableChar(b)) {
        if (minus) -n else n
      } else throw new NumberFormatException
    }

    loop()
  }

  def nextInt: Int = {
    val nl = nextLong
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException
    nl.toInt
  }

  def nextDouble: Double = next.toDouble
}

Measured memory_bytes: 133788
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

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

    int ac_cnt = n - m;
    cout << (1900 * m + ac_cnt * 100) * pow(2, m) << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = 10**18
for l in range(N - K + 1):
    D = X[l + K - 1] - X[l]
    if X[l] <= 0 <= X[l + K - 1]:
        D += min(-X[l], X[l + K - 1])
    elif X[l + K - 1] <= 0:
        D += -X[l + K - 1]
    elif X[l] >= 0:
        D += X[l]
    ans = min(ans, D)
print(ans)


Measured memory_bytes: 14384
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
  int a[3],k;
  cin >> a[0] >> a[1] >> a[2] >> k;
  sort(a, a+3);
  int mx = a[2];
  rep(i, k){
    mx *= 2;
  }
  cout << mx + a[1] + a[0] << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u) {
        cout<<--a<<" "<<b<<endl;
    }
    else
    {
        cout<<a<<" "<<--b<<endl;
    }
    
    
    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    long long a,b,c;
    cin >> a >> b >> c;
    long long x,y,z;
    long long ans;
    x = (a-a/2)*b*c - (a/2)*b*c;
    y = a*(b-b/2)*c - a*(b/2)*c;
    z = a*b*(c-c/2) - a*b*(c/2);
    ans = min(x,y);
    ans = min(ans,z);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	
	int x = 0;
	for(int i=0; i<4; i++)
	    x+=sc.nextInt();

	System.out.println(x/60);
	System.out.println(x%60);
    }
}

Measured memory_bytes: 12000
import math
from collections import Counter
n, m = map(int, input().split())

prime_count = Counter()
for i in range(2, math.ceil(math.sqrt(m))+1):
    while m % i == 0:
        m /= i
        prime_count[i] += 1
if m > 1:
    prime_count[int(m)] += 1

if len(prime_count) != 0:
    b_max = max([i for i in prime_count.values()])
else:
    b_max = 1

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
Mod = 10**9+7
def COMinit():
    #N_C_kのN
    for i in range(2, n+b_max):
        fac.append(fac[-1]*i%Mod)
        inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
        finv.append(finv[-1] * inv[-1] % Mod)


def COM(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod

ans = 1
COMinit()
for b in prime_count.values():
    ans *= COM(n+b-1, n-1)
    ans %= Mod 

print(ans)

Measured memory_bytes: 58096
#include <bits/stdc++.h>
using namespace std;
int n, x, y, z;
const int maxn = 1e5 + 7;
int exc[maxn];
int main()
{
    cin >> n;
    for (int x = 1; x * x <= n; x++)
        for (int y = 1; y * y <= n; y++)
            for (int z = 1; z * z <= n; z++)
                if (x * x + y * y + z * z + x * y + x * z + y * z <= n)
                    exc[x * x + y * y + z * z + x * y + x * z + y * z]++;
    for (int i = 1; i <= n; i++)
        cout << exc[i] << endl;
}

Measured memory_bytes: 3632
#include <iostream>                                             
using namespace std;                                            
                                                                
int main(void) {                                                
  int N;                                                        
  cin >> N;                                                     
  int A[N];                                                     
  for (int i=0; i<N; i++) {                                     
    cin >> A[i];                                                
  }                                                             
  int flag = 1;                                                 
  int ans = 0;                                                  
  while (flag) {                                                
    flag = 0;                                                   
    for (int j=N-1; j>=1; j--) {                                
      if (A[j]<A[j-1]) {                                        
        int t = A[j-1];                                         
        A[j-1] = A[j];                                          
        A[j] = t;                                               
        ans++;                                                  
        flag = 1;                                               
      }                                                         
    }                                                           
  }                                                             
  for (int i=0; i<N; i++) {                                     
    cout << (i==0?"":" ") << A[i] << flush;                     
  }                                                             
  cout << endl << ans << endl;                                  
  return 0;                                                     
}                                                               
                                                                
                                                                
                                    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 1000
using namespace std;
int n,a[N+5];char s[N+5][N+5];
char s3[4][4]={"","aab","b.b","baa"};
char s5[6][6]={"","abba.","a..ab","bba.b","a.acc","abbaa"};
char s7[8][8]={"","aabbaa.","b..a..a","b..a..a","...baab","...bccb","abb...a","acc...a"};
char s4[5][5]={"","aaba","ccba","abcc","abaa"};
I void Draw(CI n)
{
	RI i,j;if(n==4)
	{
		for(i=1;i<=4;++i) for(j=1;j<=4;++j) s[i][j]=s4[i][j-1];return;
	}
	if(n%6==0)
	{
		for(i=1;i<=n/6;++i)
			s[6*i-5][i]=s[6*i-4][i]=s[n-6*i+6][n-i+1]=s[n-6*i+5][n-i+1]='x',
			s[6*i-3][i]=s[6*i-2][i]=s[n-6*i+4][n-i+1]=s[n-6*i+3][n-i+1]='y',
			s[6*i-1][i]=s[6*i][i]=s[n-6*i+2][n-i+1]=s[n-6*i+1][n-i+1]='z';
		for(i=1;i<=n/3;++i)
			s[3*i-2][n/6+2*i-1]=s[3*i-2][n/6+2*i]='a',
			s[3*i-1][n/6+2*i-1]=s[3*i-1][n/6+2*i]='b',
			s[3*i][n/6+2*i-1]=s[3*i][n/6+2*i]='c';
	}
	if(n%6==2)
	{
		for(i=1;i<=n/6;++i)
			s[6*i-5][i]=s[6*i-4][i]=s[n-6*i+6][n-i+1]=s[n-6*i+5][n-i+1]='x',
			s[6*i-3][i]=s[6*i-2][i]=s[n-6*i+4][n-i+1]=s[n-6*i+3][n-i+1]='y',
			s[6*i-1][i]=s[6*i][i]=s[n-6*i+2][n-i+1]=s[n-6*i+1][n-i+1]='z';
		s[n-1][i]=s[n][i]=s[2][n-i+1]=s[1][n-i+1]='p';
		for(i=1;i<=n/3;++i)
			s[3*i-2][n/6+2*i-1]=s[3*i-2][n/6+2*i]='a',
			s[3*i-1][n/6+2*i-1]=s[3*i-1][n/6+2*i]='b',
			s[3*i][n/6+2*i]=s[3*i][n/6+2*i+1]='c';
		s[n-1][n/6+2*i-1]=s[n-1][n/6+2*i]='a',
		s[n][n/6+2*i-1]=s[n][n/6+2*i]='b';
	}
	if(n%6==4)
	{
		for(i=1;i<=n/6;++i)
			s[6*i-5][i]=s[6*i-4][i]=s[n-6*i+6][n-i+1]=s[n-6*i+5][n-i+1]='x',
			s[6*i-3][i]=s[6*i-2][i]=s[n-6*i+4][n-i+1]=s[n-6*i+3][n-i+1]='y',
			s[6*i-1][i]=s[6*i][i]=s[n-6*i+2][n-i+1]=s[n-6*i+1][n-i+1]='z';
		s[n-3][i]=s[n-2][i]=s[4][n-i+1]=s[3][n-i+1]='p',
		s[n-1][i]=s[n][i]=s[2][n-i+1]=s[1][n-i+1]='q';
		for(i=1;i<=n/3;++i)
			s[3*i-2][n/6+2*i-1]=s[3*i-2][n/6+2*i]='a',
			s[3*i-1][n/6+2*i]=s[3*i-1][n/6+2*i+1]='b',
			s[3*i][n/6+2*i]=s[3*i][n/6+2*i+1]='c';
		s[n][n/6+2*i-1]=s[n][n/6+2*i]='b';
	}
}
int main()
{
	RI i,j;if(scanf("%d",&n),n==2) return puts("-1"),0;
	if(n==3) {for(i=1;i<=3;++i) puts(s3[i]);return 0;}
	if(n==5) {for(i=1;i<=5;++i) puts(s5[i]);return 0;}
	if(n==7) {for(i=1;i<=7;++i) puts(s7[i]);return 0;}
	for(i=1;i<=n;++i) for(j=1;j<=n;++j) s[i][j]='.';
	if(n&1) for(Draw(n-5),i=1;i<=5;++i) for(j=1;j<=5;++j) s[n-5+i][n-5+j]=s5[i][j-1];else Draw(n);
	for(i=1;i<=n;++i) puts(s[i]+1);return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};

template< typename T >
T kruskal(vector<edge<T>> &G, int V)
{
    sort(begin(G), end(G), [](const edge< T > &a, const edge< T > &b) { return (a.cost < b.cost); });
    UnionFind tree(V);
    T ret = 0;
    for(auto &e : G) {
        if(tree.unite(e.from, e.to)) ret += e.cost;
    }
    return (ret);
}

int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> vx, vy;
    for (int i = 0; i < n; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);
        vx.emplace_back(x, i);
        vy.emplace_back(y, i);
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
    vector<edge<ll>> G;
    G.reserve(2*n-2);
    for (int i = 0; i < n - 1; ++i) {
        G.emplace_back(vx[i].second, vx[i+1].second, (ll)(vx[i+1].first-vx[i].first));
        G.emplace_back(vy[i].second, vy[i+1].second, (ll)(vy[i+1].first-vy[i].first));
    }
    cout << kruskal(G, n) << "\n";
    return 0;
}


Measured memory_bytes: 5356
###### Importing Libraries ######
import math
import operator as op
from functools import reduce
from fractions import Fraction as frac
#################################
##### User defined function #####

############ NCR ###############
def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
    
############ READ ###############
def rd(p):
    if(p==0):
        return input()
    if(p==1):
        return int(input())
    if(p==2):
        return map(int,input().split())
    if(p==3):
        return list(map(int,input().split()))


############ DSU ###############
global par
par=[-1 for i in range(100001)]
# t=rd(1)
def find(u):
    if(par[u]<0):
        return u
    else:
        return find(par[u])
def uni(x,y):
    u=find(x)
    v=find(y)
    if u==v:
        return
    if(par[u]<par[v]):
        par[u]+=par[v]
        par[v]=u
    else:    
        par[v]+=par[u]
        par[u]=v
################################        
        

t=1
for term in range(1,t+1):
    x,y,a,b,c=rd(2)
    A=rd(3)
    B=rd(3)
    C=rd(3)
    A.sort()
    B.sort()
    C.sort()
    temp=A[-x:]+B[-y:]+C
    temp.sort()
    tot=sum(temp[-x-y:])
    
    print(tot)
            
    
        
    
    

Measured memory_bytes: 25204
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);


// main function
int main()
{
	ll N = 0;
	ll M = 0;
	ll K = 0;
	ll favorite = 0;
	ll cnt = 0;

	cin >> N >> M;
	vector<ll> food(M, 0);

	Rep(i, N) {
		cin >> K;
		Rep(j, K) {
			cin >> favorite;
			favorite--;
			food[favorite]++;
		}
	}
	Rep(i, M) {
		if (food[i] == N) {
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
 int N;
  cin >> N;
  int i,j;
  int k=0;
 for(i=1;i<=9;i++){
   for(j=1;j<=9;j++){
     if(N == i*j) {
       k=1;
      break;
     }
   }
 }
 if(k==1)printf("Yes"); else printf("No");
  
 return 0;
}

Measured memory_bytes: 256