akhauriyash/Code-Regression huggingface dataset:
import java.awt.geom.*;
import java.io.*;
import java.util.*;
public class Main {
	//1453 start
	//1509 cording end
	//1517 sample match
	
	int [] vx = {0,1,0,-1,1,-1 };
	int [] vy = {1,0,-1,0,1,-1};
	int n, m;
	ArrayList<ArrayList<Integer>> data ;
	boolean [][] used;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			m = sc.nextInt();
			if((m|n) == 0) break;
			data = new ArrayList<ArrayList<Integer>>();
			for(int i = 0 ; i < n; i++){
				data.add(new ArrayList<Integer>());
				for(int j = 0; j <= i; j++){
					data.get(i).add(sc.nextInt());
				}
			}
			
			int max = -1 * 1 << 24;
			for(int i = 0; i < n; i++){
				for(int j = 0 ; j <= i; j++){
					if(data.get(i).get(j) != 0) continue;
					used = new boolean[n][n];
					data.get(i).set(j, m);
					int sum = -1 * dfs(j,i,m);
					for(int k = 0 ; k < vx.length; k++){
						int xx = j + vx[k];
						int yy = i + vy[k];
						if(! isOK(xx, yy)) continue;
						if(used[yy][xx] ) continue;
						if(data.get(yy).get(xx) == m || data.get(yy).get(xx) == 0) continue;
						sum += dfs(xx,yy, data.get(yy).get(xx));
					}
					max = Math.max(max, sum);
					data.get(i).set(j, 0);
				}
			}
			System.out.println(max);
		}
	}
	private int dfs(int x, int y, int  color) {
		used[y][x] = true;
		int res = 0;
		boolean flg = false;
		for(int i = 0 ; i < vx.length; i++){
			int xx =x + vx[i];
			int yy = y + vy[i];
			if(! isOK(xx, yy)) continue;
			if(used[yy][xx]) continue;
			if(data.get(yy).get(xx) == 0){
				flg = true;
			}
			else if(data.get(yy).get(xx) == color){
				int temp = dfs(xx,yy, color);
				if(temp == 0) flg = true;
				res += temp;
			}
		}
		if(flg) return 0;
		return res + 1;
	}
	private boolean isOK(int xx, int yy) {
		if(0 <= yy && yy < n && 0<= xx && xx < data.get(yy).size()){
			return true;
		}
		return false;
	}
	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int no,p,n,nok,ik;
  int j[31];
  int d[100];
  int ans[100];
  char c;
  for(int i=0;i<30;i++) j[i] = -1; 
  while(cin>>no>>c>>p){
    if(no==0&&p==0) break;
    ans[no] = p;
    d[no-1] = p;
    nok = no;
  }
  sort(d,d+nok,greater<int>());
  n = 0;
  for(int i=1;i<30;i++){
    while(j[i]==-1){
      if(j[i-1]!=d[n]){
	j[i] = d[n];
	n++;
      }
      else n++;
      if(n>nok){
	ik = i;
	break;
      }
    }
    if(n>nok) break;
  }
  while(cin>>no){
    for(int i=1;i<ik;i++){
      if(ans[no]==j[i]){
	cout << i  << endl;
	break;
      }
    }
  }
  return 0;
} 

Measured memory_bytes: 1176
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
def solve():
    min_number = min([A,B,C,D,E])
    if(N%min_number==0):
        return print(5 + int(N/min_number) - 1)
    else:
        return print(5 + int(N/min_number))
solve()

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();
            //[l,r)の範囲で考える
            var l = 0;
            var r = 1;
            var cnt = 0L;
            var xor = Ai[l];
            var sum = Ai[l];
            while (true)
            {
                if (xor == sum)
                {
                    cnt += r - l;
                    if (r == N) break;
                    xor ^= Ai[r];
                    sum += Ai[r];
                    ++r;
                }
                else
                {
                    xor ^= Ai[l];
                    sum -= Ai[l];
                    ++l;
                    if (l == N) break;
                    if (l == r) ++r;
                }
            }
            WriteLine(cnt);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


signed main(){

	int N, M;
	P a[123456];
	cin >> N >> M;

	for (int i = 0; i < N; i++){
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + N, [](P &s, P &t){return s.first <t.first; });

	int ans = 0;
	int cnt = 0;
	int i;
	for (i=0; i < N; i++){
		cerr << a[i].first << " " << a[i].second << endl;
		if (cnt + a[i].second <= M){
			ans += (ll)a[i].second * a[i].first;
			cnt += a[i].second;
		}
		else
			break;
	}
	ans += (M - cnt)*a[i].first;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.NavigableSet;
import java.util.TreeSet;

import static java.lang.Integer.parseInt;

/**
 * Darts
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

//		long ts = System.nanoTime();

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N, M;
			N = parseInt(line.substring(0, line.indexOf(' ')));
			M = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((N | M) == 0) break;

			int[] Pa = new int[N + 1];
			NavigableSet<Integer> Pt = new TreeSet<>();

			for (int i = 1; i <= N; i++) {
				Pa[i] = parseInt(br.readLine());
			}

			for (int i = 0; i < Pa.length; i++) {
				for (int j = 0; j < Pa.length; j++) {
					if (i <= j && Pa[i] + Pa[j] <= M) Pt.add(Pa[i] + Pa[j]);
				}
			}

			int max = 0;
			for (int p : Pt) {
				if (p * 2 > M) break;
				max = Math.max(max, p + Pt.floor(M - p));
			}
			System.out.println(max);
		}
//		System.out.println((System.nanoTime() - ts) / 1000 / 1000);
	}//end main
}

Measured memory_bytes: 175748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size()){
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
import math

r = 0

def format_input(filename = None):
	global r
	if filename == None:
		r = int(input())

	elif filename == '__random__':
		from random import randint as rng
		r = rng(1, 10**2)
		print(r)

def get_answer():
	answer = 2 * r * math.pi
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 9184
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0592 : Average Score **/
int main()
{
	int N=0;
	rep(i, 5) {
		int a; cin>>a;
		N += max(40, a);
	}
	cout << N/5 << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(void)
{
    int a, h, m, s;
    scanf("%d", &a);
    h=a/3600;
    m=(a%3600)/60;
    s=a-(3600*h)-(60*m);
    
    printf("%d:%d:%d\n", h,m,s);
    return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

string query(ll x)
{
	cout<<"? "<<x<<endl;
	string res; cin>>res;
	return res;
}

void answer(ll x)
{
	cout<<"! "<<x<<endl;
}

ll solve()
{
	vl ts={
		1,
		10,
		100,
		1000,
		10000,
		100000,
		1000000,
		10000000,
		100000000,
		1000000000,
		10000000000,
	};

	// 10^x
	if(query(ts[10])=="Y"){
		rep(i,ts.size())
			if(query(ts[i]*10-1)=="Y")
				return ts[i];
	}

	ll lo,hi;
	{
		per(i,ts.size()){
			if(query(ts[i])=="Y"){
				lo=ts[i];
				hi=ts[i+1];
				break;
			}
		}
	}

	//dump(mt(lo,hi));

	while(lo<hi){
		ll mi=(lo+hi)/2;
		if(query(mi*10)=="Y")
			hi=mi;
		else
			lo=mi+1;
	}

	return lo;
}

int main()
{
	ll res=solve();
	answer(res);
}


Measured memory_bytes: 596
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  uint64_t N, t = 0;
  cin >> N;
  vector<uint64_t> A(N);
  map<uint64_t, uint64_t> cnt{};
  for (uint64_t i = 0; i < N; i++) {
    cin >> A.at(i);
    cnt[A[i]]++;
  }

  for (auto &[key, value] : cnt) {
    t += (value * (value - 1)) / 2;
  }

  for (int i = 0; i < N; i++) {
    cout << t - (cnt[A[i]] - 1) << endl;
  }
}


Measured memory_bytes: 12388
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            var stack = new Stack<int>();

            foreach(var elem in input) {
                try {
                    int n = int.Parse(elem);
                    stack.push(n);
                }
                catch (FormatException e) {
                    if(elem == "+") {
                        var val1 = stack.pop();
                        var val2 = stack.pop();
                        stack.push(val1 + val2);
                    }
                    else if(elem == "-") {
                        var val1 = stack.pop();
                        var val2 = stack.pop();
                        stack.push(val2 - val1);
                    }
                    else if(elem == "*") {
                        var val1 = stack.pop();
                        var val2 = stack.pop();
                        stack.push(val1 * val2);
                    }
                    else {
                        Console.WriteLine(e.Message);
                    }
                }
            }
            Console.WriteLine(stack.pop());
        }

    }

    class Stack<T>
    {
        private Element<T> top;

        public void push(T data)
        {
            this.top = new Element<T>(this.top, data);
        }

        public T pop()
        {
            var result =  this.top.data;
            this.top = this.top.next;
            return result;
        }

        private class Element<Tdata>
        {
            public Element<Tdata> next;
            public Tdata data;
            public Element(Element<Tdata> next, Tdata data)
            {
                this.next = next;
                this.data = data;
            }
        }
    }
}



Measured memory_bytes: 19984
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		scan.close();
		int ans=k;
		for(int i=1;i<n;i++) {
			ans*=(k-1);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q; string S; cin >> N >> Q >> S;
    vector<char> t(Q),d(Q);
    rep(i,Q) cin >> t[i] >> d[i];
    int lb=-1,ub=N,ans=0;
    while(ub-lb>1){
        int mid=(ub+lb)>>1,now=mid;
        bool ok=false;
        rep(i,Q){
            if (S[now]==t[i]){
                if (d[i]=='L') --now;
                else ++now;
            }
            if (now==-1){ok=true; break;}
            if (now==N) break;
        }
        (ok?lb:ub)=mid;
    }
    ans+=ub;
    lb=-1,ub=N;
    while(ub-lb>1){
        int mid=(ub+lb)>>1,now=N-1-mid;
        bool ok=false;
        rep(i,Q){
            if (S[now]==t[i]){
                if (d[i]=='L') --now;
                else ++now;
            }
            if (now==N){ok=true; break;}
            if (now==-1) break;
        }
        (ok?lb:ub)=mid;
    }
    ans+=ub;
    cout << N-ans << endl;
}

Measured memory_bytes: 976
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;

int main (void)
{
	string str,E,ttt,kkk,lll,p,O;
	long q,a,b;

	cin >> str >> q;

	for (long s = 0; s < q; s++)
	{
		cin >> E >> a >> b;
		if (E == "print")
		{
			cout << str.substr(a,b - a + 1) << endl;
		}


		else if (E == "reverse")
		{
			/*ttt = str.substr(a,b - a + 1);
			kkk = str.substr(0,a);
			lll = str.substr(b - a + 1,str.size() - b - 1);

			reverse(ttt.begin(),ttt.end());
			str = kkk + ttt + lll;*/
			reverse(str.begin()+a,str.begin()+b+1);
		}


		else if (E == "replace")
		{cin >> p;
        str.replace(a,p.length(),p);


			/*cin >> p;

			O = p;
			kkk = str.substr(0,a);
			lll = str.substr(b - a + 1,str.size() - b - 1);

			str = kkk + O + lll;*/
		}

	}
}

Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;

int n, w, h;

int ru(int x, int y) {
	pii p1(x+h-y, h);
	pii p2(w, y+w-x);
	if(abs(p1.fi-x)+abs(p1.se-y) < abs(p2.fi-x)+abs(p2.se-y)) {
		return h+p1.fi;
	} else {
		return h*2 + w - p2.se;
	}
}

int rd(int x, int y) {
	pii p1(w, y-(w-x));
	pii p2(x+y, 0);
	if(abs(p1.fi-x)+abs(p1.se-y) < abs(p2.fi-x)+abs(p2.se-y)) {
		return w+h*2-p1.se;
	} else {
		return w*2 + h*2 - p2.fi;
	}
}

int lu(int x, int y) {
	pii p1(0, y+x);
	pii p2(x-(h-y), h);
	if(abs(p1.fi-x)+abs(p1.se-y) < abs(p2.fi-x)+abs(p2.se-y)) {
		return p1.se;
	} else {
		return h + p2.fi;
	}
}

int ld(int x, int y) {
	pii p1(0, y-x);
	pii p2(x-y, 0);
	if(abs(p1.fi-x)+abs(p1.se-y) < abs(p2.fi-x)+abs(p2.se-y)) {
		return p1.se;
	} else {
		return w*2 + h*2 - p2.fi;
	}
}

bool sortBySecond(const pii& lhs, const pii& rhs) {
	if( lhs.se == rhs.se ) {
		return lhs.fi < rhs.fi;
	}
	return lhs.se < rhs.se;
}

int main() {
	cin >> n >> w >> h;
	vector<pii> vp;
	rep(i, n) {
		int x, y;
		char f;
		cin >> x >> y >> f;
		if(f=='E') vp.push_back( pii(ru(x,y), rd(x,y)) );
		if(f=='W') vp.push_back( pii(ld(x,y), lu(x,y)) );
		if(f=='N') vp.push_back( pii(lu(x,y), ru(x,y)) );
		if(f=='S') vp.push_back( pii(rd(x,y), ld(x,y)) );
		if(vp[i].fi > vp[i].se) {
			vp[i].se += w*2 + h*2;
		}
	}

	int res = 10000000;
	for(int s=0; s<n; s++) {
		sort(vp.begin(), vp.end(), sortBySecond);
		int cnt = 1;
		int pos = vp[0].se;
		for(int i=1; i<n; i++) {
			if(vp[i].fi <= pos && pos <= vp[i].se) {
			} else {
				cnt++;
				pos = vp[i].se;
			}
		}
		res = min(res, cnt);
		vp[0].fi += w*2 + h*2;
		vp[0].se += w*2 + h*2;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1220
import sys
input = lambda: sys.stdin.readline().rstrip()
n, a, b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))

def solve(e):
    cnt = 0
    for i in h:
        if i<=b*e:
            continue
        cnt += (i-b*e+a-b-1)//(a-b)
    return cnt<=e

ok = 10**9
ng = 0
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 71800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String buff="";
		int buff2,res=0;

		for(int i=0;i<=s.length()-3;i++) {
			buff=s.substring(i, i+3);
			buff2=Integer.parseInt(buff);
			//System.out.println(res);
			if(Math.abs(res-753)>Math.abs(buff2-753)) {
				res=buff2;
			}
		}

		System.out.println(Math.abs(res-753));
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    bool x;
    cin >>x;
    
    cout << (x^1) << endl;


    return 0;
    

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n);
  rep(i,n)cin >> a[i];
  sort(rng(a));
  reverse(rng(a));
  ll ans = 0;
  int j = 0;
  int cnt = 1;
  srep(i,1,n){
    ans+=a[j];
    cnt--;
    if(cnt == 0){
      cnt = 2;
      j++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4792
using System;

namespace exawizards2019A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            if (A == B && B == C)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

using namespace std;

#define int long long
#define ll long long
#define double long double
#define f first
#define s second
#define all(el) el.begin(), el.end()
#define allr(el) el.rbegin(), el.rend()
//#define x first
//#define y second
#define pb push_back
#define in insert
#define mp make_pair
#define sz(el) (int)el.size()
#define endl "\n"

int n, m;
vector<int> used, p;
vector<vector<int>> g;

void bfs(int st) {
    queue<int> q;
    q.push(st);
    used.resize(n);
    used[st] = 1;
    p.resize(n, -1);
    p[st] = st;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int &to : g[v]) {
            if (!used[to]) {
                used[to] = 1;
                q.push(to);
                p[to] = v;
            }
        }
    }
}

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[b].pb(a);
        g[a].pb(b);
    }
    bfs(0);
    for (int i = 0; i < n; i++) {
        if (p[i] == -1) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    for (int i = 1; i < n; i++) {
        cout << p[i] + 1 << endl;
    }
    return 0;
    
}


Measured memory_bytes: 13732
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
AS=[]
BS=[]
for i in range(N):
    A,B=LI()
    AS.append(A)
    BS.append(B)
AS.sort()
BS.sort()
if N % 2:
    print(BS[N//2]-AS[N//2]+1)
else:
    print((BS[N//2]+BS[N//2-1]-(AS[N//2]+AS[N//2-1]))+1)


Measured memory_bytes: 97492
#include <cstdio> 
using namespace std; //This makes the code much more cleaner

int main()
{
	
/*
	int a, b, c, d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int area = a*b;
	int areatwo = c*d;
		if (area>=areatwo)
		{
			printf("%d", area);
		}
		else
		{
			printf("%d",areatwo);
		}
		*/
	//--------------------------------------------

	/*
	int a,b;
	scanf("%d %d", &a, &b);
	if (a==1 and b!=1)
	{

		printf("Alice");

	}
	else if (b == 1 and a!=1)
	{

		printf("Bob");

	}
	else if (a>b)
	{

		printf("Alice");

	}
	else if (a == b)
	{

		printf("Draw");
	}
	else
	{

		printf("Bob");
	}

	*/


	//----------------------------------------------- IN CASE YOU WANT TO FIND THE LAST DIGIT OF A NUMBER, OR A MIDDLE DIGIT OF A NUMBER:

	/*
	
	x= 413

	then do x%10

	if you want to get the digit of 10,

	then do x/10 %10
	
	*/



	//--------------------------------------------------- LEAP YEAR PROBLEM SOLUTIONS

	/*
	int x;
	scanf("%d",&x);
	if (x%4!=0)
	{
		printf("no");

	}
	else
	{
		if (x % 100 != 0)
		{

			printf("yes");
		}
		else
		{
			if (x%400==0)
			{

				printf("yes");
			}
			else
			{
				printf("no");
			}
		
		}

	}
	

int x;
scanf("%d", &x);

	if ( (x%4==0 and x%100!=0) or(x%400==0) )
	{
		printf("yes");
	}
	else
	{
		printf("no");
	}

	*/


//--------------------------------------------------------------


int a,b;
scanf("%d %d",&a,&b);
printf("%d",(a-1)*(b-1));









	return 0;

}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) erase(x.begin(), x.begin+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;

vector<vector<int> > graph(100000);

// first is the layer number, second is the number that go out from the vertex
vector<P> vertex(100000);

// struct _chunk {
// 	int connect;
// 	int dist;
// 	int color;
// };

void dfs(int now, int layer) {
	vertex[now].first = layer;

	for(int i=0; i<graph[now].size(); i++) {
		int next = graph[now][i];
		if (vertex[next].first == 0) {
			// if it is the first time to visit next vertex
			dfs(next, layer+1);
			if (vertex[next].second%2 == 0) {
				vertex[now].second += 1;
				cout << now+1 << " " << next+1 << endl;
			} else {
				vertex[next].second += 1;
				cout << next+1 << " " << now+1 << endl;
			}
		} else {
			// if the next layer is smaller than now's, decide the direction in any way
			if(vertex[next].first > vertex[now].first) {
				vertex[now].second += 1;
				cout << now+1 << " " << next+1 << endl;
			}
		}
	}
}

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

  	rep(i, M) {
  		int a, b;
  		cin >> a >> b;
  		a--; b--;
  		graph[a].pb(b);
  		graph[b].pb(a);
  		vertex[i] = make_pair(0, 0);
  	}

  	if (M%2 == 0) {
  		dfs(0, 1);
  	} else {
  		cout << -1 << endl;
  	}
 	
	return 0;
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

string s;

int main(int argc, char const *argv[])
{

	cin>>s;

	char color = s[0];
	
	int ans1 = 0, ans2 = 0;

	for (int i = 1; i < s.size(); ++i)
	{
		if (s[i] != color)
		{
			color = s[i], ans1++;
		}
	}
	
	reverse(all(s));

	color = s[0];

	for (int i = 1; i < s.size(); ++i)
	{
		if (s[i] != color)
		{
			color = s[i], ans2++;
		}
	}	
	cout<<min(ans1,ans2);
}	

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
for i in range(a[0], a[n-1]+1) :
	ans = 0
	for j in range(len(a)) :
		ans = ans + (a[j]-i)**2
	b.append(ans)
print(min(b)) 



Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
    int N;
    int t, x, y;
    cin >> N;
    for(int i=0; i<N ; i++){
        cin >> t >> x >> y;
        if( (t-x-y)>=0 && (t-x-y)%2==0){
        }
        else{
            cout << "No" << endl;
            break;
        }
        if( i == (N-1)){
            cout << "Yes" << endl;
        }

    }

   
    return 0;
}


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

#define ll long long
#define pii pair<int, int>
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<float> V(N);
    REP(i, N) cin >> V.at(i);
    sort(all(V));
    float ans = 0;
    REP(i, N-1) {
        V.at(i+1) = (V.at(i) + V.at(i+1)) / 2;
    }
    print(V.at(N-1));
}

signed main() {
    solve();
}


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

using namespace std;

typedef long long ll;

const ll INF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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 Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    ll N,M,ans=0,sum=0;
    cin>>N>>M;
    vector<pair<ll,ll> > AB(N);
    rep(i,N){
        ll a,b;
        cin>>a>>b;
        AB[i]=make_pair(a,b);
    }
    sort(AB.begin(),AB.end());
    for(ll i=0;i<N;i++){
        ll key=AB[i].first,value=AB[i].second;
        if(M>sum+value)ans+=key*value,sum+=value;
        else{
            ll a=M-sum;
            ans+=a*key;
            sum+=a;
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)

{
  int a , b , c , d , e , f , g , h , i , j , k , l , m;
  scanf("%d %d %d\n%d %d %d\n%d %d %d\n",&a,&b,&c,&d,&e,&f,&g,&h,&i);
  
  j = b - a;
  k = d - a;
  l = c - b;
  m = g - d;
  if (j==e-d && j==h-g && k==e-b && k==f-c && l==f-e && l==i-h && m==h-e && m==i-f) 
  {
  	printf("Yes");
  }  else {
  	printf("No");
  	}

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 10;
int n, m, k;
int a[maxn][maxn], mp[maxn][maxn];
int ans, tot;
int vis1[maxn], vis2[maxn];

void dfs2(int layer) {
	if (layer == m + 1) {
		for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) mp[i][j] = a[i][j];
		int tmp = tot;
		for (int i = 1; i <= n; i++) {
			if (vis1[i]) {
				for (int j = 1; j <= m; j++) {
					if (mp[i][j] > 0) {
						mp[i][j] = 0;
						tmp--;
					}
				}
			}
		}
		for (int j = 1; j <= m; j++) {
			if (vis2[j]) {
				for (int i = 1; i <= n; i++) {
					if (mp[i][j] > 0) {
						mp[i][j] = 0;
						tmp--;
					}
				}
			}
		}
		if (tmp == k) ans++;
		return ;
	}
	vis2[layer] = 1;
	dfs2(layer + 1);
	vis2[layer] = 0;
	dfs2(layer + 1);
}

void dfs1(int layer) {
	if (layer == n + 1) {
		dfs2(1);
		return ;
	}
	vis1[layer] = 1;
	dfs1(layer + 1);
	vis1[layer] = 0;
	dfs1(layer + 1);
}

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		char s[10]; scanf("%s", s + 1);
		for (int j = 1; j <= m; j++) {
			if (s[j] == '#') a[i][j] = 1, tot++;
		}
	}
	dfs1(1);
	printf("%d\n", ans);
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A,B,K; cin >>A>>B>>K;

    int n;
    for (n = A; n < A + K && n <= B; n++) {
        cout << n << endl;
    }
    for (n = max(n, B - K + 1); n <= B; n++) {
        cout << n << endl;
    }
}


Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,a1,a2,a4,ai;

int main(){
    I(n);
    REP(i,n){
        I(ai);
        if (ai&1) { a1++; }
        else if ((ai/2)&1) { a2++; }
        else { a4++; }
    }
    if (a2 && a4 >= a1 || !a2 && a4 >= a1-1 ){
        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 in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int m = in.nextInt();
			int p = in.nextInt();
			int xm = 0;
			if(n == 0) break;
			int sum = 0;
			for(int i=0; i<n; i++){
				int x = in.nextInt();
				sum += x;
				if(i+1==m) xm = x;
			}
			int res = xm==0?0:(sum*(100-p))/xm;
			System.out.println((int)res);
		}
	}
}

Measured memory_bytes: 27720
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

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

        int area = a * b;
        int circle = 2 * (a + b);

        System.out.print(area + " ");
        System.out.println(circle);

        
    }
} 


Measured memory_bytes: 25960
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    std::string S, T;
    std::cin >> S >> T;

    std::set<std::string> cands;

    for (size_t i = 0; i < S.size() - T.size() + 1; ++i) {
        bool match = true;
        for (size_t j = 0; j < T.size(); ++j) {
            if (S[i+j] != '?' && S[i+j] != T[j]) {
                match = false;
                break;
            }
        }
        if (match) {
            auto cand = S.substr(0, i) + T + S.substr(i+T.size(), S.size() - (i+T.size()));
            boost::algorithm::replace_all(cand, "?", "a");
            cands.insert(cand);
        }
    }

    if (cands.empty()) {
        std::cout << "UNRESTORABLE" << std::endl;
    }
    else {
        std::cout << *cands.begin() << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

int N, x, A[6000], mina[6000];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N >> x;

    REP(i, N) {
        cin >> A[i];
        mina[i] = INF;
    }
    REP(i, N) { A[i + N] = A[i]; }

    int ans = INF;
    REP(k, N) {
        int tmp = k * x;
        REP(i, N) {
            int t = i + N;
            mina[i] = min(mina[i], A[t - k]);
            tmp += mina[i];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],L[2<<17],R[2<<17]={1};
dfs1(u,p,id)
{
	dp1[u]=1;
	id=first[u];
	while(id)
	{
		if(eb[id]!=p)
		{
			dfs1(eb[id],u);
			dp1[u]=dp1[u]*-~dp1[eb[id]]%M;
		}
		id=next[id];
	}
}
make();
dfs2(u,p,x,id)
{
	dp2[u]=dp1[u]*x%M;
	make(first[u],p,x);
	id=first[u];
	while(id)
	{
		if(eb[id]!=p)
		{
			dfs2(eb[id],u,L[id]*R[next[id]]%M+1);
		}
		id=next[id];
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]!=p?-~dp1[eb[i]]:1;
		make(next[i],p,t%M*x%M);
		R[i]=R[next[i]]*t%M;
	}
}
main(u,v)
{
	scanf("%d%d",&n,&M);
	for(i=0;~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}
	for(i=1;i<2*n-1;i++)
	{
		next[i]=first[ea[i]];
		first[ea[i]]=i;
	}
	dfs1(1,0);
	dfs2(1,0,1);
	for(i=1;i<=n;i++)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 13056
#include <iostream>
using namespace std;
int main(){
    // Your code here!
    char c; 
     
     
    cin >> c;
    if (c == 'a'){
        cout << "vowel" << endl;
    }
    else if (c == 'i'){
        cout << "vowel" << endl;
    }       
    else if (c == 'u'){
        cout << "vowel" << endl;
    }
    else if (c == 'e'){
        cout << "vowel" << endl;
    }
    else if (c == 'o'){
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 3564
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    string s;cin>>s;
    if(s[SZ(s)-1]=='s'){
        cout<<s<<"es"<<endl;
    }else{
        cout<<s<<"s"<<endl;
    }
    return 0;
}

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

int main(){
    int sum=0;
    int a=0;
    for(int i=0;i<=2;i++){ cin>>a; sum+=a;}
    if(sum>=22) cout<<"bust"<<"\n";
    else cout<<"win"<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n;
ll a[3*100000+10];
int main(){
        while(scanf("%d",&n) != EOF){
                for(int i = 1;i <= 3*n;++i) scanf("%lld",&a[i]);
                int k = 3*n-1;
                int s = 0;
                ll ans = 0;
                sort(a+1,a+1+3*n);
               // for(int i = 1;i <= 3*n;++i) printf("%lld ",a[i]);
                for(int s = 0;s < n;++s){
                        ans += a[k];
                        k -= 2;
                }
                printf("%lld\n",ans);
        }
        return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
    int N;cin>>N;
    vector<vector<P>> tree(N,vector<P>());
    rep(i,N-1) {
        int u,v,w;cin>>u>>v>>w;
        u--;v--;
        w = w % 2;
        tree[u].push_back(P(v,w));
        tree[v].push_back(P(u,w));
    }
    vector<int> color(N,-1);
    color[0] = 0;
    queue<int> qu;
    qu.push(0);
    while(!qu.empty()) {
        int now = qu.front();
        qu.pop();
        for(auto nxt : tree[now]) {
            if(color[nxt.first]==-1) {
                if(nxt.second){
                    color[nxt.first] = 1 - color[now];
                } else {
                    color[nxt.first] = color[now];
                }
                qu.push(nxt.first);
            }
        }
    }
    rep(i,N) cout<<color[i]<<endl; 
}

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

using i64 = long long;

const int N = 1e5 + 5;

int have[N];
bool may[N];

int n, m, ant;

int main() {
#ifdef HOME
	freopen("agc2b.in", "r", stdin);
	freopen("agc2b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int x, y;

	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		have[i]+= 1;
	may[1] = true;

	for (int i = 1; i <= m; ++i) {
		cin >> x >> y;
		may[y]|= may[x];
		++have[y];
		if (!(--have[x]))
			may[x] = false; }

	for (int i = 1; i <= n; ++i)
		ant+= int(may[i]);
	cout << ant << endl;

	return 0; }


Measured memory_bytes: 768
import sys
f=1;k=0
N=int(input())
s=list(input())
t=list(input())
for i in range(N):
  for j in range(i,N):
    #print(s[j],t[k],i,j,k,f)
    if s[j]==t[k]:
      f=f*1
    else:
      f=f*0
    k=k+1
  if f!=0:
    print(N+i)
    sys.exit()
  f=1
  k=0
print(N*2)

Measured memory_bytes: 3064
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s | x < 10    = show x
        | otherwise = "error"
 where
  [a, b] = fmap read (words s) :: [Int]
  x      = a + b

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

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

struct food{
	int p,q,r,id;
	food(int p_, int q_, int r_, int id_ ){
		p = p_; q = q_; r = r_;	id = id_;
	}
	food(){
		p = q = r = id = 0;
	}
	int cal(){ return p * 4 + q * 9 + r * 4; }
};

int main(){
	int n;
	while( cin >> n, n ){
		vector<food> v;
		for(int i=0 ; i < n ; i++ ){
			int id, p, q, r;
			cin >> id >> p >> q >> r;
			v.push_back( food(p,q,r,id) );
		}
		int P, Q, R, C;
		cin >> P >> Q >> R >> C;
		bool flag = false;
		for(int i=0 ; i < v.size() ; i++ ){
			if( v[i].p <= P && v[i].q <= Q && v[i].r <= R && v[i].cal() <= C ){
				flag = true;
				cout << v[i].id << endl;
			}
		}
		if( !flag ){
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 940