akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().solve();

	}

	private long getValue(int remainWeight, int currentI) {

		if (currentI == itemNum) {
			return 0;
		} else if (arrayMemo[currentI][(int) remainWeight] != Integer.MIN_VALUE) {
			return arrayMemo[currentI][(int) remainWeight];
		} else if (remainWeight < arrayItem[currentI][0]) {
			return getValue(remainWeight, currentI + 1);
		} else {
			long kati1 = getValue((int) (remainWeight - arrayItem[currentI][0]), currentI + 1) + arrayItem[currentI][1];
			long kati2 = getValue(remainWeight, currentI + 1);
			arrayMemo[currentI][remainWeight] = Math.max(kati1, kati2);
			return arrayMemo[currentI][remainWeight];
		}
	}

	private long[][] arrayItem;
	private long[][] arrayMemo;
	private int itemNum = 0;
	private int weightTotalNum = 0;

	private void solve() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);
			itemNum = scanner.nextInt();
			weightTotalNum = scanner.nextInt();

			arrayItem = new long[itemNum][2];
			arrayMemo = new long[itemNum + 1][weightTotalNum + 1];
			for (int i = 0; i < arrayItem.length; i++) {
				arrayItem[i][0] = scanner.nextInt();
				arrayItem[i][1] = scanner.nextInt();
			}

			for (int i = 0; i < arrayMemo.length; i++) {
				Arrays.fill(arrayMemo[i], Integer.MIN_VALUE);
			}

			System.out.println(getValue(weightTotalNum, 0));
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

int main(){
    vector <int> A_1(3);
    vector <int> A_2(3);
    vector <int> A_3(3);

    for(int i=0; i < 3; i++){
        cin >> A_1.at(i);
    }
    for(int i=0; i < 3; i++){
        cin >> A_2.at(i);
    }
    for(int i=0; i < 3; i++){
        cin >> A_3.at(i);
    }

    int N;
    cin >>N;
    vector <int> b(N);
    for(int i = 0; i < N; i++){
        cin >> b.at(i);
    }

    for(int i=0; i< N; i++){
        for(int j=0; j < 3; j++){
            if(b.at(i)==A_1.at(j)){
                A_1.at(j) = 1000;
            }
        }
    }
    for(int i=0; i< N; i++){
        for(int j=0; j < 3; j++){
            if(b.at(i)==A_2.at(j)){
                A_2.at(j) = 1000;
            }
        }
    }
    for(int i=0; i< N; i++){
        for(int j=0; j < 3; j++){
            if(b.at(i)==A_3.at(j)){
                A_3.at(j) = 1000;
            }
        }
    }
    //ビンゴ判定
    string output="No";
    int sumA_1 = 0;
    for(int i=0; i < 3; i++){
        sumA_1 += A_1.at(i);
    }
    if(sumA_1==3000){
        output = "Yes";
    }
    int sumA_2 = 0;
    for(int i=0; i < 3; i++){
        sumA_2 += A_2.at(i);
    }
    if(sumA_2==3000){
        output = "Yes";
    }
    int sumA_3 = 0;
    for(int i=0; i < 3; i++){
        sumA_3 += A_3.at(i);
    }
    if(sumA_3==3000){
        output = "Yes";
    }

    if(A_1.at(0)+A_2.at(0)+A_3.at(0) == 3000)
        output = "Yes";
    if(A_1.at(1)+A_2.at(1)+A_3.at(1) == 3000)
        output = "Yes";
    if(A_1.at(2)+A_2.at(2)+A_3.at(2) == 3000)
        output = "Yes";

    if(A_1.at(0)+A_2.at(1)+A_3.at(2) == 3000)
        output = "Yes";
    if(A_1.at(2)+A_2.at(1)+A_3.at(0) == 3000)
        output = "Yes";
    cout << output <<endl;
}

Measured memory_bytes: 256
# cook your dish here
from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left

def L():
    return list(map(int, stdin.readline().split()))

def In():
    return map(int, stdin.readline().split())

def I():
    return int(stdin.readline())

P = 1000000007
n, m = In()
c = 0
if n > 1:
    c += (n*(n-1))//2
if m > 2:
    c += (m*(m-1))//2
print(c)


Measured memory_bytes: 3424
import java.util.Scanner;

class Main {

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

		scanner.close();;

		if (U.equals(S)) {
			A--;
		} else if (U.equals(T)) {
			B--;
		}
		System.out.println(A + " " + B);
	}
}

Measured memory_bytes: 22996
use std::collections::BinaryHeap;
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (_, _) = scan!(usize, usize);
    let vs = scan!(i64;;);

    let mut heap: BinaryHeap<i64> = BinaryHeap::new();
    let mut m = HashMap::new();
    for v in vs.iter().rev() {
        if let Some(w) = heap.pop() {
            let diff = w - v;
            if diff > 0 {
                let val = m.entry(diff).or_insert(0);
                *val += 1 as usize;
            }
            heap.push(w);
        }
        heap.push(*v);
    }

    let mut k: Vec<_> = m.iter().collect();
    k.sort();
    let &(_, &m) = k.last().unwrap();

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


Measured memory_bytes: 14312
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;



int main() {
	string s; cin >> s;
	vector<char> ans;
	for (auto a : s) {
		if (a != 'B') {
			ans.push_back(a);
		}
		else if (ans.size() > 0) {
			ans.pop_back();
		}
	}
	for (auto a : ans) {
		cout << a;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <ctime>
using namespace std;

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

typedef vector<int> vi;
typedef pair<int,int> pii;

const int inf=1<<29;


struct node{
	int to;
	int cost;
};
vector<node> graph[50010];


int n;
int cost[8][8];

map<int,string> iconvert;
map<string,int> sconvert;

int dist[50010];
int index=0;

void make_graph(){
	int tar[8];
	rep(i,n) tar[i]=i+1;

	do{
		string add="";
		rep(i,n) add+=(tar[i]+'0');
		iconvert[index]=add;
		sconvert[add]=index;
		index++;

	}while(next_permutation(tar,tar+n));

//	clock_t start,end;
//	start=clock();

	rep(i,index){
		string cur=iconvert[i];
		rep(j,n)rep(k,n){
			if(j==k) continue;
			string next=cur;
			int a=next[j]-'0'-1;
			int b=next[k]-'0'-1;
			swap(next[j],next[k]);
			struct node in;
			in.to=sconvert[next];in.cost=cost[a][b];
			graph[i].pb(in);
		}
	}

//	end=clock();
//	cout << (double)(end-start)/CLOCKS_PER_SEC << endl;
	return ;
}

void dijkstra(){
	rep(i,index) dist[i]=inf;
	priority_queue <pii,vector<pii>,greater<pii> > q;
	pii init;
	init.first=0;
	init.second=0;
	dist[0]=0;
	q.push(init);
	while(!q.empty()){
		pii cur=q.top(); q.pop();

		if(dist[cur.first] < cur.second)
			continue;

		//cout << iconvert[cur.first] << " "<< cur.second << endl;

		rep(i,graph[cur.first].size()){
			pii next;
			next.first=graph[cur.first][i].to;next.second=cur.second+graph[cur.first][i].cost;
			if(dist[next.first] > next.second){
				dist[next.first]=next.second;
				q.push(next);
			}
		}

	}
	return ;
}


int main(void){
	cin >> n;
	rep(i,n) rep(j,n) cin >> cost[i][j];
	
	make_graph();
	dijkstra();
	int ans=0;
	
	rep(i,index) ans=max(dist[i],ans);

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

Measured memory_bytes: 32220
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
int main() {
    long long N, K;
    cin >> N >> K;
    vector<long> A(N);
    for (int i; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    long long left = -2e18, right = 2e18;
    while (right - left > 1) {
        long long mid = (left + right) / 2, count = 0;
        for (int i = 0; i < N; i++) {
            int l = i, r = N;
            while (r - l > 1) {
                int m = (l + r) / 2;
                if (A[i] * A[m] <= mid)
                    (A[i] < 0) ? r = m : l = m;
                else
                    (A[i] < 0) ? l = m : r = m;
            }
            count += (A[i] < 0) ? N - r : l - i;
        }
        (count < K) ? left = mid : right = mid;
    }
    cout << right << "\n";
}


Measured memory_bytes: 1792
#include<iostream>
#include<cctype>
#include<vector>
#include<ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include<math.h>
#include<iomanip>
using namespace std;
int n, m;long long sw=0; vector<int> a, b;
int main() {
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> m; a.push_back(m);
		cin >> m; b.push_back(m);
	}
	for (size_t i = 0; i < n; i++)
	{


		sw +=((*(b.end() - 1) -(sw + *(a.end() - 1)) % *(b.end() - 1))% *(b.end() - 1));
		a.pop_back(); b.pop_back();
	}
	cout << sw << endl;
	return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;
const int MAX_N = 100005;

template<typename T> T inf;
template<> constexpr int inf<int> = 1<<30;
template<> constexpr ll inf<ll> = 1LL<<60;

using Cost = ll;
using Node = int;
struct Edge{
  Cost cost; Node to;
  Edge(Cost cost,Node to)
    :cost(cost),to(to){}
};
using Graph = vector<vector<Edge>>;

vector<Cost> dijkstra
(Graph &graph, Node start, ll pat[], Cost zero = 0LL)
{
  using Pcn = pair<Cost,Node>;
  priority_queue<Pcn,vector<Pcn>,greater<Pcn>> que;
  vector<Cost> dist(graph.size(),inf<Cost>);
  dist[start] = zero;
  pat[start] = 1LL;
  que.push(Pcn(zero,start));
  while(!que.empty()){
    Pcn p = que.top(); que.pop();
    Node v = p.second; //行き先
    if(dist[v] < p.first)  continue;
    for(Edge e : graph[v]){
      if(dist[v]+e.cost < dist[e.to]){
        dist[e.to] = dist[v]+e.cost;
        // 最小値を更新したら今までのパターンを消す
        pat[e.to] = 0LL;
        que.push(Pcn(dist[e.to],e.to));
      }
      if(dist[v]+e.cost == dist[e.to]){
        // 最小値を見つけたらパターンを足す
        (pat[e.to] += pat[v]) %= lmod;
      }
    }
  }
  return dist;
}

Graph graph;
ll patS[MAX_N],patT[MAX_N];

int main(){
  int N,M; scanf("%d%d",&N,&M);
  graph.resize(N);
  int S,T; scanf("%d%d",&S,&T); S--; T--;
  rep(i,M){
    int l,r; ll dd; scanf("%d%d%lld",&l,&r,&dd);
    l--; r--; graph[l].pb(Edge(dd,r)); graph[r].pb(Edge(dd,l));
  }
  auto distS = move(dijkstra(graph,S,patS));
  auto distT = move(dijkstra(graph,T,patT));
  ll ans = patS[T] * patS[T] % lmod;
  ll len = distS[T];
  rep(i,N){
    if(distS[i]+distT[i]==len && distS[i]*2LL==len){
      (ans += (lmod - patS[i]*patS[i]%lmod*patT[i]%lmod*patT[i]%lmod)) %= lmod;
    }
  }
  rep(i,N) for(auto e:graph[i]){
    int j = e.to; ll c = e.cost;
    if(distS[i]+c+distT[j]==len && distS[i]*2LL<len && distT[j]*2LL<len){
      (ans += (lmod - patS[i]*patS[i]%lmod*patT[j]%lmod*patT[j]%lmod)) %= lmod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18772
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*/
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >>n;
  int flag=0;
  for(int i=0;i<=100;i=i+4){
    for(int j=0;j<=100;j=j+7){
      if(n==i+j)flag=1;
    }
  }
  if(flag==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
} 


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

int main() {
  int H,W;
  while (cin >> H >> W, H!=0 || W!=0) {
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl;
    for (int j = 0; j < H - 2; j++) {
      cout << "#";
      for (int k = 0; k < W - 2; k++) {
        cout << ".";
      }
      cout << "#" << endl;
    }
    for (int i = 0; i < W; i++) {
      cout << "#";
    }
    cout << endl << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <random>

using namespace std;

#define x first
#define y second
#define prev _prev
typedef long long ll;
typedef unsigned long long ull;

mt19937 rnd(rand());
const int MOD = 1e9 + 7;
const ll BIG_MOD = 1e18 + 7;
const int MAXN = 107;

int fact(ll a, ll b){
	ll f = (a * b) % MOD;
	if (f < 0){
		return f + MOD;
	}

	if (f >= MOD){
		return f - MOD;
	}

	return f;
}

signed main(){
	cout.precision(20);
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	string s1, s2;
	cin >> s1;
	cin >> s2;
	int i = 0;
	vector <bool> form;
	while (i < n){
		if (s1[i] == s2[i]){
			form.push_back(true);
			i += 1;
		}
		else{
			form.push_back(false);
			i += 2;
		}
	}

	int ans;
	if (form[0]){
		ans = 3;
	}
	else{
		ans = 6;
	}

	for (int i = 1; i < form.size(); ++i){
		if (form[i] && form[i - 1]){
			ans = fact(ans, 2);
		}
		else if (!form[i] && !form[i - 1]){
			ans = fact(ans, 3);
		}
		else if (!form[i] && form[i - 1]){
			ans = fact(ans, 2);
		}
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=17;

int mat[N][N];
vi tmp;

int calc(int mask)
{
    tmp.clear();
    for(int j=0;mask;mask>>=1,++j)
    {
        if(mask&1)
            tmp.pb(j);
    }

    int len=sz(tmp);
    int res=0;
    for(int i=0;i<len;++i)
    {
        for(int j=i+1;j<len;++j)
            res+=mat[tmp[i]][tmp[j]];
    }

    return res;
}

void solve()
{
    int n;
    cin>>n;

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

    int tot=(1<<n);
    int dp[tot],cost[tot];
    mem(dp,0);
    mem(cost,0);

    for(int mask=1;mask<tot;++mask)
        cost[mask]=calc(mask);

    for(int mask=1;mask<tot;++mask)
    {
        for(int sub=mask;sub;sub=(sub-1)&mask)
        {
            if(sub==mask)
                dp[mask]=cost[mask];
            else
                dp[mask]=max(dp[mask],dp[sub]+cost[mask^sub]);
        }

        //dbug(mask);
        //dbug(dp[mask]);
        //cout<<"\n";
    }

    cout<<dp[(1<<n)-1];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

ll n,k,cur,num,l;
vector<ll> a(200005),visited(200005,-1);

int main() {
  cin >> n >> k;
  rep(i,n) cin >> a[i], a[i]--;
  while(visited[cur]==-1 && num<k){
    visited[cur]=num, cur=a[cur], num++;
  }
  k-=visited[cur], l=num-visited[cur];
  rep(i,k%l) cur=a[cur];
  cout << cur+1 << endl;
}

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

class Program
{
    static void Main()
    {
        Console.WriteLine(string.Join(" ",Enumerable.Range(0, 2).Select(_ => Console.ReadLine()).Skip(1).First().Split(' ').Select(int.Parse).Select((p, i) => new { Val = p, Index = i + 1 }).OrderBy(p => p.Val).Select(p => p.Index)));
    }
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n;
    cin>>n;
    int a = n/100;
    int b = n%100;
    if(a<13 && b<13 && a>=1 && b>=1){
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(a<13 && a>=1 && (b>=13 || b==0) && b<=100){
        cout<<"MMYY"<<endl;
    }
    else if((a>=13 || a==0) && a<=100 && b<13 && b>=1){
        cout<<"YYMM"<<endl;
    }
    else{
        cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int a[500005];
int tmp[500005];
int  n, cnt;
void Solve(int a[],int l ,int mid ,int r , int tmp[]) {
	//合并，使用三个指针指向三个数组
	int p = 0;
	int p1 = l, p2 = mid + 1;
	while (p1 <= mid && p2 <= r) {
		cnt++;
		if (a[p1] <= a[p2])
			tmp[p++] = a[p1++]; 
		else
			tmp[p++] = a[p2++];
	}
	while (p1 <= mid) {
		cnt++;
		tmp[p++] = a[p1++];
	}
	while (p2 <= r) {
		cnt++;
		tmp[p++] = a[p2++];
	}
	for (int i = 0; i <r-l+1; i++) {
		a[l+i] = tmp[i];
	}
}
void MerageSort(int a[] ,int l ,int r ,int tmp[]) {
	if (l < r) {
		int mid = l + (r - l) / 2;
		MerageSort(a, l, mid, tmp);
		MerageSort(a, mid + 1, r, tmp);
		Solve(a, l, mid, r, tmp);//合并函数
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	MerageSort(a, 0, n - 1, tmp);
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << a[i];
	}
	cout << endl << cnt << endl;
}


Measured memory_bytes: 6932
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int dist(int x1, int x2, int y1, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;

	vector<pair<int, int> > students(n);
	int x, y;
	for (int i = 0; i < n; ++i) {
		cin >> x >> y;
		students[i] = {x, y};
	}

	vector<pair<int, int> > checkpoints(m);
	for (int i = 0; i < m; ++i) {
		cin >> x >> y;
		checkpoints[i] = {x, y};
	}

	for (int i = 0; i < n; ++i) {
		int closest = INT_MAX;
		int idx = 0;
		for (int j = 0; j < m; ++j) {
			int curr = dist(students[i].first, checkpoints[j].first, students[i].second, checkpoints[j].second);
			if (curr < closest) {
				closest = curr;
				idx = j + 1;
			}	
		}

		cout << idx << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
N = int(open(0).read())
cache = {}
cnt = 0
c = int(N ** 0.5)
cs = range(1, c)
for x in cs:
    for y in cs:
        for z in cs:
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n in cache:
                cache[n] += 1
            else:
                cache[n] = 1
for i in range(1, N+1):
    if i in cache:
        print(cache[i])
    else:
        print(0)

Measured memory_bytes: 11636
#include<cstdio>

int main() {
  //入力
  int a,b;
  std::scanf("%d%d",&a,&b);
  
  if(a < b) {
    std::printf("a < b\n");
  }
  else if(a > b) {
    std::printf("a > b\n");
  }
  else {
    std::printf("a == b\n");
  }
  return 0;
}


Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 5;
const int MOD = 1e9 + 7;

int n;
int a[maxN];
int64_t fact[maxN], rfact[maxN];

int64_t quickPow(int64_t a, int64_t b) {
    if(b == 0)
        return 1;

    int64_t ans = quickPow(a, b / 2);
    ans = (ans * ans) % MOD;
    if(b % 2 == 1)
        ans = (ans * a) % MOD;

    return ans;
}

void preCal() {
    fact[0] = 1;
    rfact[0] = quickPow(fact[0], MOD - 2);
    for(int i = 1; i < maxN; i++) {
        fact[i] = (fact[i - 1] * i) % MOD;
        rfact[i] = quickPow(fact[i], MOD - 2);
    }
}

int64_t nCk(int n, int k) {
    if(n < k)
        return 0;
    return (((fact[n] * rfact[k]) % MOD) * rfact[n - k]) % MOD;
}

int last[maxN];
int64_t ans[maxN];

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

    preCal();

    cin >> n;

    int rem = 0;

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

        if(last[a[i]])
            rem = last[a[i]] - 1 + n + 1 - i;

        last[a[i]] = i;
    }

    for(int k = 1; k <= n + 1; k++) {
        ans[k] = nCk(n + 1, k);
        //cerr << rem << " choose " << k - 1 << ' ' << nCk(rem, k - 1) << '\n';
        ans[k] = (((ans[k] - nCk(rem, k - 1)) % MOD) + MOD) % MOD;
    }

    for(int k = 1; k <= n + 1; k++) {
        cout << ans[k] << '\n';
    }

    return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
/*
int gcd(int n,int m){
    if(m==0)return n;
    return gcd(m,n%m);
}
*/
signed main(void) {
    int i,j;
    int n;
    cin >> n;
    rep(i,n){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        bool ans = true;
        if(a<b) ans = false;
        else if(b>d) ans = false;
        else if(b-1<=c) ans = true;
        else{
            int l = ((c+1-a)%b+b)%b;
            int r = ((b-1-a)%b+b)%b;
            int g = __gcd(b,d);
            if(l<=r && (l/g != r/g || l%g==0)) ans = false;
            if(l>r) ans = false;
        }
        if(ans) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    else if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    int G = A[0];
    rep(i, N) G = gcd(G, A[i]);
    cout << G << endl;

    return 0;
}


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

using namespace std;

bool is_leap(int y) {
    if (!(y % 4) && (y % 100) || !(y % 400)) return true;
    return false;
}

int main() {
    int a, b;
    bool flag = false;

    while (scanf("%d %d", &a, &b), a) {
        if (flag) cout << endl;
        flag = true;

        bool flag_ans = false;
        for (int i = a; i <= b; i++) {
            if (!is_leap(i)) continue;
            flag_ans = true;
            cout << i << endl;
        }

        if (!flag_ans) cout << "NA\n";
    }

    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define for0(i,n) for (int i=0; i<n; i++)
#define forr(i,n) for (int i=n-1; i>=0; i--)
#define fori(i,a,b) for (int i=a; i<=b; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define size(x) (int)(x).size()
#define read(x) int x; scanf("%d",&x);
#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<size(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int events[200005];

int main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    read(n); read(m);
    ms(events,0);
    for0(i,m){
        read(a); read(b);
        if (a > b){
            swap(a,b);
        }
        events[a-1]++;
        events[b-1]--;
    }
    printa(events,n);

    string ans = "YES";
    int cnt=0;
    for (int i=0; i<n-1; i++){
        cnt += events[i];
        pr(cnt)
        if (cnt%2 == 1){
            ans = "NO";
        }
    }
    nl
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int t=c;
 c=a;
  a=t;
  t=c;
  c=b;
  b=t;
  cout<<a<<" "<<b<<" "<<c<<" ";
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }

const string dirs = "RUDL";
const ll INF = 1LL << 40;
int N;
ll X[1010], Y[1010];
ll x[1010], y[1010];
int m = 32;
ll d[33];

ll len(ll sx, ll sy, ll tx, ll ty) {
  return abs(sx-tx) + abs(sy-ty);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    x[i] = X[i] - Y[i];
    y[i] = X[i] + Y[i];
  }

  for (int i = 0; i < N; i++) {
    if ((x[i] - x[0]) % 2 == 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (x[0] % 2 == 0) m++;
  d[31] = d[m-1] = 1;
  for (int i = 30; i >= 0; i--) {
    d[i] = d[i+1] << 1;
  }

  cout << m << endl;
  for (int i = 0; i < m; i++) {
    cout << d[i] << " \n"[i+1==m];
  }

  for (int t = 0; t < N; t++) {
    ll sx = 0, sy = 0;
    for (int i = 0; i < m; i++) {
      int idx = -1;
      ll tmp = INF;
      for (int j = 0; j < 4; j++) {
        ll tx = sx + ((j >> 0 & 1) ? -d[i] : d[i]);
        ll ty = sy + ((j >> 1 & 1) ? -d[i] : d[i]);
        if (chmin(tmp, len(tx, ty, x[t], y[t]))) {
          idx = j;
        }
      }
      sx += ((idx >> 0 & 1) ? -d[i] : d[i]);
      sy += ((idx >> 1 & 1) ? -d[i] : d[i]);
      cout << dirs[idx];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 384
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


# --------------------------------------------

dp = None


def main():
    H, W = li_input()
    S = [input() for _ in range(H)]

    print("#" * (W + 2))
    for s in S:
        print("#{}#".format(s))
    print("#" * (W + 2))


main()


Measured memory_bytes: 5236
score = []
while True:
    a,b,c = map(int,input().split())
    
    if a == b == c == -1:
        break
    elif a == -1 or b == -1:
        score.append("F")
    elif (a+b) < 30:
        score.append("F")
    elif 30 <= (a+b) < 50:
        if c >= 50:
            score.append("C")
        else:
            score.append("D")
    elif 50 <= (a+b) < 65:
         score.append("C")
    elif 65 <= (a+b) < 80:
         score.append("B")
    elif (a+b) >= 80:
         score.append("A")
         

for i in score:
    print(i)
    


Measured memory_bytes: 5600
def solve():

    N = int(input())
    Hlist = list(map(int, input().split()))
    ans = 0

    while True:

        if all(h == 0 for h in Hlist):
            print(ans)
            exit()
        else:
            flag = False
            for i in range(N):
                if Hlist[i] > 0:
                    if not flag:
                        ans += 1
                        flag = True
                    Hlist[i] -= 1
                else:
                    flag = False


if __name__ == "__main__":
    solve()


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

int main(){
    ll k, n; cin >> k >> n;
    vector<ll> lis(n, 0);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
    }
    ll ma = 0;
    for(int i = 0; i < n-1; i++){
        ma = max(ma, lis[i+1] - lis[i]);
    }
    ma = max(k - lis[n-1] + lis[0], ma);
    cout << k - ma;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<int, PII> PIP;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())
bool wall[100][100];
bool arrive[100][100];
int W,H;
bool inmaze(int x, int y){
  return (x>=0&x<W&&y>=0&&y<H);
}

int main(void){
  while(cin>>W>>H){
    memset(arrive,0,sizeof(arrive));
    if(!W&&!H) break;
    REP(i,2*H-1){
      REP(j,W-(i+1)%2){
        cin>>wall[i][j];
      }
    }
    queue<PIP> que;
    que.push(PIP(0,PII(0,0)));
    bool find = false;
    while(!que.empty()){
      PIP pip = que.front(); que.pop();
      PII p = pip.second;
      int x = p.first;
      int y = p.second;
      if(arrive[y][x]) continue;
      arrive[y][x] = true;
      if(p == PII(W-1,H-1)){
        cout<<pip.first+1<<endl;
        find = true;
        break;
      }
      int nx,ny;
      nx = x + 1; ny = y;
      if(inmaze(nx,ny)&&!wall[y*2][x]){
        que.push(PIP(pip.first+1,PII(nx,ny)));
      }
      nx = x - 1; ny = y;
      if(inmaze(nx,ny)&&!wall[ny*2][nx]){
        que.push(PIP(pip.first+1,PII(nx,ny)));
      }
      nx = x; ny = y+1;
      if(inmaze(nx,ny)&&!wall[y*2+1][x]){
        que.push(PIP(pip.first+1,PII(nx,ny)));
      }
      nx = x; ny = y-1;
      if(inmaze(nx,ny)&&!wall[ny*2+1][nx]){
        que.push(PIP(pip.first+1,PII(nx,ny)));
      }
    }
    if(!find) cout<<"0"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]

ans=[0,0,w,h]
for i in range(n):
    if xya[i][2] == 1:
        if xya[i][0] >= ans[0]:
            ans[0] = xya[i][0]
    elif xya[i][2] == 2:
        if xya[i][0] <= ans[2]:
            ans[2] = xya[i][0]
    elif xya[i][2] == 3:
        if xya[i][1] >= ans[1]:
            ans[1] = xya[i][1]
    elif xya[i][2] == 4:
        if xya[i][1] <= ans[3]:
            ans[3] = xya[i][1]

print(0 if (ans[2]-ans[0] <= 0) or (ans[3]-ans[1] <= 0) else (ans[2]-ans[0])*(ans[3]-ans[1]))


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

int main(void){
    int N, H, W;
    scanf("%d%d%d",&N, &H, &W);
    int h[N], w[N];
    for(int i=0; i<N; i++){
        scanf("%d%d",&h[i], &w[i]);
    }

    int ans = 0;
    for (int i=0; i<N; i++) {
        if (h[i] >= H && w[i] >= W) {
            ans++;
        }
    }

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

Measured memory_bytes: 128
import bisect

N = int(input())
A = [-int(input()) for _ in range(N)]

dp = [float("inf")] * (N+1)
dp[0] = -float("inf")
dp[1] = A[0]

for i in range(1,N):
    dp[bisect.bisect_right(dp, A[i])] = A[i]

for i in reversed(range(N+1)):
    if dp[i] < float("inf"):
        print(i)
        break

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

int main(){
	int N, M;
	cin >> N >> M;
	int sum = 0;
	for(int i = 0; i < M; i++){
		int tmp;
		cin >> tmp;
		sum += tmp;
	}
	cout << (N < sum ? -1 : N-sum) << endl;

	

	return 0;	
}

Measured memory_bytes: 3620
# vim: set fileencoding=utf-8 :
a1, a2, b1, b2 = map(int, raw_input().split())

# Aが動いてる間に
if a1 <= b1 <= a2:
    # Bが先に終わる
    if b2 <= a2:
        print(b2 - b1)
    else:
        print(a2 - b1)
elif b1 <= a1 <= b2:
    # Bが先に終わる
    if a2 <= b2:
        print(a2 - a1)
    else:
        print(b2 - a1)
else:
    print(0)


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

int main(){
    int n;
    cin >> n;
  	vector<int> v(n+1);
  v[0] =10000007;
  int a;
  for(int i=1;i<n;i++){
   cin >> a;
    v[i] = a;
  }
  v[n] = 10000007;
//  v.push_back(0);
  vector<int> v2;
  for(int i=0;i<n;i++){
    v2.push_back(min(v[i],v[i+1]));
  }
  int ans=0;
  for(int i=0;i<n;i++){
  ans+=v2[i];
  }
  cout << ans <<endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX(A, B) ((A) < (B) ? (B) : (A))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define MAXNUM 10001

int main(void) {
  int n, a[MAXNUM],  i, max, min;
  long long  sum;
  scanf ("%d", &n);
  for (i = 0; i < n ; i++) {
  scanf ("%d", &a[i]);
  }
  max = a[0];
  min = a[0];
  sum = a[0];
  for (i = 1; i < n ; i++) {
    max = MAX (max, a[i]);
    min = MIN (min, a[i]);
    sum = sum + a[i];
  }
  printf ("%d %d %lld\n", min, max, sum);
  return 0;
}



Measured memory_bytes: 2124
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  ll a,b,x,i,ans=1;
  cin >> a >> b;
  x=__gcd(a,b);
  for(i=2; i*i<=x; i++) {
    if(x%i==0) {
      ans++;
      while(!(x%i)) {
        x/=i;
      }
    }
  }
  if(x>1) {
    ans++;
  }
  cout << ans << endl;
}

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

const int MaxN = 4;

int a[MaxN];

int main()
{
	for(int i = 1; i <= 3; ++ i) scanf("%d",&a[i]);
	sort(a+1,a+3+1);
	printf("%d",unique(a+1,a+3+1)-(a+1));
	
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
  #include <iomanip>
  #include <algorithm>
  #include <cmath>
  #include <queue>
  #include <list>
  #include <limits>
  #include <string>
  #include <vector>
  #include <stack>
  using namespace std;

  int main(){
    int n = 0;
    std:vector<int> prices;
    cin >> n;
    int price = 0;
    int greatest = 0;
    for(int i; i < n; i++){
      cin >> price;
      if(greatest < price) greatest = price;
      prices.push_back(price);
    }
    int price_sum = 0;
    for(int p:prices){
      price_sum += p;
    }
    price_sum -= greatest/2;
  cout << price_sum;

  }


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

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef long long ll;

const long long N = (long long) 1e5 + 5;
const long long mod = (long long) 1e9 + 7;

long long n;

long long sum(long long x){
        return x * 1ll * (x + 1) / 2;
}
int main () {
        cin >> n;

        n = abs(n);

        long long u = sqrt(n * 2),o;

        for(long long i = max(u - 10,0 * 1ll); i <= u + 10; i ++){
                if(sum(i) >= n){
                        if(sum(i) >= n){
                                cout << i << endl;
                                return 0;
                        }
                        long long o = i;
                        break;
                }
        }
        return 0;
}



Measured memory_bytes: 384
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 555;
const int MOD = INF;


int X[MAX];
int L[MAX];
int G[MAX];
int U[MAX];
int ANS[MAX * MAX];

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false); cin.tie(0);
    
    int n;
    cin >> n;
    FOR(i, 1, n+1)cin >> X[i];
    
    FOR(i, 1, n * n + 1)
    {
        bool fnd = 0;
        FOR(j, 1, n+1)
        {
            if (X[j] == i)
            {
                ANS[i] = j;
                fnd = 1;
                break;
            }
        }
        if (fnd)continue;
        int bst = -1;
        FOR(j, 1, n + 1)
        {
            if (i < X[j] && L[j] != j-1)
            {
                if (bst == -1 || X[j] < X[bst])
                    bst = j;
            }
        }
      //  cout << bst << endl;
        if (bst != -1)
        {
            ANS[i] = bst;
            L[bst]++;
            continue;
        }
        bst = -1;
        FOR(j, 1, n+1)
        {
            if (i > X[j] && G[j] != n - j)
            {
                if (bst == -1 || X[j] > X[bst])
                    bst = j;
            }
        }
        if (bst != -1)
        {
            G[bst]++;
            ANS[i] = bst;
            continue;
        }
        cout << "No" << endl;
        return 0;
        
    }
    cout << "Yes" << endl;
    FOR(i, 1, n*n+1)
    cout << ANS[i] << " ";
 
    
    
}




Measured memory_bytes: 2176
import java.util.*;

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

        int a = sc.nextInt();
        int p = sc.nextInt();

        int sum = a * 3 + p;

        int ans = sum / 2;

        System.out.println(ans);
    }
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int f(int n){
	if( n%2 == 0 ) return n/2;
	else return 3*n + 1;
}

int main(){
	//ios_base::sync_with_stdio(false);
	int s, ans=0;

	cin >> s;

	set<int> st;
	int cur = s;
	rep(i,1e6){
		st.insert(cur);
		cur = f(cur);
		if( st.count(cur) ){
			ans = i + 2;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
typedef long long lt;
typedef double dd;
#define eps 1e-6
#define sqr(x) ((x)*(x))
const int maxn=1000010;
int n;
struct point{
	point(dd a,dd b){
		x = a;
		y = b;
	}
	point(){
		
	}
	dd x,y;
	
}p[maxn],O;
dd dis(point a,point b){
	return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
}
point getO(point p1,point p2,point p3)
{
    point res;
    dd a=p2.x-p1.x,b=p2.y-p1.y,c=p3.x-p2.x,d=p3.y-p2.y;
    dd e=sqr(p2.x)+sqr(p2.y)-sqr(p1.x)-sqr(p1.y);
    dd f=sqr(p3.x)+sqr(p3.y)-sqr(p2.x)-sqr(p2.y);
    if(c*b-a*d==0)return point(0,0);
	if(a*d-b*c==0)return point(0,0);
    res.x=(f*b-e*d)/(c*b-a*d)/2.0; 
    res.y=(a*f-e*c)/(a*d-b*c)/2.0;
    return res;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;++i)
    scanf("%lf%lf",&p[i].x,&p[i].y);
    dd ans = 1e18;
    for(int i=1;i<=n;i++){
    	for(int j=i+1;j<=n;j++)
    		for(int k=j+1;k<=n;k++){
    			point O = getO(p[i],p[j],p[k]);
    			dd tmp = 0;
    			for(int l=1;l<=n;l++)
    				tmp = max(tmp,dis(p[l],O));
 //   			cout<<"!"<<i<<" "<<j<<" "<<k<<" "<<tmp<<endl;
//				cout<<"->"<<O.x<<" "<<O.y<<endl; 
    			ans = min(ans,tmp);
			}
	}
//	cout<<"!"<<endl;
	for(int i=1;i<=n;i++){
    	for(int j=i+1;j<=n;j++){
    		point O = point((p[i].x+p[j].x)/2,(p[i].y+p[j].y)/2);
   // 		cout<<O.x<<" "<<O.y<<endl;
   // 		cout<<p[i].x+p[j].x<<" "<<p[i].y+p[j].y<<endl;
    		dd tmp = 0;
    		for(int l=1;l<=n;l++)
    			tmp = max(tmp,dis(p[l],O));
    		ans = min(ans,tmp);
		}
	}
    printf("%.7lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    int n;
    char sn[30];
    char b[101][110];

    scanf("%d",&n);
    scanf("%s",sn);
    REP(i,n)
        scanf("%s",b + i);
    ll p = strlen(sn);

    ll c = 0;
    REP(i,n){
        int q = strlen((char*)(b + i));
        bool f2 = false;
        for(int j = 1;q >= (p - 1) * j + 1;j++){
            for(int k = 0;q >= (p - 1) * j + 1 + k;k++){
                bool f = true;
                for(int l = 0;l < p;l++){
                    f = (f && sn[l] == b[i][k + l * j]);
                }
                f2 = (f2 || f);
            }
        }
        c += f2;
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 3172