akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DEqueue solver = new DEqueue();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEqueue {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int v[] = new int[n];
            for (int i = 0; i < n; i++) v[i] = in.nextInt();
            int pre[] = new int[n + 1];
            int post[] = new int[n + 1];
            long ans = 0;
            for (int i = 1; i <= n; i++) pre[i] += pre[i - 1] + v[i - 1];
            for (int i = 1; i <= n; i++) post[i] += post[i - 1] + v[n - i];
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    if (i + j <= n && i + j <= k) {
                        int rem = k - i - j;
                        long curr = pre[i] + post[j];
                        ans = Math.max(ans, curr);
                        PriorityQueue<Integer> pq = new PriorityQueue<>();
                        for (int l = 0; l < i; l++) {
                            if (v[l] < 0)
                                pq.add(v[l]);
                        }
                        for (int l = 0; l < j; l++) {
                            if (v[n - l - 1] < 0)
                                pq.add(v[n - l - 1]);
                        }
                        for (int l = 0; l < rem && pq.size() > 0; l++) {
                            curr += -pq.poll();
                        }
                        ans = Math.max(ans, curr);
//                    out.println(curr + " " + i + " " + j);

                    }
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 24916
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int w = sc.nextInt();
	int n = sc.nextInt();
	int[] way = new int[w];
	for(int i = 0; i < way.length; i++){
	    way[i] = i+1;
	}
	for(int i = 0; i < n; i++){
	    String str = sc.next();
	    String[] ab = str.split(",");
	    int a = Integer.parseInt(ab[0]) - 1;
	    int b = Integer.parseInt(ab[1]) - 1;
	    int c = way[a];
	    way[a] = way[b];
	    way[b] = c;
	}
	for(int i = 0; i < way.length; i++){
	    System.out.println(way[i]);
	}
    }
}

Measured memory_bytes: 26252
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

class Main{
	private static LinkedList<LinkedList<Integer>> adjList;
	private Scanner input;
	
	public void loadAdjList() {
		input = new Scanner(System.in);
		int vertices = input.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < vertices; i++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int vertice = input.nextInt();
			tmp.add(vertice);
			int numNeighbors = input.nextInt();
			for(int j = 0; j < numNeighbors; j++) {
				tmp.add(input.nextInt());
			}
			adjList.add(tmp);
		}
	}
	public void shortPath(int s) {
		boolean visited[] = new boolean[adjList.size()+1];
		int[] distances = new int[adjList.size()+1];
		int distance = 0;
		
		LinkedList<Integer> queue = new LinkedList<Integer>();
		
		visited[s] = true;
		queue.add(s);
		distances[s] = distance;
		
		while(queue.size() != 0) {
			s = queue.poll();
			Iterator<Integer> i = adjList.get(s-1).listIterator();
			while (i.hasNext()) 
            { 
                int n = i.next(); 
                if (!visited[n]) 
                { 
                    visited[n] = true; 
                    distances[n] = distances[s] + 1;
                    queue.add(n); 
                } 
            } 
		}
		for(int i = 1; i < distances.length; i++) {
			if(visited[i] == false) {
				System.out.println((i)+ " " + "-1");
			}else {
				System.out.println((i) + " " + distances[i]);
			}
		}
	}
	public static void main(String[] args) {
		Main test = new Main();
		test.loadAdjList();
		test.shortPath(1);
		
	}
}



Measured memory_bytes: 28504
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

namespace geo
{
  const double EPS = 1e-10;

  class Point
  {
  public:
    double x, y;
    
    Point(double _x = 0.0, double _y = 0.0)
      :x(_x), y(_y) {}
    
    inline double abs() const
    {
      return sqrt(x*x + y*y);
    }
    
    // 内積
    inline double dot(const Point& p) const
    {
      return (x*p.x + y*p.y);
    }
    
    // 外積
    inline double cross(const Point& p) const
    {
      return (x*p.y - y*p.x);
    }
    
    // 直交
    /*
      AOJ0058: EPS -> 0.0 
    */
    inline bool orthogonal(const Point& p) const
    {
      if (dot(p) < EPS)
	return true;
      return false;
    }
    
    // 平行
    inline bool parallel(const Point& p) const
    {
      if (cross(p) < EPS)
	return true;
      return false;
    }
    
    Point operator +(const Point& p) const
    {
      return Point(x+p.x, y-p.y);
    }
    
    Point operator -(const Point& p) const
    {
      return Point(x-p.x, y-p.y);
    }
    
    Point operator =(const Point& p)
    {
      x = p.x;
      y = p.y;
    }
    
    bool operator ==(const Point& p) const
    {
      if ((*this - p).abs() < EPS)
	return true;
      return false;
    }
    
    bool operator <(const Point& p) const
    {
      if (std::abs(x-p.x) < EPS)
	return y < p.y;
      return x < p.x;
    }
  };

  // 凸包:graham scan(p.234) O(nlogn)
  vector<Point> convex_hull_gs(vector<Point>& ps)
  {
    sort(ps.begin(), ps.end());
    int k = 0, n = static_cast<int>(ps.size());
    vector<Point> qs(n * 2);
    for (int i = 0; i < n; ++i) {
      while (k > 1 && (qs[k-1] - qs[k-2]).cross(ps[i] - qs[k-1]) < EPS)
	--k;
      qs[k++] = ps[i];
    }

    for (int i = n-2, t = k; i >= 0; --i) {
      while (k > t && (qs[k-1] - qs[k-2]).cross(ps[i] - qs[k-1]) < EPS)
	--k;
      qs[k++] = ps[i];
    }

    qs.resize(k-1);
    return qs;
  }
}

int main()
{
  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    vector<geo::Point> p(n);
    for (int i = 0; i < n; ++i)
      scanf("%lf,%lf", &p[i].x, &p[i].y);

    printf("%d\n", p.size() - geo::convex_hull_gs(p).size());
  }
  return 0;
}

Measured memory_bytes: 0
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
int a[1000000];
int dp[1000000];
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
fastio;
	int n;
	cin>>n;
	for(int i=0; i<(1<<n); i++)
	{
		cin>>a[i];
	}
	for (int mask = 1; mask < (1<<n); mask++)
	{		
		int t1=0, t2=0;
	    for(int i = mask; ; i = (i-1) & mask)
		{
//			cout<<a[i]<<" ";
			if(t1<a[i]) 
			{
				t2=t1;
				t1=a[i];
			}
			else if(t2<a[i]) t2=a[i];
			if(!i) break;
		}
//		cout<<endl;
//		cout<<t1<<" "<<t2<<endl; 
		dp[mask]=max(dp[mask-1], t1+t2);
		cout<<dp[mask]<<endl;
    }
}




Measured memory_bytes: 5696
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define pb           push_back
#define ff           first
#define ss           second
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
using namespace std;

ll expo(ll a,ll b,ll m = mod){
	a%=mod;
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%m;
		a = (a*a)%m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
const ll INF = 1e18L + 5;
int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
// 	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    ll a[n+1];
	    ll pre[n+1];
	    pre[0] = 0;
	    rep(i,1,n+1){
	        cin>>a[i];
	        pre[i]=pre[i-1]+a[i];
	    }
	    ll dp[n+1][n+1];
	    mem(dp,0);
	    for(int i=1;i<n;i++)
	    dp[i][i+1] = a[i]+a[i+1];
	    for(int l=3;l<=n;l++){
	        for(int i=1;i<=n-l+1;i++){
	            int j = i+l-1;
	            dp[i][j] = INF;
	            for(int k=i;k<j;k++){
	                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+pre[j]-pre[i-1]);
	            }
	        }
	    }
	    cout<<dp[1][n]<<"\n";
	}

    return 0;
}


Measured memory_bytes: 4844
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> one = nextCharArray();
      String L = one.get(0);
      String R = one.get(2);
      myout((L.equals(R)) ? "Yes" : "No");
      
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}
const int mod = 1e9+7;
const int maxn = 2e5+10;
int fac[maxn], inv[maxn];

int qpow(int a, int n)
{
    int re = 1;
    while(n){
        if(n&1)re = 1LL*re*a%mod;
        a = 1LL*a*a%mod;
        n >>= 1;
    }
    return re;
}

void init()
{
    fac[0] = 1;
    for(int i = 1; i < maxn; i++)fac[i] = 1LL*fac[i-1]*i%mod;
    inv[maxn-1] = qpow(fac[maxn-1], mod-2);
    for(int i = maxn-2; i >= 0; i--)inv[i] = 1LL*inv[i+1]*(i+1)%mod;
}

int C(int n, int m)
{
    return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
    init();
    int n, m;
    sc(n); sc(m);
    ll ans = 1;
    for(int i = 2; i*i <= m; i++){
        if(m%i == 0){
            int t = 0;
            while(m%i == 0)m /= i, t++;
            ans = ans*C(n+t-1, t)%mod;
        }
    }
    if(m != 1)ans = ans*C(n, 1)%mod;
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>
#include <sstream>
#include <iomanip>

using namespace std;

using Graph = vector<vector<int> >;

vector<int> seen;


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

int main()
{
	int N;

	cin >> N;

	vector<int> As(N);

	for (int ni = 0; ni < N; ni++) {
		cin >> As[ni];
	}

	sort(As.begin(), As.end());

	vector<int> gcd_l(N);
	vector<int> gcd_r(N);

	int gl, gr;
	gcd_l[0] = As[0];
	gcd_r[N - 1] = As[N - 1];
	for (int ni = 1; ni < N; ni++) {
		gcd_l[ni] = gcd(gcd_l[ni - 1], As[ni]);
		gcd_r[N - 1 - ni] = gcd(gcd_r[N - ni], As[N - 1 - ni]);
	}

	int max_gcd = 0;
	int gcd_buf;
	for (int ni = 0; ni < N; ni++) {
		if (ni == 0) {
			gcd_buf = gcd_r[ni + 1];
		}
		else if (ni == N - 1) {
			gcd_buf = gcd_l[N - 2];
		}
		else {
			gcd_buf = gcd(gcd_l[ni - 1], gcd_r[ni + 1]);
		}
		if (gcd_buf > max_gcd) {
			max_gcd = gcd_buf;
		}
	}


	//printf("%d %d %lld", xi, yi, H + gap);

	cout << max_gcd;
	

	return 0;
}



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

bool dp[17][1<<16];
int main(){
  int n,h[16],w[16];
  char r[3]={'R','G','B'};
  string c[4];
  cin>>n;
  for(int i=0;i<n;i++)cin>>h[i]>>w[i];
  for(int i=0;i<4;i++)cin>>c[i];

  int a1[16][7][7],o1[16][3][7][7]={};
  for(int i=0;i<n;i++)
    for(int j=0;j<7;j++)for(int k=0;k<7;k++)a1[i][j][k]=(1<<16)-1;
  
  for(int k=0;k<n;k++)
    for(int cl=0;cl<3;cl++)
      for(int y=-h[k]+1;y<4;y++)
	for(int x=-w[k]+1;x<4;x++){
	  for(int l=max(0,y);l<min(4,y+h[k]);l++)
	    for(int m=max(0,x);m<min(4,x+w[k]);m++){
	      int xx=l*4+m;
	      if(c[l][m]==r[cl])o1[k][cl][y+3][x+3]|=1<<xx;
	      if(!cl)a1[k][y+3][x+3]-=1<<xx;
	    }
	}
  
  dp[0][0]=1;
  for(int j=0;j<16;j++)
    for(int i=0;i<1<<16;i++)
      if(dp[j][i])
	for(int k=0;k<n;k++)
	  for(int cl=0;cl<3;cl++)
	    for(int y=-h[k]+1;y<4;y++)
	      for(int x=-w[k]+1;x<4;x++){
		int ni=(i&a1[k][y+3][x+3])|o1[k][cl][y+3][x+3];
		dp[j+1][ni]=1;
		if(ni==(1<<16)-1){cout<<j+1<<endl;return 0;}
	      }
}

Measured memory_bytes: 4092
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include <deque>

using namespace std;
typedef long long ll;

vector<bool> ans;

int main() {
	while (1) {
		ll N, x, y, M, l[31] = {}, collected = 0, cur1 = 10, cur2 = 10;
		bool jewel[21][21] = {};
		char d[31] = {};
		cin >> N;
		if (N == 0)break;
		for (int i = 1; i <= N; i++) {
			cin >> x >> y;
			jewel[x][y] = true;
		}
		cin >> M;
		for (int i = 1; i <= M; i++) {
			cin >> d[i] >> l[i];
			if (jewel[10][10])collected++;
			for (int j = 1; j <= l[i]; j++) {
				switch (d[i]) {
				case 'N':
					cur2++;
					if (jewel[cur1][cur2]) {
						jewel[cur1][cur2] = false;
						collected++;
					}
					break;
				case 'E':
					cur1++;
					if (jewel[cur1][cur2]) {
						jewel[cur1][cur2] = false;
						collected++;
					}
					break;
				case 'S':
					cur2--;
					if (jewel[cur1][cur2]) {
						jewel[cur1][cur2] = false;
						collected++;
					}
					break;
				case 'W':
					cur1--;
					if (jewel[cur1][cur2]) {
						jewel[cur1][cur2] = false;
						collected++;
					}
				}
			}
		}
		ans.push_back(collected == N);
	}
	for (int i = 0; i < ans.size(); i++) {
		if (ans[i]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}


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

#define ll long long
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int x, a, b;
   cin >> x >> a >> b;
   x -= a;
   cout << x % b << endl;

   return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    int count = 0;
    for (int i = a; i <= b; i++) {
        s = to_string(i);
        if (s[0]==s[4] && s[1]==s[3]) count++;
    }
    cout << count << endl;
}

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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

struct UnionFind {
    vector<int> d;

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

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

    int size(int x) { return -d[find(x)]; }
};

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

int dfs(int l, char c, string s) {
    if (l == 0 || s == string(l + 1, c))return l;

    string t = "";
    for (int i = 0; i < l; ++i) {
        if (s[i] == c || s[i + 1] == c)t += c;
        else t += s[i];
    }
    return dfs(l - 1, c, t);
}

int main() {
    ll n;
    cin >> n;
    for (int h = 1; h <= 3500; ++h) {
        for (int w = 1; w <= 3500; ++w) {
            ll b = 4 * h * w - n * w - n * h;
            ll t = n * h * w;
            if (t > 0 && b > 0 && t % b == 0) {
                printf("%d %d %d\n", h, w, t / b);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;
const double EPS = 1e-20;
const double INF = 1e12;

typedef complex<double> P;
const P pINF(sqrt(2) * INF, sqrt(235) * INF);

double cross(const P &a, const P &b){
    return imag(conj(a)*b);
}

double dot(const P &a, const P &b){
    return real(conj(a)*b);
}

int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > 0) return +1;
    if(cross(b,c) < 0) return -1;
    if(dot(b,c) < 0) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

struct L : public vector<P> {
    L(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
};

bool intersectLL(const L &l, const L &m){
    return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || abs(cross(l[1]-m[0], m[1]-m[0])) < EPS;
}

bool intersectLS(const L &l, const L &s) {
    return cross(l[1]-l[0], s[0]-l[0]) * cross(l[1]-l[0], s[1]-l[0]) < EPS;
}
bool intersectLP(const L &l, const P &p) {
    return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
    return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

int polygonPointContainment(vector<P> &G, P p){
    int inside = 0;
    for (int i=0;i<G.size()-1;i++){
        P q = G[i] - p;
        P r = G[i+1] - p;
        if(imag(q) > imag(r)) swap(q,r);
            if(imag(q) <= 0 && imag(r) > 0 && cross(q,r) < 0){
                inside = 1 - inside;
            }
        if(cross(q,r) == 0 && dot(q,r) <= 0){
          return 1;
        }
    }
    return 2*inside;
}

int main(){
    int n, q;
    cin >> n;
    vector<P> G;
    P p;
    for (int i=0;i<n;i++){
        cin >> p.real() >> p.imag();
        G.push_back(p);
    }
    G.push_back(G[0]);

    cin >> q;
    for (int i=0;i<q;i++){
        cin >> p.real() >> p.imag();
        cout << polygonPointContainment(G, p) << endl;
    }

    return 0;
}

Measured memory_bytes: 3196
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	// "strings"
	"sort"
)

var stdin = initStdin()
 
func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func scanInt() int {
	stdin.Scan()
	i, _ := strconv.Atoi(stdin.Text())
	return i
}

func scanStr() string {
	stdin.Scan()
	return stdin.Text()
}

type ia []int

func (ia ia)Len() int {
	return len(ia)
}
func (ia ia)Swap(i, j int) {
	ia[i], ia[j] = ia[j], ia[i]
}
func (ia ia)Less(i, j int) bool {
	return ia[i] < ia[j]
}

func main() {
	n := scanInt()
	d := make(ia, n)
	for i := 0; i < n; i++ {
		d[i] = scanInt()
	}
	sort.Sort(d)
	h := n/2
	ans := d[h] - d[h-1]
	fmt.Println(ans)
}

Measured memory_bytes: 2560
S = input()
N = len(S)
T = 'AKIHABARA'
M = len(T)
for i in range(1 << 4):
    tmp = []
    for j in range(4):
        if i & 1 << j:
            tmp.append(j)

    t = ''
    num = 0
    for j in range(M):
        if T[j] == 'A':
            if num in tmp:
                t += 'A'
            num += 1
        else:
            t += T[j]

    if t == S:
        print('YES')
        exit()

print('NO')

Measured memory_bytes: 3064
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n;
	int a[100050];
	cin >> n;
	
	rep(i, n) cin >> a[i];
	int cnt = 1, next = 0;
	rep (i,n) {
		next = a[next] - 1;
		if (next == 1) {
			break;
		}
		
		cnt++;
		if (cnt > n) {
			cnt = -1;
		}
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
def main():
    N = int(input())
    task = [list(map(int, input().split())) for i in range(N)]
    task.sort(key = lambda x : x[1])
    time = 0

    for t in task:
        if time + t[0] <= t[1]:
            time += t[0]
        else:
            print("No")
            exit()

    print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 53648
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    ab = [map(int, input().split()) for _ in range(n)]
    a, b = [list(i) for i in zip(*ab)]
    new_a = sorted(a)
    new_b = sorted(b)
    if n % 2 == 1:
        min_m = new_a[(n + 1) // 2 - 1]
        max_m = new_b[(n + 1) // 2 - 1]
        print((max_m - min_m) + 1)
    else:
        min_m = (new_a[n // 2 - 1] + new_a[n // 2])
        max_m = (new_b[n // 2 - 1] + new_b[n // 2])
        print((max_m - min_m) + 1)


if __name__ == '__main__':
    main()


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int N;
    cin >> N;
    string S;
    cin >> S;
    int res = 0;
    while (true) {
        auto result = S.find("ABC");
        if (result == string::npos) {
            break;
        }
        S = S.substr(result + 3);
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(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; }

struct edge{ll to, cost;};
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;
  vector<ll> prev;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = LINF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = LINF;
    }
    d[s] = 0;
    priority_queue<pll,vector<pll>, greater<pll> > que;
    que.push(pll(0,s));
    prev.assign(V, -1);
    while(!que.empty()){
      pll p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          prev[e.to] = v;
          que.push(pll(d[e.to],e.to));
        }
      }
    }
  }

  vector<int> get_path(int t){ //頂点tへの最短路
    vector<int> path;
    for(; t != -1;t=prev[t]){
        path.push_back(t);
    }

    reverse(path.begin(), path.end());
    return path;
  }
};

int main(){
    int n; cin >> n;
    graph g(n);
    vector<vector<int>> G(n);
    rep(i, n-1){
        ll a, b, c; cin >> a >> b >> c; a--, b--;
        g.add_edge(a,b,c);
        g.add_edge(b,a,c);
    }
    int q, k; cin >> q >> k; k--;
    g.dijkstra(k);
    rep(i, q){
        int x, y; cin >> x >> y; x--, y--;
        cout << g.d[x] + g.d[y] << ln;
    }
}


Measured memory_bytes: 17144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

struct edge {int to, cost;};
typedef pair<int, int> P; // firstは最短距離, secondは頂点の番号

#define INF INT_MAX/2
const int MAX_V=2500;
int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int pre[MAX_V];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+V, INF);
  fill(pre,pre+V,-1);
  d[s]=0;
  que.push(P(0, s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second; // 頂点の番号
    if (d[v] < p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        pre[e.to]=v;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

vector<int> get_path(int t){
  // s to t;
  vector<int> path;
  for(;t!=-1;t=pre[t]) path.push_back(t);
  reverse(path.begin(),path.end());
  return path;
}


int main(){
  int h,w;
  cin>>h>>w;
  V=h*w;
  string s[h];
  for(int i=0;i<h;i++) cin>>s[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int x=i*w+j;
      if(s[i][j]!='.'){
        continue;
      }
      if(j<w-1){
        if(s[i][j+1]=='.'){
          G[x].push_back({x+1,1});
          G[x+1].push_back({x,1});
        }
      }
      if(i<h-1){
        if(s[i+1][j]=='.'){
          G[x].push_back({x+w,1});
          G[x+w].push_back({x,1});
        }
      }
    }
  }

  dijkstra(0);
  if(d[h*w-1]==INF){
    cout<<-1<<endl;
    return 0;
  }
  vector<int> path=get_path(h*w-1);
  int c=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='.') c++;
    }
  }
  cout<<c-path.size()<<endl;
  return 0;
}


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

int main() {
  int A , B , C;
  cin >> A >> B >> C;
  if(C > A && B > C){
    cout << "Yes" << endl;
  }
  else if(A > C && C > B){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int n;
    scanf("%d",&n);
    int ans[n + 1];
    for(int i = 1; i <= n; i++)
        ans[i] = 0;
    for(int i = 1; i < 105; i++)
        for(int j = 1; j < 105; j++)
            for(int k = 1; k < 105; k++){
                int m = i * i + j * j + k * k + i * j + i * k + j * k;
                if(m <= n)
                    ans[m] ++;
            }
    for(int i = 1; i <= n; i++)
        printf("%d\n",ans[i]);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int m,d;
	cin>>m>>d;
	int ans=0;
	FOR(i, 1, m+1){
		FOR(j, 1, d+1){
			if(j<10){
				continue;
			}
			int a=j/10, b=j%10;
			if(a>=2 && b>=2 && a*b==i){
				++ans;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	vector<int>v(N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		scanf("%d.%d", &a, &b);
		v[i] = a * 1000 + b;
	}
	vector<int>nums(v);
	sort(v.begin(),v.end());
	for (int i = 0; i < N; ++i) {
		int k=nums[i];
		int a=lower_bound(v.begin(),v.end(),k)-v.begin();
		int b=upper_bound(v.begin(),v.end(),k)-v.begin();
		cout<<(N-b)*0+(b-a-1)*1+(a-0)*3<<endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
// VAR(int, x);
#define VAR(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { std::cin >> first; Scan(rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#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<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define IN(a, x, b) (a<=x && x<=b)
#define IN2(a0, y, a1, b0, x, b1) (a0<=y && y<a1 && b0<=x && x<b1)
#define SHOW(d) {std::cout << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cout << #v << "\t:";for(const auto& i : v){std::cout << i << " ";}std::cout << "\n";}
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout << j << " ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout<<'('<<j.first<<", "<<j.second<<") ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& i:v){std::cout<<'('<<i.first<<", "<<i.second<<") ";}std::cout<<"\n";}
#define CHECKTIME(state) {auto start=std::chrono::system_clock::now();state;auto end=std::chrono::system_clock::now();auto res=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();std::cerr<<"[Time:"<<res<<"ns  ("<<res/(1.0e9)<<"s)]\n";}

#define int ll
using ll = long long;
constexpr int INFINT = 1 << 30;
constexpr ll INFLL = 1LL << 60;
constexpr double EPS = 0.0000001;
constexpr int MOD = 1000000007;

signed main() {
	INIT;
	VAR(int, n);
	VEC(int, l, n*2);
	std::sort(ALL(l));
	int sum = 0;
	REP(i, n) {
		sum += l[i * 2];
	}
	OUT(sum)BR;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


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

int main(){
    int n;
    cin >> n;
    ll c[5];
    memset(c,0,sizeof(c));
    for (int i  = 0;i < n;i++){
        string s;
        cin >> s;
        if (s[0] == 'M') c[0]++;
        else if (s[0] == 'A') c[1]++;
        else if (s[0] == 'R') c[2]++;
        else if (s[0] == 'C') c[3]++;
        else if (s[0] == 'H') c[4]++;
    }

    ll cnt = 0;
    for (int i = 0;i < 3;i++){
        for (int j = i + 1;j < 4;j++){
            for (int k = j + 1;k < 5;k++){
                if (c[i] > 0 and c[j] > 0 and c[k] > 0){
                    cnt += c[i] * c[j] * c[k];
                }
            }
        }
    }

    cout << cnt << endl;

}

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

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	for(int i=0;i<N;i++)
		cin >> a[i];
	
	sort(a.begin(),a.end());
	map<ll,ll> mp;
	bool flag = false;
	
	for(int i=0;i<N;i++) {
		mp[a[i]]++;
	}
	if(mp.size()==1) {
		if(a[N-1]==0)
			flag = true;
	}else if(mp.size()==2) {
		vector<pair<ll,ll>> tmp;
		for(auto i : mp) {
			tmp.push_back({i.first,i.second});
		}
		if(tmp[0].first == 0) {
			if(2*tmp[0].second == tmp[1].second) {
				flag = true;
			}
		}
	}else if(mp.size()==3) {
		vector<pair<ll,ll>> tmp;
		for(auto i : mp) {
			tmp.push_back({i.first,i.second});
		}
		if( (tmp[0].first^tmp[1].first^tmp[2].first) == 0) {
			if(tmp[0].second == tmp[1].second and tmp[1].second == tmp[2].second) {
				flag = true;
			}
		}
	}
	
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 5632
#include<cstdio>
int main()
{
	int l,n,m=0,i;
	scanf("%d",&l);
	for(n=0;1<<n<=l;++n);
	for(i=1;i<n;++i)if(l&(1<<i-1))++m;
	printf("%d %d\n",n,m+2*(n-1));
	for(i=1;i<n;++i)printf("%d %d %d\n%d %d %d\n",i,i+1,0,i,i+1,1<<i-1);
	for(m=1<<n-1,i=n;--i;)if(l&(1<<i-1))printf("%d %d %d\n",i,n,m),m+=1<<i-1;
}

Measured memory_bytes: 128
/* 

	 - If you fail to prepare, you are prepared to fail.	

	(C) Mark Spitz

*/

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

void setIO(string name = "") {
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	if (sz(name)) {
		freopen((name + ".in").c_str(), "r", stdin);
		freopen((name + ".out").c_str(), "w", stdout);
	}
}

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int MAXN = 1e5 + 5;

string s;

void solve() {
	cin >> s;
	
	if (s[sz(s) - 1] == 's') s += "es";
	else s += 's';
	
	cout << s;
}

main() {
	setIO();
	
	int tt = 1;
	//~ cin >> tt;
	while (tt--) {
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
#define N 10000
struct edge{
	int to,cost;
};
int par[N];
int q,n;


void init(int n){
	FOR(i,0,n)par[i]=i;
}

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

void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>q;
	init(n);
	int com,x,y;
	FOR(i,0,q){
		cin>>com>>x>>y;
		if(com){
			if(root(x)==root(y)){
				cout<<"1"<<endl;
			}else{
				cout<<"0"<<endl;
			}
		}else{
			unite(x,y);
		}
	}
	return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(c >= a && (c-a) <= b){
    puts("YES");
    return 0;
  }
  puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main()
{

	int N, a, b, c, d;
	scanf("%d", &N);
	a = N/1000;
	b = (N - a*1000)/100;
	c = (N - a*1000 - b*100)/10;
	d = N%10;
	if(((a == b)&&(b == c))||((b == c)&&(c == d))||((a == b)&&(b == c)&&(c == d)))

			printf("Yes");
	else
			printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,a[505],b[505],c[505],i,j;
    scanf("%d",&n);
    for(i = 1;i<n;i++)
    {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
    }
    for(i = 1;i<=n;i++)
    {
        int res=0;
        for(j= i;j<n;j++)
        {
            if(res<b[j]) res=b[j];
            else if(res%c[j]) res+=(c[j]-res%c[j]);
            res+=a[j];
        }cout<<res<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1000010;
int n;
int a[N];
char s[N];
inline bool check(int k) {
    for(int i=0;i<n;i++) a[i]=9*(s[i]-'0');
    int m=n,ans=0;
    a[0]+=9*k;
    for(int i=0;i<m;ans+=a[i++]%10)
	if(a[i]>9) {
	    if(i==m-1) a[m++]=0;
	    a[i+1]+=a[i]/10;
	}
    return ans<=k*9;
}
int main() {
    scanf("%s",s);
    n=strlen(s),reverse(s,s+n);
    int l=1,r=n;
    while(l<=r) {
	int mid=(l+r)>>1;
	if(check(mid)) r=mid-1;
	else l=mid+1;
    }
    cout<<l;
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
string s; 
int main() {
	cin>>s;
	if(s[0]=='S'&&s[1]=='U') cout<<7;
	if(s[0]=='M') cout<<6;
	if(s[0]=='T'&&s[1]=='U') cout<<5;
	if(s[0]=='W') cout<<4;
	if(s[0]=='T'&&s[1]=='H') cout<<3;
	if(s[0]=='F') cout<<2;
	if(s[0]=='S'&&s[1]=='A') cout<<1;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>
#include <iomanip>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;

using namespace std;

ll n, m, k;
ll h, w;

ll calc2n(ll x){
    ll ret = 1;
    for(int i=0; i<x; ++i){
        ret *= 2LL;
    }
    return ret;
}

int main(){
    cin >> h >> w >> k;
    vector<string> c(h);
    for(int i=0; i<h; ++i){
        cin >> c[i];
    }
    ll h2n = calc2n(h);
    ll w2n = calc2n(w);
    ll ret = 0;
    for(int ii=0; ii<h2n; ++ii){
        for(int jj=0; jj<w2n; ++jj){
            ll ctr = 0;
            for (int i=0; i<h; ++i){
                if((ii / calc2n(i))%2){
                    continue;
                }
                for (int j=0; j<w; ++j){
                    if((jj / calc2n(j))%2) continue;
                    ctr += (c[i][j]=='#');
                }
            }
            ret += (k == ctr);
        }
    }
    cout << ret << endl;

    return 0;
}

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

bool can_solve(vector<int>& a, vector<int>& b, int c) {
  int sum = c;
  rep(i,a.size()) sum += a.at(i) * b.at(i);
  return sum > 0;
}

int main() {
  int N,M,C; cin >> N >> M >> C;
  vector<int> b(M);
  vector<vector<int>> a(N, vector<int>(M));
  rep(i,M) cin >> b.at(i);
  rep(i,N){
    rep(j,M) cin >> a.at(i).at(j);
  }
  
  int cnt = 0;
  rep(i,N) if(can_solve(a.at(i),b,C)) cnt++;
  
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Active Infants
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 2000;

/* typedef */

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

/* global variables */

pii ps[MAX_N];
ll dp[MAX_N + 1][MAX_N + 1];

/* subroutines */

inline void setmax(ll &a, ll b) { if (a < b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++)
    scanf("%d", &ps[i].first), ps[i].second = i;
  sort(ps, ps + n, greater<pii>());

  for (int i = 0; i < n; i++) {
    int ai = ps[i].first, posi = ps[i].second;
    for (int j0 = 0, j1 = n - i; j1 <= n; j0++, j1++) {
      int l0 = abs(j0 - posi), l1 = abs(j1 - 1 - posi);
      setmax(dp[j0 + 1][j1], dp[j0][j1] + (ll)ai * l0);
      setmax(dp[j0][j1 - 1], dp[j0][j1] + (ll)ai * l1);
    }
  }

  ll maxd = 0;
  for (int i = 0; i <= n; i++) setmax(maxd, dp[i][i]);

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


Measured memory_bytes: 25856
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;s(u,p,i,I){D[u]=1;for(i=F[u];I=B[i];i=T[i])I-p?s(I,u),D[u]=D[u]*-~D[I]%M:0;}S(u,x,p,i,I){for(m(i=F[u],p);I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}m(i,p){i&&m(T[i],p);R[i]=R[T[i]]*(B[i]-p?-~D[B[i]]:1)%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,0);for(S(1,1);i++<n;)printf("%d ",P[i]);}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,x,cnt=0;
    for(int i=0;i<10000;i++){
        cin >> n >> x;
        if(n==0&&x==0){
            break;
        }
        for(int j=1;j<=n;j++){
            for(int k=j+1;k<=n;k++){
                for(int l=k+1;l<=n;l++){
                    if(j==k||k==l||l==j){
                        break;
                    }
                    if(j+k+l==x){
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
        cnt=0;
    }
}


Measured memory_bytes: 3088