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

public class Main {

    public static int coinChange(int[] coins, int amount) {
        if (coins == null || coins.length == 0) {
            return 0;
        }
        int[] dp = new int[amount + 1];

        for (int i = 1; i < dp.length; i++) {
            dp[i] = -1;
        }

        for (int coinsNum = 1; coinsNum <= coins.length; coinsNum++) {
            for (int amountN = 1; amountN <= amount; amountN++) {
                if ((amountN - coins[coinsNum - 1] >= 0) && dp[amountN - coins[coinsNum - 1]] != -1) {
                    int prevTotal = dp[amountN - coins[coinsNum - 1]];
                    if (dp[amountN] == -1) {
                        dp[amountN] = prevTotal + 1;
                    } else {
                        dp[amountN] = Math.min(dp[amountN], prevTotal + 1);
                    }
                }
            }
        }
        return dp[amount];
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int amount = scanner.nextInt();
        int n = scanner.nextInt();
        int[] coins = new int[n];
        for (int i = 0; i < n; i++) {
            coins[i] = scanner.nextInt();
        }
        System.out.println(coinChange(coins, amount));
    }
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int calc(int a,int b){
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}

	int r = a % b;
	while (r!=0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int c = a[0];
	for (int i = 1; i < n; i++) {
		c = calc(c,a[i]);
	}
	cout << c << endl;
	return 0;

}


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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 

#define mod 1000000007
#define pb push_back
#define S second
#define F first
#define INF 1e18
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n" \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)
const int N = 2001;
int dp[N];

int go(int num) {
  if(num == 0)
    return 1;
  if(num < 0)
    return 0;
  
  if(dp[num] != -1)
    return dp[num];
 
  int ans = 0;
  for(int i = 3; i <= num; ++i)
    ans = (ans % mod + go(num - i) % mod) % mod;
  
  return dp[num] = ans;
}

int32_t main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  memset(dp,-1,sizeof dp);
  cin >> n;
  cout << go(n);
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

ll n,a[100001],m,x,i,b[100001];

int main()
{
	string s;
	cin>>s;
	ll n=s.length();
	string h=s.substr(0,(n-1)/2);
	string f=s.substr((n+3)/2-1);
	string a=s,b=h,c=f;
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	reverse(c.begin(),c.end());
	if(a==s && b==h && c==f)
		cout<<"Yes\n";
	else
		cout<<"No\n";
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int max=0, min=10000000, sum=0, ave=0;
            int n = sc.nextInt();
            if(n==0)break;
            int[] s = new int[n];
            for(int i=0;i<n;i++){
                s[i] = sc.nextInt();
                if(max<s[i]) max=s[i];
                if(min>s[i]) min=s[i];
                sum += s[i];
            }
            ave = (sum-max-min)/(n-2);
            System.out.println(ave);
        }
    }
}


Measured memory_bytes: 28212
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
	string x;
	cin >> x;

	int min = INT32_MAX;
	for (int i = 0; i < x.size() - 2; i++)
	{
		int sub = abs(stoi(x.substr(i, 3)) - 753);
		if (sub < min)
			min = sub;
	}
	cout << min;
	return 0;
}

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

int main(void)
{
    int a1,b1,c1,k,a,b,c;

    cin >> a1 >> b1 >> c1;
    cin >> k;

    string ans = "No";
    for(int x = 0; x <= k; ++x){
        for(int y = 0; y+x <= k; ++y){
            a=a1;b=b1;c=c1;
            for(int i=0; i<x; ++i) a *= 2;
            for(int i=0; i<y; ++i) b *= 2;
            for(int i=0; i<k-x-y; ++i) c *= 2;
            if(b > a && c > b) ans = "Yes";
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scan(&N)

	S:= make([]string, N)

	result := make(map[string]int)

	for i:=0;i<N;i++{

		fmt.Scan(&S[i])
	}


	for i:=0;i<N;i++{

		val,ok := result[S[i]]

		if ok==true{

			result[S[i]] = val +1
		}else{

			result[S[i]] = 1
		}
	}


	fmt.Println(len(result))


}

Measured memory_bytes: 27040
n = STDIN.gets.chomp.to_i

n.times do 
  x1, y1, x2, y2, x3, y3 = STDIN.gets.chomp.split(" ").map { |item| item.to_f }
  a1 = 2*(x2-x1)
  a2 = 2*(x3-x1)
  b1 = 2*(y2-y1)
  b2 = 2*(y3-y1)
  c1 = x1*x1-x2*x2+y1*y1-y2*y2
  c2 = x1*x1-x3*x3+y1*y1-y3*y3
  xp = (b1*c2-b2*c1)/(a1*b2-a2*b1)
  yp = (c1*a2-c2*a1)/(a1*b2-a2*b1)
  r  = Math.sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1))
  puts "#{sprintf "%.3f", xp} #{sprintf "%.3f", yp} #{sprintf "%.3f", r}"
end

Measured memory_bytes: 8732
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <stack>
#include <set>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int n,k,a[N];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
 	cin>>n>>k;
 	for(int i=1;i<=n;i++) cin>>a[i];
 	for(int i=k+1;i<=n;i++){
 		if(a[i]>a[i-k]) cout<<"Yes\n";
 		else cout<<"No\n";
 	}
	return 0;
}

Measured memory_bytes: 4440
n = raw_input().split(' ')

n1 = int(n[0]) + int(n[1])
n2 = int(n[1]) + int(n[2])
n3 = int(n[2]) + int(n[0])

if n1 <= n2:
  if n1 < n3:
    print(n1)
  else :
    print(n3)
elif n2 <= n3:
  print(n2)
else:
  print(n3)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

    ll x;
    cin >> x;

    rep(a,201){
        rep(b,201){
            if(pow(a,5) - pow(b,5) == x){
                cout << a << " " << b << endl;
                return 0;
            }
            if(pow(a,5) + pow(b,5) == x){
                cout << a << " " << -b << endl;
                return 0;
            }
        }
    }
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 4064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	static class Task {
        public void solve(InputReader in, PrintWriter out) {
        	int s = in.nextInt();
        	
        	HashSet<Integer> set = new HashSet<Integer>();
        	
        	int next = s;
        	int i=1;
        	do {
        		set.add(next);
        		if(next%2==1)
        			next = next*3+1;
        		else
        			next = next/2;
        		i++;
        	}
        	while(!set.contains(next));
        	out.println(i);
        }
    }
	
    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

	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());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
    }	
}

Measured memory_bytes: 23508
A, B, H, M = map(int,input().split())

theta_M = M*6
theta_H = H*30 + M*0.5

theta = abs(theta_M - theta_H)
if theta > 180:
  theta = 360 - theta
  
import math
x = A**2 + B**2 - 2 * A * B * math.cos(math.radians(theta))
x = math.sqrt(x)
print(x)

Measured memory_bytes: 9428
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <ll,ll> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007

ll num(ll n)
{
    return log10(n)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    a[0]--;
    for(ll i=1;i<n;i++)
    {
        if(a[i]>a[i-1])
            a[i]--;
    }
    for(ll i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int r(long long x){
    long long ok = 0, ng = 1e9;
    while(ok + 1 < ng){
        long long m = (ok + ng)/2;
        if(m*m <= x) ok = m;
        else ng = m;
    }
    if(ok*ok != x) return -1;
    return ok;
}
int main(void){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        long long ans = 0;
        for(int x = 1; x*x <= i; x++){
            for(int y = 1; ; y++){
                int c = x*x+y*y+x*y - i;
                if(c >= 0) break;
                int d = r((x+y)*(x+y)-c*4);
                if(d==-1) continue;
                if((d-x-y)%2 == 0) ans++;
            }
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
long long dp[100002];
int main()
{
    int n,cap;
    cin>>n>>cap;
    for(int i=0; i<n; i++)
    {
        int w,v;
        cin>>w>>v;
        for(int j=cap; j>=w; j--)
        {
            dp[j]=max(dp[j],v+dp[j-w]);
        }
    }
    cout<<dp[cap]<<endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  
  rep (i, 0, s.size()/2) {
    if (s.at(i) != s.at(s.size() - 1 -i))
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import math

N, A, B = map(int, input().split())

h = []
min_h = 10 ** 10
max_h = 0
for _ in range(N):
    hi = int(input())
    if hi < min_h:
        min_h = hi
    if hi > max_h:
        max_h = hi
    h.append(hi)
    
min_K = math.ceil(min_h / A)
max_K = math.ceil(max_h / B)
K = min_K
while(min_K != max_K):
    sum_x = 0
    for i, n in enumerate(h):
        x = math.ceil((n - K * B) / (A - B))
        if x > 0:
            sum_x += x
    #x = [math.ceil((n - K * B) / (A - B)) for n in h]
    #sum_x = sum([xi for xi in x if xi > 0])
    if sum_x <= K:
        max_K = K
        K = math.floor((min_K + K) / 2)
    else:
        min_K = K + 1
        K = math.floor((K + max_K) / 2) + 1

print(K)

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

using namespace std;
const int N = 110;
int _w;

int n, m, f[N][N];
char s[N][N];

int main() {
	cin >> n >> m;
	for( int i = 1; i <= n; ++i )
		cin >> (s[i] + 1);
	memset(f, 0x3f, sizeof f);
	if( s[1][1] == '#' ) {
		f[1][1] = 1;
	} else {
		f[1][1] = 0;
	}
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j ) {
			if( i != n ) {
				int w = (s[i][j] == s[i+1][j] || s[i+1][j] == '.') ? 0 : 1;
				f[i+1][j] = min( f[i+1][j], f[i][j] + w );
			}
			if( j != m ) {
				int w = (s[i][j] == s[i][j+1] || s[i][j+1] == '.') ? 0 : 1;
				f[i][j+1] = min( f[i][j+1], f[i][j] + w );
			}
		}
	cout << f[n][m] << endl;
	return 0;
}


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

int main() {
	int k;
	string s;
	cin >> k >> s;
	
	for(int i = 0; i < s.length(); i++){
		cout << char ((s[i] - 'A' + k) % 26 + 'A'); 
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	int se[n],sw[n];
	for(int i=0;i<=n-1;i++){
		se[i]=0;
		sw[i]=0;
	}
	cin>>a;
	if(a[0]=='E')
		se[0]=1;
	else
		sw[0]=1;
	for(int i=1;i<=n-1;i++)
		if(a[i]=='E'){
			se[i]=se[i-1]+1;
			sw[i]=sw[i-1];
		}
		else{
			sw[i]=sw[i-1]+1;
			se[i]=se[i-1];
		}
	int minv=30000001;
	for(int i=0;i<n;i++){
		int sum=0;
		if(i==0)
			sum=se[n-1]-se[0];
		else if(i==n-1)
			sum=sw[n-2];
		else
			sum=sw[i-1]+(se[n-1]-se[i]);
		minv=min(minv,sum);
	}
	cout<<minv<<endl;
	return 0;
}

Measured memory_bytes: 3204
n=int(input())
t=n
ar=[]
while(t>0):
    ar.append(t)
    if t%2==0:
        t=t//2
    else:
        t-=1
class Graph():
    def __init__(self):
        self.vertices=set()
        self.edges=[]
    def addedge(self,a,b,w):
        self.edges.append([a,b,w])
        self.vertices.add(a)
        self.vertices.add(b)
g=Graph()
g.addedge(0,1,0)
g.addedge(0,1,1)
for i in range(3,len(ar)+1):
    if ar[-i]==ar[-i+1]+1:
        g.addedge(0,len(g.vertices)-1,ar[-i]-1)
    else:
        for j in g.edges:
            j[2]*=2
        g.addedge(len(g.vertices)-1,len(g.vertices),0)
        g.addedge(len(g.vertices)-2,len(g.vertices)-1,1)


print(len(g.vertices),len(g.edges))

for i in g.edges:
    print(i[0]+1,i[1]+1,i[2])





Measured memory_bytes: 62472
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ull i=0;i<(ull)n;++i)
const ull INF = 999999999999999;

int main(){
  ll k;
  cin >> k;
  string s;
  cin >> s;
  if( s.size() <= k ){
    cout << s << endl;
  }else{
    cout << s.substr(0,k) << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
N = int(input())
A = [[0,0,0]]
for _ in range(N):
    A += [list(map(int,input().split()))]


def is_even(num):
    if num %2 ==0:
        return 0
    else:
        return 1

a = 0
for i in range(N):
    start = A[i][1]+A[i][2]
    goal = A[i+1][1]+A[i+1][2]
    if is_even(A[i+1][0] - A[i][0]) == is_even(start - goal):
        if abs(A[i][1]-A[i+1][1])+abs(A[i][2]-A[i+1][2]) <= (A[i+1][0] - A[i][0]):
            a += 1
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 27380
n = int(input())
tl = []
dl = []
flag = 0

for i in range(n):
    t, x, y = (int(x) for x in input().split())
    tl.append(t)
    dl.append((x, y))

for num in range(n):
    if num == 0:
        if tl[num] >= sum(dl[num]) and tl[num] % 2 == sum(dl[num]) % 2:
            pass
        else:
            flag = 1
    else:
        ntl = tl[num]-tl[num-1]
        ndl = sum((abs(dl[num][0] - dl[num - 1][0]), abs(dl[num][1] - dl[num - 1][1])))
        if ntl >= ndl and ntl%2 == ndl%2:
            pass
        else:
            flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 23000
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
using namespace std;
int s[100001],n;
bool bin(int v)
{
	int left=0,right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(s[mid]==v){
			return true;
		}
		else if(s[mid]<v){
			 left=mid+1;
		}
		else{
			right=mid;
		}
	}
	return false;
}
int main(int argc, char *argv[]) {
	int t,q,i,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&t);
		if(bin(t)) sum++;
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,col[600][600], oc[4];
bool done[600][600];
int cmul;

void dfs(int a, int b, int c, pi z) {
    if (a < 0 || a >= 600 || b < 0 || b >= 600) return;
    if (done[a][b]) return;
    done[a][b] = 1;
    col[a][b] ^= c;
    
    for (int i = -1; i <= 1; i += 2)
        for (int j = -1; j <= 1; j += 2)
            dfs(a+i*z.f,b+j*z.s,c^cmul,z);
    for (int i = -1; i <= 1; i += 2)
        for (int j = -1; j <= 1; j += 2)
            dfs(a+i*z.s,b+j*z.f,c^cmul,z);
}

void color(int x, int d) {
    cmul = x;
    F0R(i,600) F0R(j,600) done[i][j] = 0;
    pi z = {1,0};
    while (d % 2 == 0) {
        if (z.f > z.s) z.s = z.f;
        else z.f *= 2, z.s = 0;
        d /= 2;
    }
    // cout << d << " " << z.f << " " << z.s << "\n";
    F0R(i,600) F0R(j,600) if (!done[i][j]) {
        // cout << i << " " << j << "\n";
        dfs(i,j,0,z);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    int D; cin >> D;
    color(1,D);
    cin >> D;
    color(2,D);
    F0R(i,2*N) F0R(j,2*N) oc[col[i][j]] ++;
    int bes = 0;
    FOR(i,1,4) if (oc[i] > oc[bes]) bes = i;
    
    vpi v;
    F0R(i,2*N) F0R(j,2*N) if (col[i][j] == bes) {
        v.pb({i,j});
    }
    F0R(i,N*N) cout << v[i].f << " " << v[i].s << "\n";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 43632
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

A,B,Q=rl()
s=[0]*(A+2)
t=[0]*(B+2)
X=[0]*Q
for i in range(1,A+1):
    s[i]=ri()
s[0],s[A+1]=-float('inf'),float('inf')
s.sort()
for i in range(1,B+1):
    t[i]=ri()
t[0],t[B+1]=-float('inf'),float('inf')
t.sort()
for i in range(Q):
    X[i]=ri()

import bisect
for x in X:
    s_i = bisect.bisect_left(s,x)
    t_i = bisect.bisect_left(t,x)
    s_l = x-s[s_i-1]
    s_r = s[s_i]-x
    t_l = x-t[t_i-1]
    t_r = t[t_i]-x
    ans = min(
        [max(s_l,t_l), s_l+t_r+min(s_l,t_r), s_r+t_l+min(s_r,t_l), max(s_r,t_r)]
    )
    print(ans)

Measured memory_bytes: 17780
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = i+1; j < s.size(); ++j) {
            string t;
            if(s[i] != '(' || s[j] != ')') continue;
            int cnt = 0,  valid = 1, stars = 0;
            for (int k = i; k <= j; ++k) {
                if(s[k] == '(') cnt++;
                else if(s[k] == ')') cnt--;
                else stars++;
                if(cnt <= 0) {
                    if(stars) stars = 0;
                    else valid = 0;
                }
                t += s[k];
            }
            if(cnt == 0 && valid) {
                ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

int main(){
	int N; cin>>N;
  	vector<int> h(N);
  	for(int i=0;i<N;i++) cin>>h[i];
  	int ans=0;
  
  	while(1){
      	int rem=0;
      	int cnt=0;
    	for(int i=0;i<N;i++){
          if(h[i]==0){
          	rem=0;
          }
          else{
            if(rem==0) cnt++;
            rem=h[i];
            h[i]--;
          }
        }
      	if(cnt==0) break;
      	ans+=cnt;
    }
  	printf("%d",ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


using Real = double;
using Point = complex<Real>;
const Real EPS = 1e-8;

struct Circle {
    Point p;
    Real r;
    Circle() :p(Point(0, 0)), r(0) {}
    Circle(Point _p, Real _r) :p(_p), r(_r) {}
};

using Points = vector<Point>;
using Circles = vector<Circle>;

bool eq(Real a, Real b) { return abs(a - b) < EPS; }

int intersect(Circle c1, Circle c2) {
    if (c1.r < c2.r) swap(c1, c2);
    Real d = abs(c1.p - c2.p);
    if (c1.r + c2.r < d) return 4;
    if (eq(c1.r + c2.r, d)) return 3;
    if (c1.r - c2.r < d) return 2;
    if (eq(c1.r - c2.r, d)) return 1;
    return 0;
}

pair<Point, Point> crosspoint(Circle& c1, Circle& c2) {
    Real d = abs(c1.p - c2.p);
    Real a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
    Real t = arg(c2.p - c1.p);
    Point p1 = c1.p + polar(c1.r, t + a);
    Point p2 = c1.p + polar(c1.r, t - a);
    return { p1, p2 };
}


bool point_in_circle(Point& p, Circle& c) {
    Real d = abs(p - c.p);
    return d < c.r or eq(c.r, d);
}

Circle circle_scan() {
    int x, y, r; scanf("%d %d %d", &x, &y, &r);
    return Circle(Point(x, y), r);
}

int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */
    auto c1 = circle_scan();
    auto c2 = circle_scan();
    cout << intersect(c1, c2) << endl;
    return 0;
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int V = 10;
//=============warshall_floyd============================
vector<vector<int>>  warshall_floyd(int V, vector<vector<int>> d)
{
  for (int k = 0; k < V; ++k)
  {
    for (int i = 0; i < V; ++i)
    {
      for (int j = 0; j < V; ++j)
      {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  return d;
}
//=================================================


int main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<int>> d(V, vector<int>(V, INF));
  for (int i = 0; i < V; ++i)
  {
    for (int j = 0; j < V; ++j)
    {
      cin >> d.at(i).at(j);
    }
  }
  d = warshall_floyd(V, d);
  int ans = 0;
  int a;
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      cin >> a;
      if (a == -1)
      {
        continue;
      }
      ans += d.at(a).at(1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  std::string inp;
  std::cin >> inp;
  if(inp == "Sunny") {
  	std::cout << "Cloudy";
  }
  else if (inp == "Cloudy") {
  	std::cout << "Rainy";
  }
  else {
  	std::cout << "Sunny";
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

long long dp[100001][3];
int main(){
int N;
long long a[100001][3];
cin>>N;
for(int i=1;i<N+1;i++){
for(int j=0;j<3;j++){
cin>>a[i][j];
}
}
for(int i=0;i<N+1;i++){
for(int j=0;j<3;j++){
dp[i][j]=0;
}
}
for(int i=1;i<N+1;i++){
for(int k=0;k<3;k++){
for(int j=0;j<3;j++){
if(j!=k){
dp[i][k]=max(dp[i][k],dp[i-1][j]+a[i][k]);
}
if(j==k){
dp[i][k]=dp[i][k];
}
}
}
}
long long answer=0;
for(int j=0;j<3;j++){
answer=max(answer,dp[N][j]);
}
cout<<answer<<endl;
}

/*int dp[100001];
int main(){
int N,K;
cin>>N>>K;
int h[100000];
for(int i=1;i<N+1;i++){
cin>>h[i];
}
dp[0]=0;
dp[1]=0;
for(int i=2;i<N+1;i++){
dp[i]=99999999;
if(i<=K){
for(int j=1;j<i;j++){
dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
}
}
if(i>K){
for(int j=i-K;j<i;j++){
dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
}
}
}
cout<<dp[N]<<endl;*/

/*int dp[200000];
int main(){
int N,C;
cin>>N>>C;
int h[200000];
for(int i=1;i<N+1;i++){
cin>>h[i];
}
dp[1]=0;
dp[2]=(h[2]-h[1])*(h[2]-h[1])+C;
for(int i=3;i<N+1;i++){
dp[i]=99999999;
for(int j=1;j<i;j++){
dp[i]=min(dp[i],dp[j]+(h[i]-h[j])*(h[i]-h[j])+C);
}
}
cout<<dp[N]<<endl;*/




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

/**
 * @brief プログラムのエントリーポイントです
 * 
 * @return int 終了後、0を返却しなければなりません。
 */
int main()
{
    // 入力
    int N;
    cin >> N;

    int *A = new int[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    // すぬけさんが満足するには、
    // レンガが左から 1, 2, 3…と並ぶようにしなければならない
    // つまり、最初の「1」を見つける必要がある
    // その後、2, 3 … と連番が見つかるまで、レンガを砕き続ける必要がある
    int breakCount = 0;
    int checkNumber = 1;
    for (int i = 0; i < N; ++i)
    {
        if (A[i] == checkNumber)
        {
            ++checkNumber;
        }
        else
        {
            ++breakCount;
        }
    }

    // 出力
    if (checkNumber > 1)
    {
        cout << breakCount << endl;
    }
    else
    {
        cout << "-1" << endl;
    }

    delete[] A;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
	int n, a;
	cin >> n;
	list<int> l;
	int p = 1;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (p == 1) l.push_back(a);
		else l.push_front(a);
		p *= -1;
	}
	if (p == 1) {
		for (list<int>::iterator it = l.begin();it != l.end();it++) {
			cout << *it << " ";
		}
		cout << endl;
	}
	else {
		reverse(l.begin(), l.end());
		for (list<int>::iterator it = l.begin();it != l.end();it++){
			cout << *it << " ";
		}
		cout << endl;
	}
}


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

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

int D;
int p_contest[27];
int last_contest[27];
int schedule[500][27];
int ti[500];
ll score=0;
ll calc_score(int d){
    ll ans = 0;
    ans += schedule[d][ti[d]];
    last_contest[ti[d]] = d;
    rep(j,1,27){ //penalty
        ans -= p_contest[j] * (d - last_contest[j] );
    }
    return ans;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> D;
    rep(i,1,27){
        cin >> p_contest[i];
        last_contest[i] = 0;
    }
    rep(i,1,D+1){
        rep(j,1,27){
            cin >> schedule[i][j];
        }
    }
    rep(i,1,D+1){
        cin >> ti[i];
        score += calc_score(i);
        cout << score << endl;
    }
}

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

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

    int cnt = 0;
    rep2(i,1,n-1)
    {
        if(p[i-1]<p[i] && p[i]<p[i+1]) cnt++;
        else if(p[i-1]>p[i] && p[i]>p[i+1]) cnt++;
    }        

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

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = []
for n in range(N):
    As.append(int(input()))
As.sort()
ans = sum(As)
ans -= As[-1] // 2
print(ans)

Measured memory_bytes: 8264
#include<cstdio>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
#define PII pair<int,int>
#define MAXN 100010
map<PII,int>G;
queue<PII>Q;
set<int>A[MAXN];
set<int>::iterator it;
int n,fa[MAXN];
int Find(int x)
{
	return fa[x]==x?x:fa[x]=Find(fa[x]);
}
int main()
{
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<=2*n-2;i++)
	{
		scanf("%d%d",&u,&v);
		A[u].insert(v),A[v].insert(u);
		G[PII(u,v)]++;G[PII(v,u)]++;
		if(G[PII(u,v)]==2)
			Q.push(PII(u,v));
	}
	for(int i=1;i<=n;i++)
		fa[i]=i;
	while(!Q.empty())
	{
		int u=Q.front().first,v=Q.front().second;Q.pop();
		u=Find(u),v=Find(v);
		A[u].erase(v),A[v].erase(u);
		if(A[u].size()>A[v].size()) swap(u,v);
		for(it=A[u].begin();it!=A[u].end();it++)
		{
			int x=(*it);
			G[PII(x,u)]=G[PII(u,x)]=0;
			G[PII(x,v)]++,G[PII(v,x)]++;
			if(G[PII(x,v)]==2)
				Q.push(PII(x,v));
			A[x].erase(u);A[x].insert(v);
			A[v].insert(x);
		}
		fa[u]=v;
		A[u].clear();
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
		cnt+=(fa[i]==i);
	if(cnt==1) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 56448
# D - Lunlun Number


def main():
    K = int(input())
    queue = list(range(1, 10))
    i = 0
    while len(queue) < K:
        x = queue[i]
        remainder = x % 10
        if remainder:
            queue.append(10 * x + remainder - 1)
        queue.append(10 * x + remainder)
        if remainder != 9:
            queue.append(10 * x + remainder + 1)
        i += 1
    ans = queue[K - 1]
    print(ans)


if __name__ == "__main__":
    main()


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code
VVL g;
VL gval;

void solve(int v, int par, int val) {
	for (auto&& var : g[v]) {
		if (var != par) {
			solve(var, v, val + gval[v]);
		}
	}
	gval[v] = val + gval[v];
	return;
}

int main(int argc, char const* argv[])
{
	int n,q;
	cin >> n >> q;
	g = VVL(n);
	for (int i = 0; i < n-1; i++) {
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	gval = VL(n,0);
	for (int i = 0; i < q; i++) {
		int p,x;
		cin >> p >> x;
		gval[p-1] += x;
	}
	solve(0, -1, 0);
	for (auto&& var : gval) {
		cout << var << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 27392
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int n,i,flag=0,a[105]={};
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(i=0; i<n; i++){
        if(a[i]%2==0){
            flag+=(a[i]%3)*(a[i]%5);
        }
    }
    if(flag==0)printf("APPROVED");
    else printf("DENIED");
    return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>

int main()
{

	int a[10000], min, max, n, i;
	long long sum = 0;
	scanf("%d", &n);//1??\????????\????????????????????¨?????????
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	max = min = a[0];//??¨?????????????????????????´?????????????????????????
	for (i = 1; i < n; i++){//2????????\??????????´???¨??????
		if (a[i] > max)max = a[i];
		if (a[i] < min)min = a[i];
	}
	printf("%d %d %lld\n", min, max, sum);

	return 0;
}

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

int N, M;
vector<vector<int> > adj;
vector<int> col;

bool dfs(int u) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(col[v] != -1) {
            if(col[v] == col[u]) return false;
            continue;
        }
        col[v] = col[u] ^ 1;
        if(!dfs(v)) return false;
    }
    return true;
}

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

    adj.resize(N);
    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    col = vector<int>(N, -1);
    col[0] = 1;
    bool res = dfs(0);

    if(!res) printf("%lld", 1LL * N * (N - 1) / 2 - M);
    else {
        int cnt1 = 0, cnt2 = 0;
        for(int i = 0; i < N; i++) {
            if(col[i]) cnt1++;
            else cnt2++;
        }
        printf("%lld", 1LL * cnt1 * cnt2 - M);
    }
}


Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] Sa = S.toCharArray();
		if (Sa[2] == Sa[3] && Sa[4] == Sa[5]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22864
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int H, W, N;
	cin >> H >> W >> N;

	int m[100][100];
	bool right = true;
	int x = 0;
	int y = 0;
	for (auto i = 0; i < N; ++i)
	{
		int a;
		cin >> a;
		for (auto j = 0; j < a; ++j)
		{
			m[y][x] = i + 1;
			if (right)
			{
				++x;
				if (x >= W)
				{
					--x;
					++y;
					right = false;
				}
			}
			else
			{
				--x;
				if (x < 0)
				{
					++x;
					++y;
					right = true;
				}
			}
		}
	}

	for (auto i = 0; i < H; ++i)
	{
		for (auto j = 0; j < W; ++j)
		{
			cout << m[i][j];
			if (j != W - 1)
			{
				cout << " ";
			}
		}

		cout << endl;
	}

	return 0;
}

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

while k:
    if a%2 == 1:
        a -= 1
    b += a//2
    a = a//2
    k -= 1
    if k > 0:
        if b%2 == 1:
            b -= 1
        a += b//2
        b = b//2
        k -= 1
print(a, b)

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

int main() {
  string s, t;
  cin >> s >> t;
  s = s + s;
  bool ans = false;
  for (int i=0; i<t.size(); i++) {
    if (s.substr(i,t.size()) == t) {ans = true; break;}
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Amida {
  int height;
  int left;
  int right;
};

bool cmp(const Amida& a, const Amida& b)
{
  return a.height > b.height;
}

int main()
{
  int n, m, a;
  vector<Amida> v;
  Amida buff_amida;

  while (1) {
    cin >> n >> m >> a;
    if (n == 0 && m == 0 && a == 0) break;
    v.clear();
    while (m--) {
      cin >> buff_amida.height >> buff_amida.left >> buff_amida.right;
      v.push_back(buff_amida);
    }

    sort(v.begin(), v.end(), cmp);

    for (auto itr : v) {
      if (itr.left == a) a = itr.right;
      else if (itr.right == a) a = itr.left;
    }

    cout << a << endl;
  }
}



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

int main(){
	int S,h,m,s;
	cin >> S;
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;

	cout <<h<<':'<<m<<':'<<s<<endl;
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m;
    cin >> n >> m;
    ll left = 1, right = n;
    rep(i, m){
        ll l, r; cin >> l >> r;
        chmax(left, l);
        chmin(right, r);
    }
    if(right>=left) cout << right-left+1 << endl;
    else cout << 0 << endl;
}

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

using namespace std;

int main(){
    int A,B,sum,difference,product;
    cin>>A>>B;
    sum=A+B;
    difference=A-B;
    product=A*B;
    if(sum>=product && sum>=difference)cout<<sum;
    else if(difference>=sum && difference>=product)cout<<difference;
    else cout<<product;

}


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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        for(int i=n-1;i>=0;i--){
            if(i==0)System.out.print(a[i]);
            else System.out.print(a[i]+" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26116
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 152076289;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll bit[1 << 18]; int n;
void add(int a, ll w) {
	a++;
	for (int i = a; i <= n + 1; i += i & -i)bit[i] += w;
}
ll sum(int a) {
	a++;
	ll ret = 0;
	for (int i = a; i > 0; i -= i & -i)ret += bit[i];
	return ret;
}
vector<int> alf[26];
bool used[1 << 18];
int main(){
	string s; cin >> s; n = s.length();
	ll k; cin >> k;
	rep(i, n) {
		alf[s[i] - 'a'].push_back(i);
	}
	string out;
	bool added = false;
	bool fin = false;
	while(true) {
		added = false;
		fin = false;
		rep(j, 26) {
			rep(i, (int)alf[j].size()) {
				int id = alf[j][i]; if (used[id])continue;
				int num = id - sum(id); //cout << num << endl;
				if (k >= num) {
					add(id, 1); used[id] = true;
					k -= num;
					out.push_back(s[id]);
					added = true;
				}
				else {
					fin = true;
				}
				if (!k)break;
				if (added&&fin)break;
			}
			if (!k)break;
			if (added&&fin)break;
		}
		if (!added)break;
		if (!k)break;
	}
		rep(i, n) {
			if (!used[i])out.push_back(s[i]);
		}
	cout << out << endl;
	return 0;
}


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

int main() {
  ll a, b;
  cin >> a >> b;

  cout << a*b <<  endl;

  return 0;
}

Measured memory_bytes: 3620
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int q,h,s,d,n;cin>>q>>h>>s>>d>>n;
	dump((n/2)*min({8*q,4*h,2*s,d})+(n%2)*min({4*q,2*h,s}));
}





Measured memory_bytes: 256