akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            int n = IO.RInt;
            long V = 0, E = 0;
            for (int i = 1; i <= n; i++)
            {
                V += (long)i * (n - i + 1);
            }
            for (int i = 0; i < n - 1; i++)
            {
                var ab = IO.RSInt;
                var a = ab[0];
                var b = ab[1];
                if (a > b) Swap(ref a, ref b);
                E += (long)a * (n - b + 1);
            }
            long ans = V - E;
            WriteLine(ans);
        }

        public static void Swap(ref int x, ref int y)
        {
            int tmp = x;
            x = y;
            y = tmp;
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 23188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		if(A == B) {
			System.out.println(C);
		} else if(A == C) {
			System.out.println(B);
		} else if(B == C) {
			System.out.println(A);
		}
		scan.close();

	}

}


Measured memory_bytes: 25556
import java.util.*;	
import java.math.BigInteger;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger a = sc.nextBigInteger();
		BigInteger b = sc.nextBigInteger();
		if(a.compareTo(b) == 1)System.out.println("GREATER");
		else if(a.compareTo(b) == -1)System.out.println("LESS");
		else System.out.println("EQUAL");
	}

}


Measured memory_bytes: 23636
from bisect import bisect_right
from random import randint, seed
from copy import deepcopy
import time

def calculate_score(i: int, last_i, S, D: int, C: list, T):
    rst = 0
    for d in range(1, D + 1):
        down = C[i] * (d - last_i[d])
        up = S[d][i] if i == T[d] else 0
        rst += up - down
    return rst


def create_last_i(i, T, D):
    _last_i = [0] * (D + 1)
    for d in range(1, D + 1):
        if T[d] == i:
            _last_i[d] = d
        else:
            _last_i[d] = _last_i[d - 1]
    return _last_i


def main():
    Z = 26
    D = int(input())
    C = list(map(int, input().split()))
    S = [tuple([None] * Z)] + [tuple(map(int, input().split())) for _ in range(D)]

    last = [0] * Z
    T = [0]
    for d in range(1, D + 1):
        maxScore = -float('inf')
        cntst = 0
        for i in range(26):
            tmp = last[i]
            last[i] = d
            up = S[d][i]
            down = sum(C[j] * (d - last[j]) for j in range(Z))
            score = up - down
            if maxScore < score:
                cntst = i
                maxScore = score
            last[i] = tmp
        last[cntst] = d
        T.append(cntst)

    last = [None] * Z
    V = [0] * Z
    for i in range(Z):
        last[i] = create_last_i(i, T, D)
    for i in range(Z):
        V[i] = calculate_score(i, last[i], S, D, C, T)

    score = sum(V)
    # maxScore = score
    # maxT = deepcopy(T)
    # print('Initial Score: ', score)

    max_iter = 10 ** 5
    seed(time.time())
    for _ in range(max_iter):
        d = randint(1, D)
        q = randint(0, Z - 1)

        p = T[d]
        if p == q:
            continue

        T[d] = q
        last_p = create_last_i(p, T, D)
        last_q = create_last_i(q, T, D)

        Vp = calculate_score(p, last_p, S, D, C, T)
        Vq = calculate_score(q, last_q, S, D, C, T)
        if V[p] + V[q] < Vp + Vq:
            score -= V[p] + V[q]
            score += Vp + Vq
            V[p] = Vp
            V[q] = Vq
            last[p] = last_p
            last[q] = last_q
        else:
            T[d] = p

    # if score > maxScore:
    for i in range(1, D + 1):
        print(T[i] + 1)
    # else:
    #     for i in range(1, D + 1):
    #         print(maxT[i] + 1)
    # # print(score)
    # for d in range(1, D + 1):
    #     print(T[d] + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 86220
import java.util.Scanner;

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

        int n = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            b[i] = scanner.nextInt();
            c[i] = scanner.nextInt();
        }

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

        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        for (int i = 1; i < n; i++) {
            dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][2]) + a[i];
            dp[i][1] = Math.max(dp[i - 1][0], dp[i - 1][2]) + b[i];
            dp[i][2] = Math.max(dp[i - 1][0], dp[i - 1][1]) + c[i];
        }

        int result = -1;
        for (int i = 0; i < 3; i++) {
            if (result < dp[n-1][i]) {
                result = dp[n-1][i];
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 93284
# ABC061C - Big Array
import sys

input = sys.stdin.readline

from itertools import accumulate
from bisect import bisect_left


def main():
    n, k = map(int, input().split())
    memo = [0] * (10 ** 5 + 1)

    for _ in range(n):
        i, j = map(int, input().split())
        memo[i] += j

    ans = bisect_left(list(accumulate(memo)), k)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 10624
#include <cstdio>
#include <iostream>
#include <tgmath.h>
#include <queue>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
typedef long long ll;
using namespace std;


typedef tuple<int,int,int> P;

int N;
vector<pair<int,int>> x;
vector<pair<int,int>> y;
vector<P> x_y;

struct UnionFind{
    vector<int> par;
    vector<int> rankTree;


    void init(int n){
        for(int i=0;i<n;i++){
            par.emplace_back(i);
        }
        rankTree.resize(n,1);       
    }

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

    bool same(int x,int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        if(same(x,y)){
            return;
        }

        int rootx = find(x);
        int rooty = find(y);
        
        if(rankTree[rootx] < rankTree[rooty]){
            par[rootx] = rooty;
            return;
        }
        par[rooty] = rootx;
        if(rankTree[rootx] == rankTree[rooty]){
            rankTree[rootx] ++;
        }
    }
};


int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >> b;
        x.emplace_back(a,i);
        y.emplace_back(b,i);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    for(int i=0;i<N-1;i++){
        x_y.emplace_back(x[i+1].first-x[i].first,x[i].second,x[i+1].second);
        x_y.emplace_back(y[i+1].first-y[i].first,y[i].second,y[i+1].second);
    }
    sort(x_y.begin(),x_y.end());


    UnionFind u1 = UnionFind();
    u1.init(N);

    ll ans =0;

    for(auto r: x_y){
        int i = get<1>(r);
        int j = get<2>(r);

        if(u1.same(i,j)){
            continue;
        }
        // cout << "i=" << i << "j=" <<j << endl;
        ans += get<0>(r);
        u1.unite(i,j);
    }


    cout << ans << endl;


}

Measured memory_bytes: 7144
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll vector <pll>
#pragma 03
using namespace std;
ll dp[200005];
vector <ll> adj[200005];
bool accessed[200005];
ll dfs(ll a){
	if (dp[a] >= 0) return dp[a];
	if (adj[a].size() == 0) return 0;
	accessed[a] = true;
	ll mx = 0;
	for (ll i = 0; i<adj[a].size(); i++){
		ll x = dfs(adj[a][i]);
		mx = max(mx, (x+1));
	}
	dp[a] = mx;
	return mx;
}
int main(){
	for (int i = 0; i<200005; i++){
		adj[i].clear();
		dp[i] = -1;
	}
	ll n, m, u, v;
	cin >> n >> m;
	for (int i = 0; i<m; i++){
		cin >> u >> v;
		adj[u].push_back(v);
	}
	for (int i = 1; i<=n; i++){
		dfs(i);
	}
	ll mx = 0;
	for (int i = 1; i<=n; i++) mx = max(mx, dp[i]);
	cout << mx << endl;
	return 0;
}
 


Measured memory_bytes: 11776
import collections
n = int(input())

s = []
for i in range(n):
  s.append(input())

c = collections.Counter(s)
c_max = c.most_common(1)[0][1]

c_word = [i[0] for i in c.items() if i[1] == c_max]

dic = sorted(c_word)

for i in range(len(dic)):
  print(dic[i])


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



long long int dp[100001][2];
long long int mod=1000000007;

long long int solve(map<int,vector<int> >&g,int color,int node,int par)
{
	if(g[node].size()==1 &&g[node][0]==par)
	{
		if(color==1)
		return(1);
	    else
	    return(2);
	}
	if(dp[node][color]!=-1)
	{
		return(dp[node][color]);
	}
	long long int op1=1;
	long long int op2=1;
	if(color==1)
	{
		for(auto x:g[node])
		{
			if(x!=par)
			op1=(op1*solve(g,0,x,node))%mod;
		}
		return(dp[node][color]=op1);
	}
	else
	{
		op1=1;
		op2=1;
		for(auto x:g[node])
		{
			if(x!=par)
			{
			op1=(op1*solve(g,1,x,node))%mod;
			op2=(op2*solve(g,0,x,node))%mod;
		    }

		}
		return(dp[node][color]=(op1+op2)%mod);
	}

}
int main(int argc, char const *argv[])
{
	long long int n;
	cin>>n;
	int i,j;
	int x,y;
	map<int,vector<int> >g;
	for(i=1;i<n;i++)
	{
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(i=0;i<=100000;i++)
	{
		for(j=0;j<2;j++)
		{
			dp[i][j]=-1;
		}
	}
	cout<<solve(g,0,1,1);
	return 0;
}

Measured memory_bytes: 21120
#include<iostream>
using namespace std;
int main()
{
  unsigned long long int n,sum=0,i,j,max,max1=0;
  cin>>n;
  unsigned long long int arr[n];
  for(i=0;i<n;i++){
      cin>>arr[i];
      if(arr[i]>max1)
      max1=arr[i];
  }
 // cout<<max1;
  max=arr[0];
  for(i=1;i<n;i++){
      if(arr[i]<max){
      sum=sum+(max-arr[i]);
     // max=arr[i];
      }
      else if(arr[i]>max)
      max=arr[i];
  }
  cout<<sum;
}

Measured memory_bytes: 4708
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>




int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);

printf("%.10lf\n",0.5*(double)a*b*sin(c*3.1415926535897932384626/180.0));
printf("%.10lf\n",(double)a+b+sqrt((double)a*a+(double)b*b-2*(double)a*b*cos(c*3.14159526535897932384626/180.0)));
printf("%.10lf\n",2*0.5*(double)a*b*sin(c*3.1415926535897932384626/180.0)/a);
}




Measured memory_bytes: 2064
import datetime


def is_YYMM(s: str) -> bool:
    try:
        datetime.datetime.strptime(s, "%y%m")
    except ValueError:
        return False
    else:
        return True


def is_MMYY(s: str) -> bool:
    try:
        datetime.datetime.strptime(s, "%m%y")
    except ValueError:
        return False
    else:
        return True


S = input()
if is_MMYY(S) and is_YYMM(S):
    print("AMBIGUOUS")
elif is_MMYY(S):
    print("MMYY")
elif is_YYMM(S):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 4460
#include <iostream>
using namespace std;
const int MAXN = 2e5 + 5;
int a[MAXN];
 
int main()
{
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) 
    {
        int x;
        cin >> x;
        a[x]++;
    }
 
    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
#define LOCAL 1
int main(){
	#if LOCAL
//	freopen("E:\\in.txt","r", stdin);
	#endif
	int n;
	cin >> n;
	int t = 0;
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		if(x == y){
			t++;
			if(t == 3) break;
		}else{
			t = 0;
		}
	}
	cout << (t==3 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vi p(n);
    for(int i=0;i<n;i++) cin>>p[i],p[i]--;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]==i)
        {
            ans++;
            if(i<n-1) swap(p[i],p[i+1]);
        }
    }
    print(ans);
}

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    a = [int(e) for e in lines[0].split(" ")]

    return (a, )


def solve(a):


    result = 'bust'
    if sum(a) <= 21:
        result = 'win'

    return result 


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace	std;
int main(){

  string s;
  int i,n;

  cin>>s;
  n=s.size()-1;
  if(n%2==1) n--;
  for(i=0;i<n/2;i++) if(s.substr(0,n/2-i)==s.substr(n/2-i,n/2-i)) break;
  cout<<n-i*2<<endl;
  return 0;

}



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

using namespace std;

int A[2000] = {0};
int n, q;

bool knap(int k, int j)
{
  if (k == 0) return true;
  if (j >= n) return false;
  if (k < A[j]) {
    return knap(k, j+1);
  } else {
    return knap(k, j+1) or knap(k-A[j], j+1);
  }
}

int main()
{
  // problem: pick k-1 breakpoints from among n objects
  // to minimize the maximum value of the objects contained
  // within a particular group of the objects
  // algorithm:
  // opt(k, n) = min_{i_k} max(opt(k-1, i_k), sum_{j=i_k, ..., n-1} A_j)
  // -> Binary search over 0..sum(A), see if there's a way to do it with that

  cin >> n;

  for(int i = 0; i<n; ++i) cin >> A[i];

  cin >> q;

  int k;
  for (int i =0; i<q; ++i) {
    cin >> k;
    cout << (knap(k, 0) ? "yes\n" : "no\n");
  }
}


Measured memory_bytes: 3088
using System;

namespace A___Ferris_Wheel
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            if (a <= 5)
            {
                Console.WriteLine (0);
            }
            else if (6 <= a && a <= 12)
            {
                Console.WriteLine (b / 2);
            }
            else
            {
                Console.WriteLine (b);
            }
        }
    }
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int N, M; cin >> N >> M;
	vector<int> a(M), b(M);
	rep(i, M) scanf("%d%d", &a[i], &b[i]), a[i]--, b[i]--;
	union_find uf(N * 2);
	rep(i, M) uf.unite(a[i], N + b[i]), uf.unite(N + a[i], b[i]);
	bool bipartite = true;
	bipartite = !uf.same(0, N);
	if (bipartite) {
		int x = 0, y = 0;
		rep(u, N) if (uf.same(0, u)) x++; else y++;
		cout << (ll)x * y - M << endl;
	}
	else cout << (ll)N * (N - 1) / 2 - M << endl;
}


Measured memory_bytes: 1920
import sys
grid=[line.strip() for line in sys.stdin.readlines()]
xgrid=["0"+grid[i]+"0" for i in xrange(9) if i%2==0]
ygrid=[grid[i] for i in xrange(9) if i%2==1]
ygrid.insert(5,"0"*5)
ygrid.insert(0,"0"*5)
graph=[[None]*5 for i in xrange(5)]
for y in xrange(5):
    for x in xrange(5):
        graph[y][x]=[ygrid[y][x],xgrid[y][x+1],ygrid[y+1][x],xgrid[y][x]]
nx,ny,dir=0,0,1
di=["U","R","D","L",]
dx=[0,1,0,-1]
dy=[-1,0,1,0]
log=[]
while True:
    for i in xrange(4):
        if graph[ny][nx][(dir+3)%4]=="1":
            dir=(dir+3)%4
            log.append(di[dir])
            nx,ny=nx+dx[dir],ny+dy[dir]
            break
        dir=(dir+1)%4
    if nx==0 and ny==0:break
print "".join(log)

Measured memory_bytes: 6280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod (ll)1e9+7
vector<ll> v;
//map<ll,ll> mp;

int main()
{
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
snm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()
ans=10**13
for i in range(1,int(n**0.5)+1):
    j=n//i
    if n%i==0:
        ans=min(ans,i+j)
print(ans-2)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;


int main() {


    string s;

    cin >> s;

    string result;

    int f=0;
    int l=0;


    for (int i = 0; i < s.length(); i++) {

        if (s[i] == 'A') {
            f = i;
            break;
        }

    }

    for (int i = (s.length()-1); i > 0; i--) {
        if (s[i] == 'Z') {
            l = i;
            break;
        }
    }


    cout << (l-f+1) << "\n";

    return 0;
}

Measured memory_bytes: 640
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	int h,a;
	cin>>h>>a;
	if(h%a)
		cout<<h/a+1;
	else
		cout<<h/a;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void readInt(int &x) {
	x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;
}
inline void readLong(ll &x) {
	x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;
}
/*================Header Template==============*/
string s;
int main() {
	cin>>s;
	string tmp=s.substr(0,4);
	if(tmp=="YAKI")
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int m[2][4],n,i,j,k,
		x[4][4]={{1,-1,-1,-1},{1,1,1,-1},{1,-1,1,1},{1,1,-1,1}},
		y[4][4]={{0,1,2,3},{1,0,3,2},{2,3,0,1},{3,2,1,0}};
	for(;scanf("%d",&n),n;)
	{
		for(;n--;)
		{
			for(i=0;i<2;i++)
				for(j=0;j<4;j++)
					scanf("%d",&m[i][j]);
			for(i=0;i<4;i++,printf("%d%s",k,i==4?"\n":" "))
				for(j=k=0;j<4;j++)
					k+=m[0][j]*m[1][y[i][j]]*x[i][j];
		}
	}
	return 0;
}

Measured memory_bytes: 600
#
# Hanafuda shuffle (AOJ id=1129)
#
n, r = gets.chomp.split.map { |s| s.to_i }
while [n,r] != [0,0]
  # p [n,r]
  
  cards = (1..n).to_a
  cards.reverse!
  
  # p cards
  
  r.times do
    _p, c = gets.chomp.split.map { |s| s.to_i}
    u = cards[0, _p-1]
    cards[0, c] = cards[_p-1, c]
    cards[c, _p-1] = u

    # p cards
  end
  puts cards[0]
  
  n, r = gets.chomp.split.map { |s| s.to_i }
end

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

const int DIM = 1e5 + 5;

deque<int> deq;

int main(void) {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        
        if ((i + n) % 2 == 0)
            deq.push_front(x);
        else
            deq.push_back(x);
    }
    
    for (int x : deq)
        cout << x << " ";
    return 0;
}


Measured memory_bytes: 3072
char s[258],p[258],f[];a,v,i,t,b;main(k){if(~scanf("%*d\n%[^\n]\n"+!k*4,s))for(a=0;++a<27;){for(memset(f,b=i=v=-1,26);++i<26;f[t]=i)v&=f[t=a*i%26];for(;!~v&&++b<26;p[i]=0,strstr(p,"that")-strstr(p,"this")&&main(0*puts(p)))for(i=0;s[i];i++)p[i]=s[i]-32?(f[s[i]-97]+b)%26+97:32;}exit(0);}

Measured memory_bytes: 0
h,w,n=map(int,input().split())
d=dict()
def change(a,b):
    global h,w,d
    if 1<=a<h-1 and 1<=b<w-1:
        if (a,b) in d:
            d[(a,b)]+=1
        else:
            d[(a,b)]=1
for i in range(n):
    a,b=map(int,input().split())
    a-=1
    b-=1
    change(a,b)
    change(a-1,b-1)
    change(a-1,b+1)
    change(a+1,b-1)
    change(a+1,b+1)
    change(a-1,b)
    change(a+1,b)
    change(a,b-1)
    change(a,b+1)
ans=[0]*10
ans[0]=(h-2)*(w-2)
#print(d)
for i in d:
    ans[d[i]]+=1
    ans[0]-=1
for i in range(10):
    print(ans[i])



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

struct List{
    int val;
    List *pre, *next, *skip, *preskip;
    List (int x){
        val = x;
        next = NULL;
        pre = NULL;
        skip = NULL;
        preskip = NULL;
    }
};

typedef List *Node;

map<int, Node> M;

Node Addfront(Node head, Node &last, int x){
    Node temp = new List(x);
    if (M[x] != NULL) {
        temp->skip = M[x];
        M[x]->preskip = temp;
    }
    M[x] = temp;
    if (head == NULL){
        head = temp;
        last = temp;
    }
    else {
        temp->next = head;
        head->pre = temp;
        head = temp;
    }
    return head;
}

Node DeleteFirst(Node head, Node &last){
    //cout << '*';
    if (head == NULL) return head;
    if (head == last){
        M[head->val] = NULL;
        last = NULL;
        return NULL;
    }
   // cout << head->val << '\n';

    M[head->val] = M[head->val]->skip;

    head = head->next;
    head->pre = NULL;
   // cout << head->val << ";" ;
    return head;
}

void Print(Node head){
    if (head == NULL){
        cout << '\n';
        return;
    }
    cout << head->val;
    head = head->next;
    while (head != NULL){
        cout << " " << head->val;
        head = head->next;
    }
    cout << '\n';
}

Node DeleteLast(Node head, Node &last){
    if (head == NULL) return head;
    if (head == last)
    {
        M[head->val] = NULL;
        last = NULL;
        return NULL;
    }
    if (last->preskip != NULL) last->preskip->skip = NULL;
    else M[last->val] = NULL;
    last = last->pre;
    last->next = NULL;
    return head;
}

Node DeleteVal(Node head, Node &last, int x){
    if (M[x] == NULL || head == NULL) return head;
    if (M[x] == head){
        head = DeleteFirst(head, last);
        //M[x] = M[x]->skip;
    }
    else{
        if (M[x] == last){
            head = DeleteLast(head, last);
           // M[x] = NULL;
        }
        else{
            Node L = M[x]->pre;
            Node R = M[x]->next;
            L->next = R;
            R->pre = L;
            M[x] = M[x]->skip;
        }
    }
    return head;
}

void solve(){
    Node head = NULL;
    Node last = NULL;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        int x;
        cin >> s;
        if (s == "insert"){
            cin >> x;
            head = Addfront(head, last, x);
        }
        else{
            if (s == "delete"){
                cin >> x;
                head = DeleteVal(head, last, x);
              //  cout << "*";
            }
            else{
                if (s == "deleteFirst")
                    head = DeleteFirst(head, last);
                else{
                    head = DeleteLast(head, last);
                }
            }
        }
       // cerr << i << '\n';
        //Print(head);
    }
    Print(head);
}

void doc(){
    freopen("OB.inp", "r", stdin);
    freopen("OB.out", "w", stdout);
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
   // doc();
    solve();
}



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

int main()
{
  int N;
  cin >> N;
  vector<int> A;
  int *B;
  int n;
  int i;
  int k;

  B = (int *)malloc(sizeof(int)*N);

  for (i=0;i<N;i++){
    cin >> n;
    A.push_back(n);
    B[A[i]-1] = i + 1;
  }

  for (i=0;i<N;i++){
    cout << B[i] << " ";
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 1784
from sys import stdin
N = int(stdin.readline().rstrip())
cards = [list(c) for c in stdin.readline().rstrip().split()]
c_cards = cards.copy()

def bubble_sort(a, n):
    for i in range(0, n):
        for j in range(n-1, i, -1):
            if a[j][1] < a[j-1][1]:
                a[j], a[j-1] = a[j-1], a[j]
    return a

def select_sort(a, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j][1] < a[minj][1]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
    return a

bubbled = [''.join(c) for c in bubble_sort(cards, N)]
selected = [''.join(c) for c in select_sort(c_cards, N)]
print(*bubbled)
print('Stable')
print(*selected)
if selected == bubbled:
    print('Stable')
else:
    print('Not stable')


Measured memory_bytes: 5624
using System.Linq;
using static System.Console;

namespace ABC171
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            SolveB();
        }

        static void SolveB()
        {
            var nk = ReadLine().Split(' ').Select(int.Parse);
            var k = nk.Last();
            var prices = ReadLine().Split(' ').Select(int.Parse).OrderBy(x=>x).ToList();
            var sum = 0;
            for (var i = 0; i < k; i++)
            {
                sum += prices[i];
            }
            WriteLine(sum);
            
        }
    }
}

Measured memory_bytes: 28456
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s, t;
  cin >> s >> t;
  ll n = s.size();
  ll ans = 0;
  REP(i, n){
    if(s[i] != t[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int n, m; cin >> n >> m;
    vector<int> h(n+1, 0), ma(n+1, 0);
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= m; i++) {
        int a, b; cin >> a >> b;
        ma[a] = max(ma[a], h[b]);
        ma[b] = max(ma[b], h[a]);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += h[i] > ma[i];
    }
    cout << ans << endl;
}

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

int main(){
  int n,T;
  cin >> n >> T;
  int c,t,min_c=10000;
  
  rep(i,n){
    cin >> c >> t;
    if(t<=T){
      if(c < min_c){
        min_c = c;
      }
    }
  }
  
  if(min_c==10000){
    cout << "TLE" << endl;
  }else{
    cout << min_c << endl;
  }
  
  return 0;

}


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

int main() {
  int n;
  std::cin >> n;
  string w[n];
  for (int i = 0; i < n; i++) {
    std::cin >> w[i];
  }
  // input all w[i]

  for (int i = 0; i < n-1; i++) {
    if(w[i][w[i].size()-1] != w[i+1][0]){
      std::cout << "No" << '\n';
      return 0;
    }

    for (int j = i + 1; j < n; j++) {
      if (w[i] == w[j]) {
        std::cout << "No" << '\n';
        return 0;
      }
    }
  }

  std::cout << "Yes" <<'\n';
  return 0;
}

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

class Mondai
{
    static void Main()
    {
        var XA = Console.ReadLine().Split(' ').Select(n => Int32.Parse(n)).ToArray();
        var X = XA[0];
        var A = XA[1];
        Console.WriteLine(X<A?0:10);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,k,d,c;
    cin>>a>>b>>k;
    c=(a+k)-1;
    d=(b-k)+1;
    for(int i=a;i<=b;i++)
    {
        if(i<=c||i>=d)
        {
            cout<<i<<endl;
        }

    }
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector< vector<int> > open(N,vector<int>(10));
	for(int i=0;i<N;++i){
		for(int t=0;t<10;++t){
			cin>>open[i][t];
		}
	}
	
	vector< vector<int> > P(N,vector<int>(11));
	for(int i=0;i<N;++i){
		for(int num=0;num<=10;++num){
			cin >> P[i][num];
		}
	}

	int ans = -INF;
	for(int J=1;J<(1<<10);++J){//開く時間
		int res = 0;
		for(int i=0;i<N;++i){
			int count = 0;//同時
			for(int t=0;t<10;++t){
				if( (open[i][t]==1) && ((J>>t)&1 ) ){
					++count;
				}
			}
			res += P[i][count];
		}
		ans = max(ans,res);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n;

struct box{
    int w,s,v;
} a[1005];

ll dp[1005][20005],ans;

bool comp(box a, box b){
    return a.w+a.s<b.w+b.s;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i].w >> a[i].s >> a[i].v;
    }
    sort(a+1,a+n+1,comp);
    for(int i=1;i<=n;i++){
        for(int j=0;j<=20000;j++){
            if(a[i].w>j || a[i].s<j-a[i].w) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i].w]+a[i].v);
            ans=max(ans,dp[i][j]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 156544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        int[] a = nia(n);

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

        out.println(ans);
    }

    int gcd(int a, int b) {
        return a == 0 ? b : gcd(b % a, a);
    }

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

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

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

	int q;cin>>q;
	while(q--){
		int k;cin>>k;
		cout<<(binary_search(a.begin(),a.end(),k)?1:0)<<endl;
	}
  return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MOD 1000000007
#define accm(i) ( (i)%2 ? od[((i)-1)/2] : ev[(i)/2])
#define acc(i) ( i%2 ? cpod[(i-1)/2] : cpev[i/2])
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;

int f(int n) {
	return (n*n+4)/8;
}

int main(){
	int n, a;

	scanf("%d %d", &n, &a);
	vector<int> num(n);
	REP(i, n) {
		scanf("%d", &num[i]);
	}
	long long int dp[51][51][2501] = {};
	dp[0][0][0] = 1;
	REP(i, n) {
		REP(j, n) {
			REP(k, 2501) {
				if (dp[i][j][k]) {
					dp[i + 1][j + 1][k+num[i]]+= dp[i][j][k];
					dp[i + 1][j][k]+= dp[i][j][k];
				}
			}
		}
	}
	long long int ans = 0;
	for(int i = 1; n+1 > i; i++) {
		ans += dp[n][i][a*i];
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 51072
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	ll x;
	cin >> x;
	ll count = 1;
	int n;
	if (x % 11 <= 6&&x%11!=0) {
		n = 1;
	}
	else if(x%11!=0) {
		n = 2;
	}
	else {
		n = 0;
	}
	cout << (x / 11) * 2 + n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>

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

using namespace std;

int n;
double x[4];
double y[4];

int main(){
	scanf("%d", &n);
	rep(i, n){
		rep(j, 4){
			scanf("%lf%lf", x + j, y + j);
		}

		double dx[2];
		double dy[2];
		dx[0] = x[0] - x[1];
		dx[1] = x[2] - x[3];
		dy[0] = y[0] - y[1];
		dy[1] = y[2] - y[3];

		// printf("(%lf, %lf) (%lf, %lf)\n", dx[0], dy[0], dx[1], dy[1]);

		printf("%s\n", fabs(dx[0] * dy[1] - dx[1] * dy[0]) < 1e-12 ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1048
#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--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

vector<int> v;

int main(){
    int n;
    cin >> n;
    rep(i, 2*n){
        int l;
        cin >> l;
        v.push_back(l);
    }
    sort(v.rbegin(), v.rend());
    
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += v[2*i+1];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3564
'use strict';
(function(input){
  input=input.trim();
  var A=(input[0]+input[1])-0;
  var B=(input[2]+input[3])-0;
  var a=(A<=12&&A>=1);
  var b=(B<=12&&B>=1);
  var ans=(a&&b)?'AMBIGUOUS':a?'MMYY':b?'YYMM':'NA';
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define vi vector<int>
#define umap unordered_map
#define pii pair<int, int>
#define vpii vector<pii>
#define uset unordered_set
#define frw(i, a, b) for(int i = (a); i < (b); i++)
#define bck(i, a, b) for(int i = (a); i > (b); i--)
#define T() int testcases; cin >> testcases; frw(TC, 1, testcases + 1)
#define tez ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define fi first
#define se second
#define pow asdihagsiduh
#define pub push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) (int)(a.size())
#define sq(a) ((a) * (a))

#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> 
void ZZ(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}

//console o/p without variable names
#define trace1(...) ZZZ(__VA_ARGS__)
template<typename Arg1>
void ZZZ(Arg1&& arg1){
    cerr << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZZ(Arg1&& arg1, Args&&... args){
    cerr << arg1 << ' ';
    ZZZ(args...);
}

const int MOD = 1e9 + 7;

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

int sub(int a, int b, int m = MOD){
    return add(a, m - b, m);
}

int mult(int a, int b, int m = MOD){
    a %= m, b %= m;
    return 1ll * a * b % m;
}

int fpow(int x, int y, int m = MOD){
    int res = 1;
    if(y < 0)   y += m - 1;   //only if m is prime
    while(y > 0){
        if(y & 1)   res = mult(res, x, m);
        x = mult(x, x, m);
        y >>= 1;
    }
    return res;
}

int inv(int a, int md = MOD){
    a %= md;
    if(a < 0)   a += md;
    int b = md, u = 0, v = 1;
    while(a){
        int t = b / a;
        b -= t * a; swap(a, b);
        u -= t * v; swap(u, v);
    }
    if(u < 0)   u += md;
    return u;
}

const int N = 1e5 + 5;

vi fac(N, 1), ifac(N, 1);

int ncr(int n, int r){
    if(r > n)   return 0;
    return mult(fac[n], mult(ifac[r], ifac[n - r]));
}

void precomp(){
    frw(i, 2, N)    fac[i] = mult(fac[i - 1], i);
    ifac[N - 1] = inv(fac[N - 1]);
    bck(i, N - 2, 0)    ifac[i] = mult(ifac[i + 1], i + 1);
}

signed main(){
    tez
    precomp();
    int n, k; cin >> n >> k;
    vi a(n + 1);
    frw(i, 1, n + 1)    cin >> a[i];
    sort(a.begin() + 1, a.end());
    int ans = 0;
    frw(i, 1, n + 1){
        ans = sub(ans, mult(a[i], ncr(n - i, k - 1)));
        ans = add(ans, mult(a[i], ncr(i - 1, k - 1)));
    }
    cout << ans;
}

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

int m(int m, int n)
{
    return std::min(m, n-m);
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i=0; i<n; i++) scanf(" %d", &a[i]);

    std::sort(a.begin(), a.end());
    int ai = a[n-1];
    int aj = a[0];
    for(int i=1; i<n-1; i++){
        if(m(aj, ai) < m(a[i], ai)) aj = a[i];
    }

    std::cout << ai << " " << aj << std::endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
ll MOD = 1000000007;
ll qpow(ll a, ll b, ll p){//a的b次方求余p
    ll res = 1;
    while(b){
         if(b & 1) res = (res * a) % p;
         a = (a * a) % p;
         b >>= 1;
    }
    return res;
}
ll inv(ll x, ll p){
    return qpow(x, p-2, p);
}
ll C(int n, int m) {
    ll x = 1, y = 1;
    for (int i = n; i >= n - m + 1; i--) {
        x = x * i % MOD;
    }
    for (int i = 1; i <= m; i++) {
        y = y * i % MOD;
    }
    return x * inv(y, MOD) % MOD;
}
int main () {
    int n, a, b;
    cin >> n >> a >> b;
    ll sum = 0;
    sum = qpow(2, n, MOD) - C(n, a) - C(n, b) - 1;
    while (sum < 0) sum += MOD;
    cout << sum << "\n";
    return 0;
}





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

using namespace std;

int main() {
    int n;
    cin >> n;
    int ct = 0;
    int ch = 0;
    for (int i = 0; i < n; i++) {
        string t, h;
        cin >> t >> h;
        if (t > h) {
            ct += 3;
        } else if (t == h) {
            ct++;
            ch++;
        } else {
            ch += 3;
        }
    }
    cout << ct << " " << ch << endl;
    return 0;
}



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

int main() {
  int n, m = 0, o = 0;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) {
    cin >> h.at(i);
    if(m <= h.at(i)) {
      o++;
      m = max(m, h.at(i));
    }
  }
  cout << o << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

int main(){
    ll ans = 0;
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    ans += (a[2]-a[0])/2;
    //cout << ans << endl;
    ans += (a[2]-a[1])/2;
    //cout << ans << endl;
    if((a[2]-a[0])%2 != 0 && (a[2]-a[1])%2 != 0){
        ans++;
    }else if((a[2]-a[0])%2 != 0 || (a[2]-a[1])%2 != 0){
        ans += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 20

typedef long long ll;
using namespace std;


int main(){
    int N,K;

    cin >> N >> K;
    vector<int> p(N);
    for(int i = 0 ; i < N ; i++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ans =0 ;
    for(int i = 0 ; i < K ; i++){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define pb push_back
#define mk make_pair

#define flu(i, s, e) for(int i = s; i < e; i++)
#define fld(i, s, e) for(int i = s; i >= e; i--)


int main(){

	char arr[101];
	int k; scanf("%d %s", &k, arr);
	int n = strlen(arr);
	
	flu(i, 0, min(k, n)) printf("%c", arr[i]);
	if(k < n) printf("...");

	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include<cstring>
using namespace std;
int main()
{
string S;
cin>>S;
if (S=="Sunny") 
cout<<"Cloudy"<<endl;
else if (S=="Cloudy") 
cout<<"Rainy"<<endl;
else if (S=="Rainy") 
cout<<"Sunny"<<endl;
return 0;
}



Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
//string s;
int main (){
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	char a[n], b[n];
	cin >> a >> b;
	for (int i = 0; i<n; i++){
		cout << a[i] << b[i];
	}
	cout << endl;
}
	
	


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;


const int MOD = (int)1e9 + 7;
int n;
int mul(int a, int b) {
	return (1ll * a * b) % MOD;
}

// Legendre's formula
// x! 을 나누는 p의 최대 exp를 반환한다.
int Legendre(int x, int p)
{
	int ret = 0;
	while(x > 0)
	{
		x /= p;
		ret += x;
	}
	return ret;
}

VI sieve()
{
	VB prime(n + 1, true);
	prime[0] = prime[1] = false;

	int m = sqrtl(n);
	for(int i = 2; i <= m; ++i)
		if(prime[i] == true)
			for(int j = i * i; j <= n; j += i)
				prime[j] = false;

	VI ret;
	for(int i = 2; i <= n; ++i)
		if(prime[i])
			ret.emplace_back(i);
	return ret;
}

int factDiv()
{
	VI prime = sieve();

	int ret = 1;
	for(auto p : prime)
	{
		int exp = Legendre(n, p);
		ret = mul(ret, exp + 1);
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;

	cout << factDiv() << endl;

	return 0;
}

Measured memory_bytes: 256