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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >>n;
    string pre,locate;
    cin >> locate;
    bool ok = true;
    vector<string> m;
    m.push_back(locate);
    rep(i,0,n-1){
        pre = locate;
        cin >> locate;
        if(find(all(m),locate)!=m.end()) ok = false;
        m.push_back(locate);
        if(pre[pre.size()-1] != locate[0]) ok = false;

    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define lli long long unsigned int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 0
#define LIM 1000000007

int main(){
	lli n,a;
	cin>>n>>a;
	vector<lli> x;
	x.resize(n);
	REP(i,n)cin>>x[i];

	vector<vector<lli>> dp(n+1,vector<lli>(n*a+1));

	dp[0][0]=1;
	REP(i,n){
		for(lli j=n;j>0;j--){
			for(lli k=x[i];k<n*a+1;k++){
				dp[j][k] += dp[j-1][k-x[i]];
			}
		}
	}
	lli ans=0;
	for(lli i=1;i<=n;i++)ans += dp[i][i*a];

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

Measured memory_bytes: 1280
N, H = map(int, input().split())
max_a = 0
blist = []
counter = 0
killed = False
for _ in range(N):
    a, b = map(int, input().split())
    max_a = max(a, max_a)
    blist.append(b)

for b in sorted(blist, reverse=True):
    if H <= 0:
        killed = True
        break
    if b > max_a:
        counter += 1
        H -= b
if killed:
    print(counter)
elif H % max_a == 0:
    print(counter + H // max_a)
else:
    print(counter + H // max_a + 1)


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

int main(){
    int N, K;
    cin >> N >> K;
    int res = 0;
    for(int i =0; i < N; i++){
        int h;
        cin >> h;
        if(h >=K) res ++;
    }
    cout << res << endl;
}

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

int main()
{
    
    string S;
    cin >> S;
    
    int count = 0;
    if (S[0] == 'o') {
        count++;
    }
    if (S[1] == 'o') {
        count++;
    }
    if (S[2] == 'o') {
        count++;
    }
    cout << 700 + 100 * count << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

/**
 * Counting of Trees
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();

            LRC[] lrcs = new LRC[M];
            for (int i = 0; i < M; i++) {
                LRC lrc = new LRC();
                lrc.L = sc.nextInt() - 1;
                lrc.R = sc.nextInt() - 1;
                lrc.C = sc.nextLong();
                lrcs[i] = lrc;
            }

            Arrays.sort(lrcs, (o1, o2) -> {
                int compare = Integer.compare(o1.L, o2.L);
                if (compare != 0) {
                    return compare;
                }
                return Long.compare(o1.C, o2.C);
            });

            long[] d = new long[N];
            for (int i = 1; i < N; i++) {
                d[i] = Long.MAX_VALUE;
            }

//            int L = -1;
//            int R = -1;
            for (int i=0;i<M;i++) {
                if (d[lrcs[i].L] == Long.MAX_VALUE) {
                    break;
                }

//                int t = lrcs[i].L + 1;
//                if (L == lrcs[i].L) {
//                    if (R >= lrcs[i].R) {
//                        continue;
//                    }
//                    t = R + 1;
//                }

                for (int j = lrcs[i].R; j >= lrcs[i].L + 1; j--) {
                    if (d[j] < d[lrcs[i].L] + lrcs[i].C) {
                        break;
                    }
                    d[j] = d[lrcs[i].L] + lrcs[i].C;
                }

//                L = lrcs[i].L;
//                R = lrcs[i].R;
            }

            long ans = d[N - 1];
            if (ans == Long.MAX_VALUE) {
                ans = -1;
            }

            System.out.println(ans);
        }
    }

    static class LRC {

        int L;

        int R;

        long C;

    }

}


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

class Com
{
public:
	string p,c;
	Com(){}
	
	Com(string c, string p)
	:c(c),p(p)
	{}
};

bool ck(string a, string b)
{
	for(int i=0; i<b.size(); i++)
	{
		if(b[i]=='?') continue;
		if(b[i]!=a[i]) return false;
	}
	
	return true;
}

int main()
{
	int N,M;
	while(cin >> N >> M, (N||M))
	{
		vector<Com> Filt(N);
		for(int i=0; i<N; i++)
		{
			string c,a,b;
			cin >> c >> a >> b;
			Filt[i]=Com(c, (a+b));
		}
		
		int cnt=0;
		stringstream ss;
		
		for(int i=0; i<M; i++)
		{
			string a,b,c,d;
			cin >> a >> b >> c;
			d=(a+b);
			
			for(int i=N-1; i>=0; i--)
			{
				if(ck(d,Filt[i].p))
				{
					if(Filt[i].c=="permit")
					{
						ss << a << " " << b << " " << c << endl;
						cnt++;
					}
					else
					{
						break;
					}
				}
			}
		}
		cout << cnt << endl;
		cout << ss.str();
	}
}

Measured memory_bytes: 1064
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e9;
// cout << "Case #" << index << " :IMPOSSIBLE";

typedef int Weight;
struct Edge
{ //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
bool operator<(const Edge &e, const Edge &f)
{
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
             e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
//引数 g:隣接リスト,s:始点,dist:各頂点までの距離が入る,prev:最短路木の親頂点が入る
//戻値 なし
void shortestPath(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev)
{
  int n = g.size();
  dist.assign(n, INF);
  dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q;
  Q.push(Edge(-2, s, 0));
  while (!Q.empty())
  {
    Edge e = Q.top();
    Q.pop();
    if (prev[e.dst] != -1)
      continue;
    prev[e.dst] = e.src;
    for (auto f = g[e.dst].begin(); f != g[e.dst].end(); f++)
    {
      if (dist[f->dst] > e.weight + f->weight)
      {
        dist[f->dst] = e.weight + f->weight;
        Q.push(Edge(f->src, f->dst, e.weight + f->weight));
      }
    }
  }
}

//引数 prev:最短路木の親頂点集合,t:終点
//戻値 path:sからtへの最短経路
vector<int> buildPath(const vector<int> &prev, int t)
{
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,m;
    cin>>n>>m;
    Graph g(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        g[a].push_back(Edge(a,b,1));
        g[b].push_back(Edge(b,a,1));
    }
    vector<Weight> dist;
    vector<int> prev;
    shortestPath(g,0,dist,prev);
    rep(i,n){
        if(dist[i]==INF){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep3(i,1,n){
        cout<<prev[i]+1<<endl;
    }
}


Measured memory_bytes: 16024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcm(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcm(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcm(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    /*int a, b;
    cin >> a >> b;
    int count = 1;
    int count_a = 0;
    bool ok = false;
    if(count >= b) ok = true;
    while(!ok) {
        count--;
        count += a;
        count_a++;
        if(count >= b) ok = true;
    }
    cout << count_a << endl;*/
    int i = 0;
    int a, b;
    cin >> a >> b;
    int count = 1;
    int a_count = 0;
    int k = 1;
    if(b == 1) {
        cout << 0 << endl;
        return 0;
    }
    do{
        i++;
        k = (a - 1) * i + 1;
    }while(k < b);
    cout << i << endl;
}

Measured memory_bytes: 3644
#include <cmath>
#include <limits>
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

int main(){
  double n,d;
  cin >> n >> d;
  vector<double> x(n);
  vector<double> y(n);
  for (int i =0; i< n; i++){
    cin >> x[i] >> y[i];
  }
  int count = 0;
  for (int i =0; i< n; i++){
    if (sqrt(x[i]*x[i] + y[i]*y[i]) <= d){
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 6480
a,b = map(int,input().split())

result = 0
if a > b:
	result = result + a
	a = a -1
else:
	result = result + b
	b = b -1

if a > b:
	result = result + a
	a = a -1
else:
	result = result + b
	b = b - 1
print(result)

Measured memory_bytes: 3060
N = int(input())
An = list(map(int, input().split()))
suma = sum(An)
cnt = [0]*(10**5+1)
for a in An:
    cnt[a] += 1
Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())
    suma += (c-b)*cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(suma)


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

using namespace std;

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

void solve(){
	int a;
	cin >> a;
	cout << (a + a*a + a*a*a) << endl;
}

int32_t main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int tc = 1;
	//cin >> tc;
	while(tc--)
		solve();
}


Measured memory_bytes: 3624
N = int(input())

AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort(key=lambda x: x[1], reverse=True)

# print(AB)
fa, fb = AB[0][0], AB[0][1]
t = fb - fa
for a, b in AB[1:]:
    if b <= t:
        t = b
    t -= a
    # print(t)

if t >= 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38320
#include<iostream>
#include<list>
#include <algorithm>
#include<cmath>
using namespace std;

void cheese(int x,int y,int z){
    int number,tmp;
    list<int> hole;
    cin >> number;
    double xy = sqrt(x/2*x/2+y/2*y/2);
    double xz = sqrt(x/2*x/2+z/2*z/2);
    double zy = sqrt(z/2*z/2+y/2*y/2);
    
    for(int i=0;i<number;i++){
        cin >> tmp;
        hole.push_back(tmp);
    }
    list<int>::iterator it = hole.begin();
    for(;it != hole.end();it++){
        double r = (double)*it;
        //3つの面に対して原点を中心とした長方形を作る.
        if((r>xy)||(r>xz)||(r>zy))
            cout << "OK" << endl;
        else {
            cout << "NA"<< endl;
        }
    }
    
}

int main(){
    int x,y,z;
    cin >>x >> y>> z;
    while(x!=0 && y!=0&&z!=0){
        cheese(x,y,z);
        cin >> x>>y>>z;
    }
    return 0;
}

Measured memory_bytes: 1184
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

limits = list()
limits.append(a)
limits.append(b)
limits.append(c)
limits.append(d)
limits.append(e)

min_v, min_i = limits[0], 0
for i, limit in enumerate(limits):
    if min_v > limit:
        min_v = limit
        min_i = i
if min_v >= n:
    time = 5
elif n % min_v == 0:
    time = 5 + n // min_v - 1
else:
    time = 5 + n // min_v

print(time)


Measured memory_bytes: 3064
package main

import (
  "bufio"
  "container/list"
  "fmt"
  "os"
  "strconv"
  "strings"
)

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int = NextInt()
  var a []int = NextIntArray()
  lst := list.New()
  for i:=0;; {
    lst.PushBack(a[i])
    i++
    if i == n { break }
    lst.PushFront(a[i])
    i++
    if i == n { break }
  }
  var v int
  if n%2 == 0 {
    v,_ = lst.Remove(lst.Front()).(int)
    fmt.Printf("%d",v)
    for ;lst.Len()>0; {
      v,_ = lst.Remove(lst.Front()).(int)
      fmt.Printf(" %d",v)
    }
  } else {
    v,_ = lst.Remove(lst.Back()).(int)
    fmt.Printf("%d",v)
    for ;lst.Len()>0; {
      v,_ = lst.Remove(lst.Back()).(int)
      fmt.Printf(" %d",v)
    }
  }
  fmt.Println()
}

Measured memory_bytes: 18432
class disjoint_set:
    def __init__(self,num):

        self.array=[0]+[[i,0,1] for i in range(1,num+1)]  # our set
    
    def union(self,a,b):
        
        ''' a and b are the vertices that we want to connect them to each other '''
        
        a=self.find(a) # finds the ancestor of a
        b=self.find(b) # finds the ancestor of b
    
        if a==b:
            # if the ancestors of a and b are the same , do nothing
            return False
    

        # connecting two graph components to each other

        if self.array[a][1] > self.array[b][1] :
            self.array[b][0]=a
            self.array[a][2]+=self.array[b][2]
        
        elif self.array[a][1] < self.array[b][1] :
            self.array[a][0]=b
            self.array[b][2]+=self.array[a][2]

        else:
            self.array[a][0]=b
            self.array[b][1]+=1
            self.array[b][2]+=self.array[a][2]
        return True
            
    def find(self,a):
        p=[]
        while self.array[a][0]!=a :
            p.append(a)
            a=self.array[a][0]
        for i in p:
            self.array[i][0]=a
        return a
        

n,m=map(int ,input().split())
friend = disjoint_set(n)
for _ in range(m):
    x,y=map(int ,input().split())
    friend.union(x,y)

ans=-10
for i in range(1,n+1):
    if friend.array[i][0]==i :
        ans=max(ans,friend.array[i][2])

print(ans)

Measured memory_bytes: 37360
#include <bits/stdc++.h>
#define int long long
#define N 10010
using namespace std;
const int INF = 1LL<<55;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}
int h,w,n,A[N],ans[101][101];

int dx[] = {1,-1};

signed main(){
  cin>>h>>w>>n;
  for(int i=0;i<n;i++) cin>>A[i];
  
  
  int x = 0,y = 0;
  for(int i=0;i<n;i++){
    while(A[i]--){
      ans[y][x] = i+1;
      int nx = x+dx[y%2];
      int ny = y;
      if(nx < 0 || nx >= w) nx = x,ny = y+1;
      x = nx;
      y = ny;
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j)cout<<" ";
      cout<<ans[i][j];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int abs(int x)
{
	if(x<0)return -x;
	return x;
}
int mp[5000000];
int main()
{
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int ans=min(j-i,min(abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1));
			mp[ans]++;
		}
	}
	for(int i=1;i<=n-1;i++)
	{
		printf("%d\n",mp[i]);
	}
	return 0;
}

Measured memory_bytes: 256
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter { s: String::new() }
    }

    fn print<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

fn main() {
    let mut printer = ContestPrinter::new();
    let c: Vec<_> = (0..3).map(|_| readlvec!(i32)).collect();
    // debug!(c);
    for x in 0..c[0][0]+1 {
        for y in 0..c[1][0]+1 {
            for z in 0..c[2][0]+1 {
                let vals = [c[0][0]-x, c[0][1]-x, c[0][2]-x];
                // debug!(vals);
                let xyz = [x, y, z];
                let mut f = true;
                for i in 0..3 {
                    for j in 0..3 {
                        if vals[j] != c[i][j]-xyz[i] {
                            f = false;
                        }
                    }
                }
                if f {
                    printer.println("Yes");
                    return;
                }
            }
        }
    }
    printer.println("No");
}


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

using namespace std;

int k,a,b;

int main() {

  cin >>k>>a>>b;

  for(int i=a ; i<=b ; i++){
    if(i%k==0){
      cout << "OK"<<endl;
      return 0;
    }
  }


  cout << "NG" << endl;


  
  
  return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c=-202,n;
    scanf("%d%d",&a,&b);
    n=a+b;
    if(n>c)c=n;
    n=a-b;
    if(n>c)c=n;
    n=a*b;
    if(n>c)c=n;
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N, M = map(int, input().split())
A = list(int(a) for a in input().split())

sumA = [0] * (N+1)
for i in range(N):
    sumA[i+1] = (sumA[i] + A[i]) % M

ans = 0
c = Counter(sumA)
for k, v in c.items():
    ans += (v*(v-1))//2
print(ans)

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


int main(){
	    int L; cin >> L;
        cout << fixed;
        cout << setprecision(12);
        cout << pow(L, 3) / 27 << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    bool p,w,g,y;
    p = w = g = y = false;
    rep(i,n) {
        char c; cin >> c;
        if (c == 'P') p = true;
        if (c == 'W') w = true;
        if (c == 'G') g = true;
        if (c == 'Y') y = true;
    }
    int cnt = 0;
    if (p) cnt++;
    if (w) cnt++;
    if (g) cnt++;
    if (y) cnt++;
    if (cnt == 4)
    {
        cout << "Four\n";
    } else {
        cout << "Three\n";
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
ans=0
mod=10**9+7
for k in range(60):
    X=0
    Y=0
    for i in range(N):
        if A[i]^(2**k)>A[i]:
            X+=1
        else:
            Y+=1
    #print(X,Y)
    ans+=pow(2,k,mod)*(X*Y)
    ans%=mod
print(ans)


Measured memory_bytes: 122936
n=int(input())
A=[0 for i in range(n)]

A=input().split()

for i in range(n):
    A[i]=(int)(A[i])

for i in range(n):
    key=A[i]
    j=i-1
    while j>=0 and A[j]>key:
        A[j+1]=A[j]
        j=j-1
        A[j+1]=key

    for i in range(n):
        if i!=n-1:
            print(A[i],end=" ")
        if i==n-1:
            print(A[i])



Measured memory_bytes: 5976
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 51;
int q[N];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n ; i ++ ) cin >> q[i];
	sort(q,q+n);
	float sum = 0;
	sum += q[0];
	
	for (int i = 1; i < n ; i ++ )
	{
		sum += q[i];
		sum /= 2.0;
	}
	if(n == 1) cout << sum / 2.0 << endl;
	else cout << sum << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int INF = 1<<29;
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int H, W, N;
string town[1024];
int dist[10][1024][1024];

inline bool in(int r, int c) {
  return 0 <= r && r < H && 0 <= c && c < W;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> H >> W >> N;
  REP(i, H) cin >> town[i];
  int sr = 0, sc = 0;
  REP(i, H) REP(j, W) {
    if (town[i][j] == 'S') {
      sr = i, sc = j;
      break;
    }
  }

  int ans = 0;
  REP(i, N) {
    queue<T> que;
    que.push(T(sr, sc, 1));
    while (!que.empty()) {
      int r, c, d;
      tie(r, c, d) = que.front(); que.pop();
      if (dist[i][r][c]) continue;
      dist[i][r][c] = d;
      if (town[r][c] != 'S' && town[r][c] != '.' && town[r][c] != 'X' && town[r][c] - '0' == i+1) {
	ans += d-1;
	sr = r, sc = c;
	break;
      }
      REP(j, 4) {
	int nr = r + dr[j], nc = c + dc[j];
	if (in(nr, nc) && town[nr][nc] != 'X' && !dist[i][nr][nc]) {
	  que.push(T(nr, nc, d+1));
	}
      }
    }
  }

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

Measured memory_bytes: 39132
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    vector<bool> A(N, false);
    for (int i = 0; i < K; i++)
    {
        int d; cin >> d;
        for (int j = 0; j < d; j++)
        {
            int h;
            cin >> h;
            h--;
            A[h] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(!A[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int n,key,A[100],j;
 
void print_table(){
  for(int i = 0;i < n; i++){
    if( i ) cout <<' ';
    cout << A[i];
  }
  cout << endl;
}
 
int main(){
 
  cin >> n;
  for(int i = 0;i < n;i++) cin >>A[i];
  print_table();
  for(int i = 1;i < n;i++){
    key = A[i];
    j= i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j + 1] = key;
    print_table();
  }
  return 0;
}



Measured memory_bytes: 3080
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(A: int, B: int, C: int, K: int):
    return min(K, A) - max(K-A-B, 0)


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(A, B, C, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 70332
#include <stdio.h>

int main(){
  int P,Q,R;
  int max;
  scanf("%d %d %d",&P,&Q,&R);
  max=P;
  if(max<Q) max=Q;
  if(max<R) max=R;
  printf("%d\n",P+Q+R-max);
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, k = [int(x) for x in input().split()]
    a = []
    for _ in range(n):
        a.append(int(input()))
    a.sort()
    ans = float('inf')
    for i in range(n-k+1):
        ans = min(ans, a[i+k-1]-a[i])
    print(ans)
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

a aa c ca c a b a ab a b c

"""


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

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
	int a, b;
	cin >> a >> b;
	for (int i = 0; i <= 1250; i++) {
		if ((i * 8)/100 == a && i/10 == b) {
			cout << i << "\n";
			return 0;
		}
	}
	cout << "-1\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int ff(int k) {
    int res = 0;
    while (k) res += k % 10, k /= 10;
    return res;
}

void chemthan() {
    int n; cin >> n;
    int res = INF;
    FOR(i, 1, n) {
        chkmin(res, ff(i) + ff(n - i));
    }
    cout << res << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
string s;
long long dfs(long long now,long long ans,long long x){
	if(now==s.size())return (ans*(x==0));
	return (dfs(now+1,ans,x*10+(long long)(s[now]-'0'))+dfs(now+1,ans+x*10+(long long)(s[now]-'0'),0));
}
int main(){
	cin>>s;
	cout<<dfs(0,0,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,d;
int main(){
	cin>>n>>d;
	d=d*2+1;
	cout<<n/d+(n%d==0?0:1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 

*/

//================== INPUT ========================
int N;
vector<int> A;
//=================================================
void input()
{
    cin >> N;
    A = vector<int>(N);
    rep(i, N)
    {
        cin >> A[i];
    }
}

//=================================================
void solve()
{
    deque<int> d; // double-ended-queue
    rep(i, N)
    {
        int p = lower_bound(d.begin(), d.end(), A[i]) - d.begin(); // index
        if (p == 0)
        {
            d.push_front(A[i]);
        }
        else
        {
            d[p - 1] = A[i];
        }
    }
    cout << d.size() << endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// --- MOD begin --- cut here ---

ll MOD = 1e9 + 7;
// ll MOD = 998244353;

// g = eGCD(a, b, s, t)  --->  sa + tb = g
constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

constexpr ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(a, b, dummy1, dummy2);
}

struct Fp {
  ll val;

  Fp(ll t = 0) :
    val(t < 0 ? MOD + t % MOD : t >= MOD ? t % MOD : t) {}

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};

class Comb {
  int nMax;
  vector<Fp> vFact;
  vector<Fp> vInvFact;
public:
  Comb(int nm) : nMax(nm), vFact(nm+1), vInvFact(nm+1) {
    vFact.at(0) = 1;
    for (int i = 1; i <= nMax; i++) vFact.at(i) = i * vFact.at(i-1);
    vInvFact.at(nMax) = vFact.at(nMax).inv();
    for (int i = nMax; i >= 1; i--) vInvFact.at(i-1) = i * vInvFact.at(i);
  }
  Fp fact(int n) { return vFact.at(n); }
  Fp comb(int n, int r) {
    return vFact.at(n) * vInvFact.at(r) * vInvFact.at(n-r);
  }
  // The number of permutation extracting r from n.
  Fp perm(int n, int r) {
    return vFact.at(n) * vInvFact.at(n-r);
  }
};

/* 
   Power function    power(a, b) == a^b
   Speed is O(log b).
   The same source code can be used for integers by replacing
   Fp with int etc.  Unfortunately, replacing Fp with auto does not
   make the function generic for int and Fp.
 */
Fp power(Fp a, ll b) {
  Fp twoPow = a;
  Fp rv = 1;
  while (b > 0) {
    if (b & 1LL) rv *= twoPow;
    twoPow *= twoPow;
    b >>= 1;
  }
  return rv;
}

// --- MOD end --- cut here ---


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> C(N);
  for (ll i = 0; i < N; i++) cin >> C.at(i);
  sort(C.begin(), C.end());
  Fp ans = 0;
  Fp p2n1 = power(2, N-1);
  Fp p2n2 = power(2, N-2);
  for (ll i = 0; i < N; i++) {
    ans += C.at(i) * (p2n1 + Fp(N-1-i) * p2n2);
  }
  cout << int(power(2, N) * ans) << endl;

  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
bool ugly[100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>v;
    for(int i=0;i<n-1;i++){
        ll x;
        cin>>x;
        v.push_back(x);
    }
    ll ans=v.front()+v.back();
    for(int i=0;i<n-2;i++){
        ans+=min(v[i],v[i+1]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     bool f=true;
     cin>>n;
     for(i=0;i<n;i++)
     {
       ll x;
       cin>>x;
       if(x%2==0)
       {
         if(x%3!=0&&x%5!=0)
          f=false;
       }
     }
     if(f) cout<<"APPROVED";
     else cout<<"DENIED";
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 256
N = int(input())
d = list(map(int,input().split()))
k = 0
d.sort()
if len(d) % 2 == 1:
    k = 0
elif d[int(len(d) / 2)] == d[int((len(d) / 2) - 1)]:
    k = 0
else:
    k = d[int(len(d) / 2)] - d[int((len(d) / 2) - 1)]

print(k)

Measured memory_bytes: 20488
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int max(int a,int b){if(a>b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int main(){
  int n,s,i,j,r;
  int a[1024];
  while(scanf("%d%d",&n,&s),n!=0){
    for(i=0;i<n;i++){scanf("%d",&a[i]);}
    qsort(a,n,sizeof(int),sortfncsj);
    i=0;j=n-1;r=-1;
    while(i<j){
      if(a[i]+a[j]<=s){r=max(a[i]+a[j],r);i++;}
      else{j--;}
    }
    if(r==-1){printf("NONE\n");}
    else{printf("%d\n",r);}
  }
  return 0;
}



Measured memory_bytes: 2028
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
	int a, n;
	long  sum=0;
	int max=-1000000, min=1000000;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (max < a) max = a;
		if (min > a) min = a;
		sum += a;
	}
	cout << min << " " << max << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define L long
#define t first
#define u second
#define M push_back(make_pair(c(
using namespace std;
L R,C,N,a[9<<14],b,i;
vector<pair<L,L>> p;
bool s(L x,L y){return !(x^0&&x^R&&y^0&&y^C);}
L c(L x,L y){return L(atan2(x-R/2,y-C/2)*(1LL<<40));}
main(){
    cin>>R>>C>>N;
    for(;i<N;++i){
        cin>>*a>>a[1]>>a[2]>>a[3];
        if(s(*a,a[1])&&s(a[2],a[3])){
            p.M*a,a[1]),i));
            p.M a[2],a[3]),i));
        }
    }
    sort(p.begin(), p.end());
    fill(a,a+114514,0);
    stack<L> s;
    for(auto P : p){
        if(s.empty()||s.top()^P.u)s.push(P.u);
        else s.pop();
    }
    puts(s.empty()?"YES":"NO");
}

Measured memory_bytes: 6512
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int a, N;
  scanf("%d", &N);
  int ans = 0;
  rep(i, 0, N) {
    scanf("%d", &a);
    ans += a - 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;


vector<vector<int> > rotate90(const vector<vector<int> > &am)
{
	int m = am.size();
	vector<vector<int> > r = vector<vector<int> >(m, vector<int>(m));

	for (int i = 0; i < m; i++)
		for (int j = 0; j < m; j++)
			r[j][m - i - 1] = am[i][j];
	return r;
}

pair<int, int> match(const vector<vector<int> > &an, const vector < vector<int> > &am)
{
	vector<vector<int> > a[4];
	a[0] = am;
	for (int i = 0; i < 3; i++)
	{
		a[i + 1] = rotate90(a[i]);
	}
	int m = am.size();
	int n = an.size() - m + 1;
	vector<pair<int, int> > result = vector<pair<int, int> >();
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				for (int p = 0; p < m; p++) //??¨?????¢?????????????????§??????
				{

					bool ok = false;
					for (int q = 0; q < m; q++)
					{
						if (a[k][p][q] != -1)
						{
							if (a[k][p][q] != an[i + p][j + q])
							{
								ok = true;
								break;
							}
							else if (p + q == 2 * (m - 1))
							{
								for (int s = 0; s < m; s++)
								{
									bool ok2 = false;
									for (int t = 0; t < m; t++)
									{
										if (a[k][s][t] != -1)
										{
											result.push_back({ i + s + 1,j + t + 1 });
											ok2 = true;
											break;
										}
									}
									if (ok2) break;
								}
							}
						}
						else if (p + q == 2 * (m - 1))
						{
							for (int s = 0; s < m; s++)
							{
								bool ok2 = false;
								for (int t = 0; t < m; t++)
								{
									if (a[k][s][t] != -1)
									{
										result.push_back({ i + s + 1,j + t + 1 });
										ok2 = true;
										break;
									}
								}
								if (ok2) break;
							}
						}
					}
					if (ok) break;
				}

			}
			if (!result.empty())
			{
				int pos = 0;
				for (int h = 1; h < result.size(); h++)
				{
					if (result[pos].first > result[h].first)
						pos = h;
					else if (result[pos].first == result[h].first && result[pos].second > result[h].second)
						pos = h;
				}
				return result[pos];
			}
		}
	}
	return { -1,-1 };
}

int main()
{
	int n, m;
	vector<vector<int> > an, am;
	while (cin >> n >> m && n != 0)
	{
		an = vector<vector<int> >(n);
		for (int i = 0; i < n; i++)
		{
			an[i] = vector<int>(n);
			for (int j = 0; j < n; j++)
				cin >> an[i][j];
		}
		am = vector<vector<int> >(m);
		for (int i = 0; i < m; i++)
		{
			am[i] = vector<int>(m);
			for (int j = 0; j < m; j++)
				cin >> am[i][j];
		}
		pair<int, int> res = match(an, am);
		if (res.first > -1)
			cout << res.second << " " << res.first << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 3120
n = int(input())

tp = 0
hp = 0

for i in range(n):
    t, h = input().split()
    if t < h:
        hp += 3
    elif t > h:
        tp += 3
    elif t == h:
        tp += 1
        hp += 1

print('%d %d' % (tp, hp) )

Measured memory_bytes: 7716
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[]=new int[a];
int i=0;
do {
	b[i]=scan.nextInt();
	if(i==a-1)break;
	i++;
}while(true);
i=0;
int c=b.length-1;
do {
	System.out.print(b[c]);
	if(i==a-1)break;
	System.out.print(" ");
	i++;
	c--;
}while(true);
System.out.println();
}
}


Measured memory_bytes: 26320
N=int(input())
*A,=map(int,input().split())
A.sort()
i_min=A[0]
i_max=A[-1]

import collections
C=collections.Counter(A)
count=[]
i=i_min
while i_min<=i<=i_max:
    count.append(C[i]+C[i-1]+C[i+1])
    i+=1

print(max(count))

Measured memory_bytes: 14436
def main():
  X, N = map(int, input().split())
  if N == 0:
    print(X)
    return
  p = tuple(map(int, input().split()))  
  if X not in p:
    print(X)
    return
  
  not_p = list(set([i for i in range(max(p)+2)]) - set(p))
  not_p_X = [abs(X - i) for i in not_p]
  print(not_p[not_p_X.index(min(not_p_X))])
    
main()


Measured memory_bytes: 9180
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/





int main() {

	string s;
	cin >> s;
	vector<int> alpha(26, 0);

	bool all_same = true;
	for (int i = 0; i < s.size(); i++)
	{
		alpha[s[i] - 'a']++;
	}


	int mini = INF;

	for (int i = 0; i < 26; i++)
	{
		if (alpha[i] > 0) {

			string copy = s;//sのコピー
			string t;
			
			int cnt = 0;

			while (true) {
			
				bool same = true;

				for (int k = 1; k < copy.size(); k++)
				{
					same &= (copy[k - 1] == copy[k]);
				}

				if (same) {
					mini = min(mini, cnt);
					break;
				}

				cnt++;
				for (int j = 0; j < copy.size() - 1; j++)
				{
					if (i == copy[j] - 'a') {
						t.push_back(copy[j]);
					}
					else if (i == copy[j + 1] - 'a') {
						t.push_back(copy[j + 1]);
					}
					else
					{
						t.push_back(copy[j]);
					}
				}

				copy = t;
				t.clear();
			}
		}
	}


	cout << mini << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> dP;

const int INF = 100000000;
const double EPS = 1e-10;

int main(){
	//freopen("test.txt", "r", stdin);
	while(1){
		queue<char> q[3]; // up left down
		rep(i, 3){
			string s;
			cin >> s;
			if(s.size() == 1 && s[0] == '-') return 0;
			rep(j, s.size()){
				q[i].push(s[j]);
			}
		}

		string s;

		int next = 1;
		while(!q[next].empty()){
			char buf = q[next].front(); q[next].pop();
			if(q[2].empty() || buf != q[2].front()){
				s += buf;
				next = 1;
			}else{
				q[2].pop();
				next = 0;
			}
		}

		cout << s << endl;
	}

	return 0;
}

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

void inp_str(long int*);

int main(void) {

long int input1[150];
inp_str(input1);

long int A,B,C,D;

A=input1[0];
B=input1[1];
C=input1[2];
D=input1[3];


long int x,tmp,a,b,r;

a=C;
b=D;

  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }




















long int E,F,G;

long int H,I;

E=B/C;
F=B/D;
G=B/(x/b);

H=B-(E+F-G);
//printf("%ld\n",H);


E=(A-1)/C;
F=(A-1)/D;
G=(A-1)/(x/b);

I=(A-1)-(E+F-G);
//printf("%ld\n",I);

long int ans;

ans=H-I;

printf("%ld\n",ans);


    return 0;

}


void inp_str(long int instr[]){
char *ptr;
long int z,i,count;
char str[20000]={'\0'};
char *ln;

fgets(str, 20000, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atol(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atol(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}



Measured memory_bytes: 128