akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

string s;
signed main()
{
    cin >> s;
    cout << s.substr(0, 3LL);
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream> 
#include <iomanip> 
#include <cmath> 
using namespace std; 
int main(){
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		int x = i;
		if(i%3==0){
			cout << " " << i;
			continue;
		}
		while(x!=0){
			if(x%10==3){
				cout << " " << i;
				break;
			}
			x/=10;
		}		
	}
	cout << endl;
	return 0;
}


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

int main() {
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    rep(i, n - 2) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	long long g = gcd(a, b);
	return a / g * b;
}

int main() {
	int n; cin >> n;
	vector<int>d(n);
	rep(i, n)cin >> d[i];

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += d[i] * d[j];
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 100000000

vector<int> P;
bool f = true;

vector<pair<int,int>> range;

void dfs(int now,int parent,auto &E){
	int l=-Inf,r=Inf;
	if(P[now]!=-1){
		l = P[now];
		r = l;
	}
	
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(parent==to)continue;
		dfs(to,now,E);
		if(range[to]!=make_pair(-Inf,Inf)){
			auto p = range[to];
			p.first--;
			p.second++;
			if(l==-Inf){
				l=p.first;
				r=p.second;
				continue;
			}
			if((p.first%2==0)!=(l%2==0))f=false;
			l = max(l,p.first);
			r = min(r,p.second);
		}
	}
	
	range[now] = make_pair(l,r);
	if(l>r)f=false;
}

void dfs2(int now,int parent,auto &E){
	P[now] = range[now].first;
	pair<int,int> p = make_pair(range[now].first-1,range[now].first+1);
	
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(parent==to)continue;
		if(range[to].first==-Inf){
			range[to].first=p.first;
			range[to].second=p.second;
		}
		else{
			range[to].first = max(range[to].first,p.first);
			range[to].second = min(range[to].second,p.second);
		}
		dfs2(to,now,E);
	}	
}

int main() {
	
	int N;
	cin>>N;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	P.resize(N,-1);
	range.resize(N);
	
	int K;
	cin>>K;
	
	int V;
	
	for(int i=0;i<K;i++){
		int v,p;
		cin>>v>>p;
		v--;
		
		if(i==0)V = v;
		
		P[v] = p;
	}
	
	dfs(V,-1,E);
	
	if(!f){
		cout<<"No"<<endl;
		return 0;
	}
	
	dfs2(V,-1,E);
	
	cout<<"Yes"<<endl;
	
	for(int i=0;i<N;i++)cout<<P[i]<<endl;
	
    return 0;
}


Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int A[N - 1];
    int cnt[N];
    for(int i = 0; i < N; i++) cnt[i] = 0;
    for(int i = 0; i < N - 1; i++){
        cin >> A[i];
        cnt[A[i] - 1]++;
    }
    
    for(int i = 0; i < N; i++) cout << cnt[i] << "\n";
    return 0;
}

Measured memory_bytes: 5144
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class DirectedGraph {
public:
    int V;
    vector<vector<int>> costs;

    DirectedGraph(int v) : V(v), costs(v, vector<int>(v, INF)) {
        for (int i = 0; i < V; i++) {
            costs[i][i] = 0;
        }
    }

    void add_edge(int u, int v, int cost) {
        costs[u][v] = cost;
    }

    void warshall_floyd() {
        for (int k = 0; k < V; k++) {
            for (int i = 0; i < V; i++) {
                for (int j = 0; j < V; j++) {
                    costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
                }
            }
        }
    }
};

signed main() {
    int N, M, R;
    cin >> N >> M >> R;

    int r[R];
    for (int i = 0LL; i < R; i++) cin >> r[i];
    sort(r, r + R);

    DirectedGraph g = DirectedGraph(N);
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }
    g.warshall_floyd();

    int ret = INF;

    do {
        int dis = 0LL;
        for (int i = 0; i < R - 1; i++) {
            dis += g.costs[r[i] - 1LL][r[i+1LL] - 1LL];
        }

        ret = min(ret, dis);
    } while (next_permutation(r, r + R));

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<string,string> pss;
typedef pair<int,int> pii;
typedef pair<pair<pss,pss>,pair<pii,char> > pssc;//red:green:bottom:hidari:down's count:slide's count:center

string red,green,bottom,h;
char center;

void down(){
	if(center!=0){
		bottom+=center;
		center=0;
	}
	if(red.size()>0){
		center=red[0];
		red.erase(red.begin());
	}
}

void slide(){
	if(center!=0){
		h+=center;
		center=0;
	}
	if(green.size()>0){
		center=green[0];
		green.erase(green.begin());
	}
}

int main(){
	string ans,ansbottom;
	while(1){
		cin>>red;
		if(red=="-")break;
		cin>>green>>ansbottom;
		h="";
		int limitd=red.size();
		int limits=green.size()+1;
		center=0;
		bottom="";
		slide();
		pssc now,alt;
		now.first.first.first=red;
		now.first.first.second=green;
		now.first.second.first=bottom;
		now.first.second.second=h;
		now.second.second=center;
		now.second.first.first=0;
		now.second.first.second=1;
		queue<pssc> que;
		que.push(now);
		while(!que.empty()){
			alt=now=que.front();
			que.pop();
			red=now.first.first.first;
			green=now.first.first.second;
			bottom=now.first.second.first;
			h=now.first.second.second;
			center=now.second.second;
			if(now.second.first.first>limitd)continue;
			if(now.second.first.second>limits)continue;
			bool check=false;
			rep(i,bottom.size()){
				if(bottom[i]!=ansbottom[i]){
					check=true;
					break;
				}
			}
			if(check)continue;
			if(red.size()==0 && green.size()==0 && center==0){
				if(ansbottom==bottom){
					ans=h;
					break;
				}
			}
			if(red.size()>0){
				down();
				now.first.first.first=red;
				now.first.first.second=green;
				now.first.second.first=bottom;
				now.first.second.second=h;
				now.second.second=center;
				now.second.first.first++;
				que.push(now);
			}else if(center!=0){
				down();
				now.first.first.first=red;
				now.first.first.second=green;
				now.first.second.first=bottom;
				now.first.second.second=h;
				now.second.second=center;
				now.second.first.first++;
				que.push(now);
			}
			now=alt;
			red=now.first.first.first;
			green=now.first.first.second;
			bottom=now.first.second.first;
			h=now.first.second.second;
			center=now.second.second;
			if(green.size()>0){
				slide();
				now.first.first.first=red;
				now.first.first.second=green;
				now.first.second.first=bottom;
				now.first.second.second=h;
				now.second.second=center;
				now.second.first.second++;
				que.push(now);
			}else if(center!=0){
				slide();
				now.first.first.first=red;
				now.first.first.second=green;
				now.first.second.first=bottom;
				now.first.second.second=h;
				now.second.second=center;
				now.second.first.second++;
				que.push(now);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main()
{
	int n, k, x, y, resp = 0;
	cin >> n >> k >> x >> y;
	
	int aux = n - k;
	for(int i = 1; i <= n; i++)
		if(i > k) resp += y;
		else resp += x; 
	cout << resp;
	return 0;
}

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

int main(){
  int n,a,b,c,d;
  cin >> n;
  a = n / 1000;
  b = n / 100 - a * 10;
  c = n / 10 - a * 100 - b * 10;
  d = n - a *1000 - b * 100 - c * 10;
  if (b != c){
    cout << "No" << endl;
  }
  else{
    if(a == b || c == d){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
int main(){
  std::string s, m, d;
  std::cin >> s;
  int month, day;
  m = s.substr(5,2);
  d = s.substr(8,2);
  month = atoi(m.c_str());
  day = atoi(d.c_str());
  if(month <= 4){
    std::cout << "Heisei" << std::endl;
  }else{
    std::cout << "TBD" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    ll n,k;cin >> n >> k;
    vector <ll> bl;
    set <ll> s1;
    ll arr[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin >> arr[i];
    }
    ll kk = arr[1];
    bl.pb(1);
    s1.insert(1);
    ll r2 = 0;
    while(1)
    {
        if(s1.find(kk) != s1.end()) {r2 = kk;break;}
        else s1.insert(kk);
        bl.pb(kk);
        kk=arr[kk];
    }
    vector <ll> bkl;
    vector <ll> loop;
    loop.pb(r2);
    ll fl = 0;
    for(auto i:bl)
    {
        if(fl==1)
        {
            loop.pb(i);
            continue;
        }
        if(i!=r2)
        {
            bkl.pb(i);
        }
        else
        {
            fl = 1;
        }
    }
    // for(auto i:loop)
    // {
    //     cout << i << endl;
    // }
    // cout << endl;
    // for(auto i:bkl)
    // {
    //     cout << i << endl;
    // }
    // k--;
    if(k<bkl.size())
    {
        cout << bkl[k] << endl;
        return 0;
    }
    k = k-bkl.size();
    k = k%loop.size();
    cout << loop[k] << endl;
    
}
    

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

using namespace std;
int n, a[100001], k;
int main(){
    cin >> n >> k;
    int mn = 1e5 + 1, pos = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(mn > a[i]){
            mn = a[i];
            pos = i;
        }
    }
    int l = pos, r = pos, ans = 0;
    while(l > 1){
        if(l - k + 1 > 0){
            l = l - k + 1;
        }
        else{
            r = r + (k - (l - 1 + 1));
            l = 1;
        }
        ans++;
    }
    while(r < n){
        r = r + k - 1;
        ans++;
    }
    cout << ans;
}


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


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

  int max = 0;
  int count = 0;
  for(int i = 0; i < N; i++) {
    if(max <= H[i]) {
      count++;
      max = H[i];
    }
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 256
/**
 *      ABC 70 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 22:25:00
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    N / 100 == N % 10 ? cout << "Yes" : cout << "No";

    return 0;
}


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

struct unionfindtree {
    vector<int> parent;

    unionfindtree(int n): parent(n) {
        iota(begin(parent), end(parent), 0);
    }

    int find(int x) {
        return parent[x] == x ? x : parent[x] = find(parent[x]);
    }

    void unite(int x, int y) {
        parent[find(x)] = find(y);
    }
};

int main() {
    int n, k, l;
    cin >> n >> k >> l;

    unionfindtree roadtree(n), railtree(n);
    for (int i = 0; i < k; i++) {
        int p, q;
        cin >> p >> q, p--, q--;
        roadtree.unite(p, q);
    }
    for (int i = 0; i < l; i++) {
        int r, s;
        cin >> r >> s, r--, s--;
        railtree.unite(r, s);
    }

    map<int, vector<int>> roadcity;
    for (int i = 0; i < n; i++) {
        roadcity[roadtree.find(i)].push_back(i);
    }

    vector<int> ans(n);
    for (auto& rc : roadcity) {
        map<int, int> tmp;
        for (auto& e : rc.second) tmp[railtree.find(e)]++;
        for (auto& e : rc.second) ans[e] = tmp[railtree.find(e)];
    }
    for (auto& e : ans) cout << e << endl;
}


Measured memory_bytes: 22912
k=int(input())
v=[1]*k
if k==1 or k==7:
  print(1)
  exit()
m=7%k
v[m]=0
for i in range(k):
  m=(10*m+7)%k
  if m==0:
    c=i+2
    break
  elif v[m]:
    v[m]=0
  else:
    c=-1
    break
print(c)

Measured memory_bytes: 16772
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b;
  cin >> a >> b;
  cout << a * b << "\n";
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    for( int i = 1; i < n; i++ )    {
        if( s[i] != s[i-1] ) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main() {
  int a,b;
  string s,t,u;
  cin>>s>>t>>a>>b>>u;
  if(u==s){
    cout<<a-1<<" "<<b<<endl;
  }
  else{
    cout<<a<<" "<<b-1<<endl;
  }
}

Measured memory_bytes: 256
using System;
using System.IO;
//using System.Collections.Generic;
	class Program
	{
		public static void Main(string[] args)
		{
			
			//??????????????§??°??????????????????????????¨??????????????????????????????????????£????????????
			
			Stream inputStream=Console.OpenStandardInput();
			StreamReader sr =new StreamReader(inputStream);
			string text =sr.ReadToEnd();
			sr.Close();
			
			string[] textArray=text.Replace("\r\n", "\n").Split('\n');
			
			double n=double.Parse(textArray[0]);
			int[] array= new int[(int)n];
			/*
			 * //??????????????????text???????????????????§?????????????
			array=Array.ConvertAll(text.Replace("\r\n", "\n").Split('\n')
                ,
                new Converter<string,int>( s 
                                          => int.Parse(s) ));
			*/
			//?????????????????????????????§??????????????¨?????????
            for(int k=0;k<array.Length;k++)
			{
            	array[k]=int.Parse(textArray[k+1]);
			}
			
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???
			
			while((Math.Pow(3,m+1)-1)/2<n)//?????????m+1??????
			{
				m++;
			}
			
		/*	
			for(int gap=2;(Math.Pow(3,gap)-1)/2<n;gap++)
			{			
				m++;
			}
		*/	
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<G.Length;i++)//??????.Length????????????????????? m=G.Length
			{
				G[m-1-i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int s=0;s<G.Length;s++)
			{
				cnt+=sort( array, G[s]);//?????\???????????????????????????????????????????????´???????????????????????????????????????
				
				
				
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<G.Length-1;o++)
			{
				Console.Write(G[o]+" ");
			}
			Console.Write(G[G.Length-1]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
Console.SetOut(sw);
/*????????????????????????*/
			for(int l=0;l<array.Length;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			Console.Out.Flush();
			
		}
		public static int sort(int [] A,int g)
		{
			//g????????£??????
			int count=0;//??????????????°
			int v=0;
			int j=0;
			for (int k=0;k<g;k++)
			{
				//?????\?????????
			for(int i=k+g;i<A.Length;i+=g)
			{
				
				 v=A[i];
				 j=i-g;
				while(j>=0 &&
				       A[j]>v)//???&&????????§???????????????????????????
				{
					A[j+g]=A[j];
					
				A[j]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				j=j-g;
					//?????????????????£??????????????\??¨????????¢?????§???????????§????????????
					//??§????????????????????????????????????
				count ++; //????????????????????§????????????????????§??????????????¢??????
				
				}
				
			}
			}
			return count;
		}
		
	}
	

Measured memory_bytes: 130780
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static class Root {
        int root;
        int size;
        Root (int root) {
            this.root = root;
            this.size = 1;
        }
    }

    static Root find(int i) {
        if(roots[i].root == i) {
            return roots[i];
        }
        roots[i].root = roots[roots[i].root].root;
        return find(roots[i].root);
    }

    static void union(Root a, Root b) {
        if(a.root == b.root) return;
        a.root = b.root;
        b.size += a.size;
    }

    static Root[] roots;

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int K = scan.nextInt();
        roots = new Root[N];
        int[] friends = new int[N];
        int[] blocks = new int[N];
        for(int i = 0; i < N; i++) {
            roots[i] = new Root(i);
        }

        for(int i = 0; i < M; i++) {
            int A = scan.nextInt()-1;
            int B = scan.nextInt()-1;
            friends[A]++;
            friends[B]++;
            Root rootA = find(A);
            Root rootB = find(B);
            union(rootA, rootB);
        }

        for(int i = 0; i < K; i++) {
            int C = scan.nextInt()-1;
            int D = scan.nextInt()-1;
            Root rootC = find(roots[C].root);
            Root rootD = find(roots[D].root);
            if(rootC.root == rootD.root) {
                blocks[C]++;
                blocks[D]++;
            }
        }

        for(int i = 0; i < N; i++) {
            Root root = find(i);
            int possible = root.size - friends[i] - blocks[i] - 1;
            os.print(possible);
            if(i != N-1)
                os.print(" ");
        }
        os.println();
    }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

string s;
int n;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  cin>>s;
  n = s.length();
  int ans = n;
  
  s = "*" + s;
  
  for (int i=1; i+1<=n; i++) {
    if (s[i]!=s[i+1]) {
      ans = min(max(i,n-i), ans);
    }
  }

  cout<<ans<<endl;  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 512
INF=10**18
N,M,X=gets.split.map(&:to_i)
B=N.times.map{gets.split.map(&:to_i)}
ans=INF
(2**N).times do |used|
  x=Array.new(M){0}
  cost=0
  N.times do |i|
    next if used[i].zero?
    cost+=B[i][0]
    M.times do |j|
      x[j]+=B[i][j+1]
    end
  end
  ans=[ans,cost].min if x.all?{|i|X<=i}
end
p ans==INF ? -1 : ans

Measured memory_bytes: 14580
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

inline int sign(ll x){
	if(x >= 0LL) return 1;
	else return -1;
}

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

    int n; cin >> n;
    vi xs(n), ys(n);
    rep(i, n) cin >> xs[i] >> ys[i];

    int m = 39;
    vll d(m);
    rep(i, m) d[i] = (1LL << i);
    reverse(_all(d));

    bool iseven = false;
    rep(i, n){
    	bool cur = false;
    	if((xs[i] + ys[i]) % 2 == 0){
    		if(i == 0) d.emplace_back(1LL), m++;
    		cur = true;
    	}
    	if(i >= 1 and iseven != cur){
    		cout << -1 << endl;
    		return 0;
    	}
    	iseven = cur;
    }

    cout << m << endl;
    rep(i, m){
    	cout << (i ? " ":"") << d[i];
    }
    cout << endl;

    rep(i, n){
    	int x = xs[i], y = ys[i];
    	ll cx = 0LL, cy = 0LL;
    	string res = "";

    	rep(j, m){
    		ll xx = x - cx;
    		ll yy = y - cy;

    		if(abs(xx) >= abs(yy)){
    			if(xx >= 0LL){
    				cx += d[j];
    				res += 'R';
    			}
    			else {
    				cx -= d[j];
    				res += 'L';
    			}
    		}
    		else {
    			if(yy >= 0LL){
    				cy += d[j];
    				res += 'U';
    			}
    			else {
    				cy -= d[j];
    				res += 'D';
    			}
    		}
    	}
    	cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s.find("AC") != string::npos)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()

c = [0]
cum = 0
for i in range(1, len(s)):
  if s[i-1:i+1] == 'AC':
    cum += 1
    c.append(cum)
  else:
    c.append(cum)

for i in range(q):
  l, r = map(int, input().split())
  print(c[r-1] - c[l-1])

Measured memory_bytes: 6180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 

template <class T>
class SegTree {
    int n;// 葉の数
    vector<T> data;// データを格納するvector
    T def; // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;// 点更新で使う処理

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }

    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
        function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};

int main(){
    ll n,q;cin >> n >> q;
    SegTree<ll> st(
        n,0,[](ll a,ll b){return a+b;},[](ll a,ll b){return a+b;}
    );
    while(q--){
        ll t;cin >> t;
        if(t){
            ll a,b;cin >> a>>b;a--;
            cout << st.query(a,b) <<endl;
        }
        else{
            ll a,b;cin >> a >> b;a--;
            st.change(a,b);
        }
    }
}


Measured memory_bytes: 4956
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

bool only(string S){
    bool res=true;
    rep(i,S.size()-1) if(S[i]!=S[i+1]) res=false;
    return res;
}

int main(void){
    string S;
    cin >> S;
    int N=S.length();
    int alf[3]={};
    rep(i,N) alf[S[i]-'a']++;
    int mini=min3(alf[0],alf[1],alf[2]);
    bool ans=true;
    rep(i,3) if(alf[i]-mini>1) ans=false;
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  int max_x = -200;
  int min_y = 200;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    max_x = x > max_x ? x : max_x;
  }

  for (int i = 0; i < M; i++) {
    int y;
    cin >> y;
    min_y = y < min_y ? y : min_y;
  }

  bool ans = false;
  for (int z = X + 1; z <= Y; z++) {
    if (max_x < z && z <= min_y) {
      ans = true;
    }
  }
  if (ans) {
    cout << "No War\n";
  } else {
    cout << "War\n";
  }
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split(" ").map(Number).sort(function(a,b){return a-b;});
  if((input[1]-input[0])%2==0){
  console.log((input[1]-input[0])/2+input[2]-input[1]);
  }else{
    console.log((input[2]*2-input[1]-input[0]+3)/2);
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>

using namespace std;


int main()
{
    double ev[1001];
    ev[1] = 1;
    for (int i = 2; i <= 1000; i++)
    {
        ev[i] = i + ev[i - 1];
    }
    for (int i = 2; i <= 1000; i++)
    {
        ev[i] /= i;
    }
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    double rez = 0;
    double curr = 0;
    for (int i = 0; i < k; i++)
    {
        curr += ev[p[i]];
    }
    rez = curr;
    for (int i = k; i < n; i++)
    {
        curr += ev[p[i]] - ev[p[i - k]];
        rez = max(rez, curr);
    }
    cout << fixed << setprecision(7) << rez << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int a,b,c,temp=0;
    scanf("%d %d %d",&a,&b,&c);
    temp=a;
    a=b;
    b=temp;
    temp=a;
    a=c;
    c=temp;
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 1704
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll dp[maxn];
ll n,W;
ll v[maxn];
ll w[maxn];
int main()
{
    memset(dp,0x3f,sizeof(dp));
    gbtb;
    cin>>n>>W;
    repd(i,1,n)
    {
        cin>>w[i]>>v[i];
    }
    ll ans=0ll;
    dp[0]=0;
    repd(i,1,n)
    {
        for(int j=1e5;j>=v[i];--j)
        {
            {
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
                if(dp[j]<=W)
                    ans=max(ans,(ll)(j));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str1,str2;
  cin >> str1 >> str2;
  int ans=0;
  
  for(int i = 0; i < 3 ; i++){
  	if(str1.at(i) == str2.at(i)){
    	ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u64,
    }
    println!("{}", 800 * n - 200 * (n / 15));
}


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

using namespace std;

int main(){
    int K,N;    
    cin >> K >> N;

    vector<int> A(N);
    for(int i;i<N;i++){
        cin >> A[i];
    }
    
    vector<int> B(N);

    for(int i=0;i<N;i++){
        if(i==N-1){B[i]=K-(A[i]-A[0]);}
        else{B[i]=A[i+1]-A[i];}
    }

    int temp=0;
    int sum=0;

    for(int i=0;i<N;i++){
        if(temp<B[i]){temp=B[i];}
    }
    
    int kai;
    kai = K-temp;

    cout << kai << endl;
    
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX (101)
#define MOD (1000000007)

using namespace std;

typedef long long ll;

ll n, k;
char s[10];

int main() {
    cin >> n;
    cin >> s;
    cin >> k;
    
    char moji = s[k - 1];
    REP(i, n) {
        if (moji == s[i]) {
            cout << s[i];
        } else {
            cout << "*";
        }
    }
}


Measured memory_bytes: 256
<?php
  
$ab = explode(' ', trim(fgets(STDIN)));
$a = $ab[0];
$b = $ab[1];

$c = 0;
$p = 1;
while($p<$b){
  $p--;
  $p += $a;  
  $c++;
  if ($p >= $b) break;
}

echo $c;
  
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
typedef double D;
typedef complex<D> P;
#define X real()
#define Y imag()

P rot(P p, double a,P p1){
  a=a*M_PI/180.0;
  p-=p1;
  double x=p.X*cos(a)+p.Y*(-sin(a));
  double y=p.X*sin(a)+p.Y*cos(a);
  return P(x,y);
}


int main(){
  int n;
  while(cin>>n,n!=-1){
    P p=P(1,0);
    rep(i,n-1){
      P x=rot(P(0,0),270,p);
      x/=abs(x);
      p+=x;
    }
    printf("%.9f\n%.9f\n",p.X,p.Y);
  }
}



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

int main(){
    int count = 0;
    int N;
    cin >> N;
    int *L;
    L = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (L[i] != L[j]) {
                for (int k = j + 1; k < N; k++) {
                    if (L[i] != L[k] && L[j] != L[k]) {
                        if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) {
                            count += 1;
                        }
                    }
                }
            }
        }
    }
    cout << count;
    delete[] L;
    return 0;
}

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

using pii = pair<int,int>;
using piii = pair<int,pair<int,int>>;
using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define gold first
#define silver second.first
#define bronze second.second

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int x,y,z;
	cin>>x>>y>>z;
	int n = x+y+z;
	pair<int,pii> arr[n];
	f(i,0,n) {
		int a,b,c;
		cin>>a>>b>>c;
		arr[i] = {a,{b,c}};
	}
	sort(arr,arr+n,[](piii a, piii b) {
		return (a.gold-a.silver)>(b.gold-b.silver);
	});
	priority_queue<int> pq;
	ll dpl[z+1], dpr[z+1];
	f(i,0,z+1) dpl[i] = dpr[i] = 0;
	ll sum = 0;
	f(i,0,x) {
		sum += arr[i].gold;	
		pq.push(arr[i].bronze-arr[i].gold);
	}
	dpl[0] = sum;
	f(i,0,z) {
		pq.push(arr[x+i].bronze-arr[x+i].gold);
		sum += arr[x+i].gold;
		sum += pq.top(); pq.pop();
		dpl[i+1] = sum;
	}
	sum = 0; pq = priority_queue<int>();
	f(i,0,y) {
		sum += arr[n-1-i].silver;
		pq.push(arr[n-1-i].bronze-arr[n-1-i].silver);
	}
	dpr[z] = sum;
	f(i,0,z) {
		pq.push(arr[n-1-y-i].bronze-arr[n-1-y-i].silver);
		sum += arr[n-1-y-i].silver;
		sum += pq.top(); pq.pop();
		dpr[z-1-i] = sum;
	}
	ll ans = 0;
	f(i,0,z+1)
		ans = max(ans,dpl[i]+dpr[i]);
	cout << ans << endl;
	

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 2688
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int C = sc.nextInt();
		long K = sc.nextLong();
		long[] T = nextLongArray(sc,N);

		sc.close();

		Arrays.sort(T);

		int ans = 0;

		int cnt = 0;
		long t=0;

		for(int i=0;i<N;i++) {
			//バスにのってるひとがいない
			if(cnt == 0) {
				t = T[i]+K;
				cnt++;
			}else {
				if(T[i] > t) {
					//T[i]が出発時刻をすぎていたら、
					ans++;//バス出発して
					cnt=1;//次のバスに乗る
					t = T[i]+K;
				}else {
					//T[i]が出発時刻をすぎていない
					//まだ乗れるなら乗る
					if(cnt < C) {
						cnt++;
					}else {
						//乗れないなら、
						ans++; //バス出発
						cnt=1; //新しいバスに乗る
						t = T[i]+K;
					}
				}
			}
		}
		//乗ってる人が残っていたら、バス出発
		if(cnt>0) {
			ans++;
		}

		out.println(ans);

	}

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

	@SuppressWarnings("unused")
	private long[] nextLongArray(Scanner sc, int n) {
		long[] result = new long[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextLong();
		}
		return result;
	}
}


Measured memory_bytes: 50236
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    cnt = {"_A": 0, "B_": 0, "B_A": 0}
    ans = 0
    for _ in range(n):
        s = input()
        if s[0] == "B" and s[-1] == "A":
            cnt["B_A"] += 1
        elif s[0] == "B":
            cnt["B_"] += 1
        elif s[-1] == "A":
            cnt["_A"] += 1
        # 含まれるABを探す
        for i in range(len(s) - 1):
            if s[i:i + 2] == "AB":
                ans += 1

    # 接続することで作れるABを探す
    # B_Aで貪欲にABを作る
    if cnt["B_A"] > 1:
        ans += cnt["B_A"] - 1
        cnt["B_A"] = 1
    # B_A,_A,B_の組み合わせを作る
    if cnt["_A"] > 0 and cnt["B_"] > 0 and cnt["B_A"] > 0:
        ans += 2
        cnt["_A"] -= 1
        cnt["B_"] -= 1
        cnt["B_A"] -= 1
    # 残りで作る

    ans += min(sorted([cnt["_A"], cnt["B_"], cnt["B_A"]])[1:])

    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 73524
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

void solve (int n)
{
    vi l(2 * n);
    for (int i = 0; i < 2 * n; i++)
        cin >> l[i];
    sort(ALL(l));
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2)
        ans += l[i];
    cout << ans << endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    while (cin >> n)
        solve(n);
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

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



  return 0;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int  a = sc.nextInt();
		int  b = sc.nextInt();
		int ans=0;
		if(a>b){
			ans+=a;
			a--;
		}else{
			ans+=b;
			b--;
		}
		if(a>b){
			ans+=a;
			a--;
		}else{
			ans+=b;
			b--;
		}
		System.out.println(ans);
	}
}


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

int main(){
  int A,B,counter=0;
  cin >> A >> B;
  int num = A;
  rep(i,B-A+1){
    int n1,n2,n4,n5;
    n5 = num % 10;
    n4 = (num % 100)/10;
    n2 = (num % 10000)/1000;
    n1 = num / 10000;
    if((n5 == n1)&&(n4 == n2))
      counter++;
    num++;
  }
  cout << counter << endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf (1LL<<60)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;

vll x, y, z;
ll N, M;

int main()
{
    cin >> N >> M;
    x.resize(N), y.resize(N), z.resize(N);
    rep(i, N) cin >> x[i] >> y[i] >> z[i];

    ll maxn = -inf;
    rep(i, 2) rep(j, 2) rep(k, 2) {
        priority_queue<pair<ll, vector<ll>>> que;
        rep(l, N) que.push(
            {
                (i == 0 ? 1 : -1) * x[l] + (j == 0 ? 1 : -1) * y[l] + (k == 0 ? 1 : -1) * z[l],
                {x[l], y[l], z[l]}
            }
        );

        ll x_sum = 0, y_sum = 0, z_sum = 0;
        rep(i, M) {
            //cout << que.top().first << ": " << endl;
            vll v = que.top().second; que.pop();
            //cout << v[0] << " " << v[1] << " " << v[2] << endl;
            x_sum += v[0], y_sum += v[1], z_sum += v[2];
        }
        //cout << endl;
        maxn = max(maxn, abs(x_sum) + abs(y_sum) + abs(z_sum));
    }
    cout << maxn << endl;

    return 0;
}

Measured memory_bytes: 384
import math

n = int(input())

ans=0
for i in range(n):
    x = int(input())
    if x%2==0 and x!=2:
        pass
    else:
        limit=int(math.sqrt(x))
        judge=True

        for j in range(3,limit+1,2):
            if x%j==0:
                judge=False
                break

        if judge:
            ans+=1
            #print(x,": prime number")
    
print(ans)



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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define in insert
#define mp(a, b) make_pair(a, b)
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define INF INT_MAX
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	int n, m, x;
	cin>>n>>m>>x;
	vi c(n);
	int a[n][m];
	int min_cost = INF;
	forn(i, n){ cin>>c[i]; forn(j, m) cin>>a[i][j]; }
	forn(i, 1<<n){
		vi curr(m, 0); int cost = 0;
		forn(j, n){
			if(i>>j&1){
				cost += c[j];
				forn(k, m)
					curr[k] += a[j][k];
			}
		}
		bool isValid = true;
		forn(j, m)
			isValid = isValid && (curr[j]>=x);
		if(isValid)
			min_cost = min(min_cost, cost);
	}
	if(min_cost==INF)
		cout<<-1<<endl;
	else
		cout<<min_cost<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    map<ll,ll> z;
    vector<ll> w(n),s(n);
    rep(i,n) {
        ll a;
        cin >> a;
        w[i] = a+i+1;
        s[i] = i+1-a;
        z[s[i]]++;
    }
    ll ans = 0;
    rep(i,n){
        ans+=z[w[i]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 28948