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

public class Main {
	public static void main(String[] args) {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; cnt++){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); ++i){
				for(int j = 0; j != w.get(new Integer(cnt)); ++j){
					if(i % 2 == 0){
						if(j % 2 != 0)
							System.out.print(".");
						else
							System.out.print("#");
					}else if(i % 2 != 0){
						if(j % 2 != 0)
							System.out.print("#");
						else
							System.out.print(".");
					}
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 39008
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	int ans=0;
	cin>>n;
	vi a(n+1);
	a[0]=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		//cout<<a[i]<<endl;
	}
	for(int i=1;i<=n;i++){
		if(i==a[a[i]]){
			ans++;
		}
	}
	ans/=2;
	cout<<ans<<endl;
}


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

int main() {
    std::vector<bool> v(26, false);
    std::string s; std::cin >> s;
    for (const auto ss: s) {
        char f = ss - 'a';
        if (v[f]) {
            std::cout << "no" << std::endl;
            return 0;
        }
        v[f] = true;
    }
    std::cout << "yes" << std::endl;
    return 0;
}

Measured memory_bytes: 888
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

fn main() {
    input! {
        n: usize,
        k: usize,
        _a: [u64;n],
    }

    let ans = if (n - 1) % (k - 1) == 0 {
        (n - 1) / (k - 1)
    } else {
        (n - 1) / (k - 1) + 1
    };

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


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

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

	if(S[S.size()-1] == 's')
		S.push_back('e');
	S.push_back('s');

	cout << S << endl;


	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif

int main()
{
	ll n, k;
	static ii q[100000];

	cin >> n >> k;
	ll i;
	rep (i, n)
		cin >> q[i]._0 >> q[i]._1;
	sort(q, q+n);
	i = 0;
	k--;
	for (;;) {
		k -= q[i]._1;
		if (k < 0)
			break;
		i++;
	}
	cout << q[i]._0 << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;
lint dp[5000][5000][4];

int main(){
  int R,C,K;
  cin>>R>>C>>K;
  map<pair<int,int>,lint> m;
  REP(i,K){
    int r,c,v;
    cin>>r>>c>>v;
    r--;c--;
    m[make_pair(r,c)]=v;
  }
  REP(r,R){
    REP(c,C){
      REP(i,4)dp[r][c][i]=0;
      if(r>0){
        REP(i,4)dp[r][c][0]=max(dp[r][c][0],dp[r-1][c][i]);
      }
      if(c>0){
        REP(i,4)dp[r][c][i]=max(dp[r][c][i],dp[r][c-1][i]);
      }
      if(m.find(make_pair(r,c))!=m.end()){
        for(int i=2;i>=0;i--)dp[r][c][i+1]=max(dp[r][c][i+1],dp[r][c][i]+m[make_pair(r,c)]);
      }
    }
  }
  lint ans=0;
  REP(i,4)ans=max(ans,dp[R-1][C-1][i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 309364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int N;
    cin >> N;
    string ans = "No";
    rep(i,4) if(((N-7*i)%4==0) && (N-7*i)>=0) ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  double n,k;
  cin>>n>>k;
  double ans=0;
   cout << fixed << setprecision(14);

  for(int i=1;i<=n;i++){
    double t=1.0/n;
    int h=i;
    while(h<k){
      t/=2;
      h*=2;
    }
    ans+=t;
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)420;

int main(void) {
   ll K,N;
   cin>>N>>K;
   rep(i,K-N+1,K+N) {
      cout<<i<<" ";
   }
   cout<<endl;


   return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto H = aryread();
    H.sort();
    writeln(H[0 .. max(0, N - K)].sum());
}


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

#define SZ(x) ((int(x.size())))

typedef long long ll;
typedef long double ld;

using namespace std;

int a, b, t;

int main()
{
    cin >> a >> b;
    if (a < 0)
    {
        if (b >= 0)
            cout << "Zero";
        else
        {
            t = b - a + 1;
            if (t & 1)
                cout << "Negative";
            else
                cout << "Positive";
        }
    }
    else if (a == 0)
        cout << "Zero";
    else
        cout << "Positive";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long

LL a, b, c, d, ans = 0;

LL GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a%b);
}


int main() {
	cin >> a >> b >> c >> d;
	ans += b - (b / c) - (b / d) + (b / (c*d / GCD(c, d)));
	ans -= a - (a / c) - (a / d) + (a / (c*d / GCD(c, d)));
	if (a%c != 0 && a%d != 0)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }
}

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

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

    void solve() {
        Scanner scanner = new Scanner(System.in);
        final int N = scanner.nextInt();
        final int H = scanner.nextInt();
        final Integer[] A = new Integer[N];
        final Integer[] B = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
            B[i] = scanner.nextInt();
        }
        final int max_a = Collections.max(Arrays.asList(A));
        Arrays.sort(B, Comparator.reverseOrder());
        int h = H;
        int n = 0;
        for (int i = 0; i < N && B[i] >= max_a && h > 0; i++) {
            final int b = B[i];
            h -= b;
            n++;
        }
        n += Math.max(0, h + max_a - 1) / max_a;
        System.out.println(n);
    }
}

Measured memory_bytes: 93424
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pii pair<int,int>
#define int long long int
int n, h[200005] = {}, a[200005] = {}, dp[200005] = {}, tree[800005] = {};
void build(int l, int r, int now){
    if(l == r){
        tree[now] = 0;
        return;
    }
    int m = (l+r)/2;
    build(l, m, now * 2);
    build(l, m + 1, now * 2 + 1);
    return;
}
void update(int L, int R, int now, int k, int delta){
//    cout <<"test:" << L << ' ' << R << endl;
    if(L==R){
//        cout << "UPDATE:" << k << ' ' << L << ' ' << now << endl;
        tree[now] = delta;
        return;
    }
    int m = (L+R) / 2;
    if(m >= k){
        update(L, m, now * 2, k, delta);
    }else{
        update(m + 1 , R, now * 2 + 1, k ,delta);
    }
    tree[now] = max(tree[now * 2], tree[now * 2  + 1]);
    return;
}
int query(int L, int R, int l, int r, int now){
//    cout <<"test2:"<< L << ' ' << R << ' ' << l << ' ' << r << endl;
    if(L >= l && R <= r){
//        cout <<"query2:" << L << ' '<< R << ' ' << now << ' ' << tree[now] << endl;
        return tree[now];
    }
    int m = (L+R) / 2, a = 0, b = 0;
    if(l <= m){
        a = query(L, m, l, r, now * 2);
    }
    if(r > m){
        b = query(m + 1, R, l, r, now * 2 + 1);
    }
//    cout << "query:" << L << ' ' << m << ' ' << R << ' ' << a << ' ' << b << endl;
    return max(a, b);
}
int32_t main(){
    cin >> n;
    set<int> se;
    map<int, int> ma, ma2;
    for(int i = 0 ; i < n ; i++){
        cin >> h[i];
        se.insert(h[i]);
    }
    int cnt = 1;
    for(auto i : se){
//        ma.insert(pii(cnt, i));
        ma2.insert(pii(i, cnt));
        cnt++;
    }
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
        int qu = query(1, n, 1, ma2[h[i]], 1);
        dp[i] = qu + a[i];
//        cout << i << ' ' << qu << ' ' << ma2[h[i]] << ' ' << dp[i] << endl;
        ans = max(ans, dp[i]);
        update(1, n, 1, ma2[h[i]], dp[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 34256
#include <stdio.h>

void main()
{
  int n;
  scanf("%d", &n);
  int m = n % 10;
  if (m == 3)
  {
    printf("bon\n");
  }
  else if((m == 0) | (m == 1) | (m==6)|(m==8))
  {
    printf("pon\n");
  }
  else
  {
    printf("hon\n");
  }
}

Measured memory_bytes: 1624
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MAX = 1e5 + 1;
LL A[MAX];
struct rewrite{
    int b;  // 操作するカード枚数の上限.
    LL  c;  // 書き換え後の整数.
    bool operator < (const rewrite& rhs) const{
        if(c > rhs.c) return true;
        else          return false;
    }
};
vector<rewrite> R;

int main() {
    
    // 1. 入力情報取得.
    int N, M;
    scanf("%d %d", &N, &M);
    LL ans = 0;
    for(int i = 0; i < N; i++) scanf("%lld", A + i), ans += A[i];
    for(int i = 0; i < M; i++){
        rewrite r;
        scanf("%d %lld", &r.b, &r.c);
        R.push_back(r);
    }
    
    // 2. 昇順sort.
    sort(A, A + N);
    
    // 3. 降順sort.
    sort(R.begin(), R.end());
    
    // 4. カードの書き換え作業.
    // なるべく小さいカードA[i]を, なるべく大きい整数 C[j] に, 書き換える.
    int index = 0;
    for(auto &r : R){
        // 4-1. index ～ (index + r.b)番目 までで, 書き換えるか確認.
        int upper = min(N, index + r.b);
        for(int i = index; i < upper; i++){
            // A[i] と比較し, C[j] が 大きければ, 書き換える.
            // C[j] が 小さければ, 書き換えを終了.
            if(A[i] < r.c) ans += r.c - A[i];
            else           break;
        }

        // 4-2. 次の整数 C[j] に書き換えるための準備.
        index += r.b;
        
        // 4-3. index が N以上 ならば, 書き換え出来ないので終了.
        if(index >= N) break;
    }

    // 5. 出力 ～ 後処理.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

#define eps 1e-6
const int N=1000100;
//对数组名取地址得到的是整个数组的地址
ll k[N];
int main() {
    long long a;
    double b;
    cin >> a >> b;
    b += eps;
    ll d = b*100;
    ll c = a*d/100;
    cout << c << endl;
}


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

int main()
{
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  int totalMin = H * 60 + M;
  long double radA = 2.0 * M_PI * (totalMin / 720.0);
  long double radB = 2.0 * M_PI * (M / 60.0);
  long double dRad = abs(radA - radB);
  long double C = pow(A, 2) + pow(B, 2) - 2 * A * B * cos(dRad);
  long double ans = sqrt(C);
  cout << fixed << setprecision(20) << ans << endl;
}


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N;
  cin>>N;
  vector<ll> a(N),b(N);
  ll ans=0;

  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }

  for(int i=N-1;i>=0;i--){
    a[i]+=ans;
    if(a[i]%b[i]!=0) ans+=(b[i]-a[i]%b[i]);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 1792
num = int(input())
words = {}
ans = []

for _ in range(num):
    word = input()
    if word in words.keys():
        words[word] += 1
    else:
        words[word] = 1

words = sorted(words.items(), key = lambda x:x[1], reverse=True)
count = 0

for item in words:
    if count <= item[1]:
        count = item[1]
        ans.append(item[0])
    else:
        break

ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 43228
#include<stdio.h>
int main()
{
	int a [100][100];
	int b [100];
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++)
	{
		for(int j = 0;j < m; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for(int j = 0; j < m; j++)
	{
		scanf("%d", &b[j]);
	}
	int c[100] = {0};
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			c[i] += a[i][j]*b[j];
		}
	}
	for(int i = 0; i < n; i++)
	{
		printf("%d\n", c[i]);
	}
	return 0;
 } 


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

using namespace std;

int main()
{
    int n,input,max1=0,max2=0;
    vector <int> v;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>input;
        if(input>max1){
            max2=max1;
            max1=input;
        }
        else if(input>max2 && max1>max2) max2=input;

        v.push_back(input);
    }
    for(int i=0;i<n;i++){
        if(v[i]==max1) cout << max2<<endl;
        else cout << max1<<endl;
    }

    return 0;
}


Measured memory_bytes: 2548
n = int(input())

al = list(map(int, input().split())) 

import itertools
alsum = list(itertools.accumulate(al))

temp1 = 0
temp2 = 0
res = 0
for i in range(n):
    res += al[i]
    if i % 2 ==0:
        if res >0:
            pass
        else:
            y = res*(-1)+1
            temp1 += y
            res =1
    else:
        if res <0:
            pass
        else:
            y = res+1
            temp1 += y
            res = -1
    
res= 0

for j in range(n):
    res += al[j]
    if j % 2 ==0:
        if res <0:
            pass
        else:
            y = res+1
            temp2 += y
            res = -1
    else:
        if res >0:
            pass
        else:
            y = res*(-1)+1
            temp2 += y
            res = 1

print(min(temp1,temp2))

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 200010;

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

	multiset<int> s;
	rep(i, N) {
		int t; cin >> t;
		s.insert(t);
	}

	int ans = 0;

	while (s.size()) {
		auto it = s.end();
		--it;
		int x = *it;
		s.erase(it);

		for (int j = 0; j <= 30; ++j) {
			int p = (1 << j) - x;
			if (p <= x && s.count(p)) {
				s.erase(s.lower_bound(p));
				++ans;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9600
N, M = map(int, input().split())

range_list = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    range_list[p-1].append([y, i])

result_list = [0] * M
for i, py in enumerate(range_list):
    py.sort()
    for j, (y, p) in enumerate(py):
        result_list[p] = "%06d%06d" % (i+1, j+1)

print('\n'.join(result_list))

Measured memory_bytes: 41420
import math
n = int(input())
x = list(map(int, input().split()))
a = sum(x)//n
b = math.ceil(sum(x)/n)
ma = 0
mb = 0
for i in x:
	ma += (i-a)**2
for i in x:
	mb += (i-b)**2
print (min(ma,mb))


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

// ?????§????´¢
bool LinearSearch(int A[], int n, int key) {
	// ?°?key???????????°???????????????
	A[n] = key;
	int i = 0;
	while (A[i] != key)
		i++;
	// ??????i??????n????????£??¨??¨?????\?????°???????????°key???
	// ????????£??¨?????\??°????????????key????????°?????????????????\??°?????????????´?
	return i != n;
}
int main() {
	int n, q, key;
	int sum = 0;
	int A[10000 + 10];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &key);
		if (LinearSearch(A, n, key))
			sum++;
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 3232
#include<iostream>
#include<numeric>
#include<cmath>
#include<vector>

using namespace std;
/*
int main() {
	int A, N,answer;
	cout << "N,Aを入力。" << endl;
	cin >> N >> A;
	answer = N % 500;
	if (A>=1)
	{
		answer %= 1;
		if (answer==0)
		{
			cout << "Yes" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}
*/
int main() {
	int N ,n,tmp=0;
	vector<int> A;
	
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> n;
		A.push_back(n);
	}

	for ( int  t= 0; t <N; t++)
	{
		for (int r = 0; r < N; r++)
		{
			if (tmp < abs(A[t] - A[r]))
			{
				tmp = abs(A[t] - A[r]);
			}
		}
	}

	cout << tmp;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Integer> s = new HashMap<String, Integer>();
    char[] c;
    String ds;
    long ans = 0;
    int tmp;
    for (int i=0;i<n;i++){
      c = sc.next().toCharArray();
      Arrays.sort(c);
      ds = String.valueOf(c);
      tmp = s.getOrDefault(ds,0);
      ans += tmp;
      s.put(ds,tmp+1);
    }
    sc.close();
    System.out.println(ans);
  }
}

Measured memory_bytes: 53416
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
char S[100001];
int main(){
  int i, j, t0, t1;
  N = rd(S);
  for(i=0;i<N;i++){
    S[i] -= '0';
  }
  for(i=0;i<N;i+=2){
    S[i] = 1 - S[i];
  }
  t0 = t1 = 0;
  for(i=0;i<N;i++){
    if(S[i]){
      t1++;
    }
    else{
      t0++;
    }
  }
  wt_L(min_L(t0, t1));
  wt_L('\n');
  return 0;
}
// cLay varsion 20190608-2

// --- original code ---
// int N; char S[100001];
// {
//   int i, j, t0, t1;
// 
//   rd(S@N);
//   rep(i,N) S[i] -= '0';
//   for(i=0;i<N;i+=2) S[i] = 1 - S[i];
// 
//   t0 = t1 = 0;
//   rep(i,N) if[S[i], t1, t0]++;
//   wt(min(t0,t1));
// }


Measured memory_bytes: 384
/*	ex7_1
	suzuto	*/

#include <stdio.h>

typedef struct point{ /*直交座標を表す構造体を作る*/
  int x_elem;
  int y_elem;
}point;

#define  point_scanf(z) scanf("%d %d", &z.x_elem, &z.y_elem); /*point型を入力をする関数を定義*/
#define  point_printf(z) printf("%d %d", z.x_elem, z.y_elem); /*point型を出力をする関数を定義*/

point shift_point(point bef_point, int move_x, int move_y); /*プロトタイプ宣言*/

int main(void) {
  point point_1, point_2, point_3, point_4, vect_1to2, vect_2to3, vect_3to4; /*変数の宣言*/

  point_scanf(point_1); /*既知の座標を入力*/
  point_scanf(point_2);

  vect_1to2.x_elem = point_2.x_elem - point_1.x_elem; /*point_1からpoint_2へのベクトル(point_1を原点としてみたときのpoint_2の座標)*/
  vect_1to2.y_elem = point_2.y_elem - point_1.y_elem;

  vect_2to3.x_elem = -1 * vect_1to2.y_elem; /*point_2からpoint_3へのベクトル = vect_1to2を時計回りに90度回転*/
  vect_2to3.y_elem = vect_1to2.x_elem;

  vect_3to4.x_elem = -1 * vect_1to2.x_elem; /*point_3からpoint_4へのベクトル = vect_1to2を時計回りに180度回転*/
  vect_3to4.y_elem = -1 * vect_1to2.y_elem;

  /*未知の座標を算出*/
  point_3 = shift_point(point_2, vect_2to3.x_elem, vect_2to3.y_elem);
  point_4 = shift_point(point_3, vect_3to4.x_elem, vect_3to4.y_elem);

  point_printf(point_3); /*結果を出力*/
  printf(" ");
  point_printf(point_4);
  printf("\n");
  return 0;
}

point shift_point(point bef_point, int move_x, int move_y){ /*bef_pointをxの正の方向にmove_x、yの正の方向にmove_yだけ動かした座標aft_pointを返す*/
  point aft_point; /*変数の宣言*/
  aft_point.x_elem = bef_point.x_elem + move_x; /*x方向の移動*/
  aft_point.y_elem = bef_point.y_elem + move_y; /*y方向の移動*/
  return aft_point;
}


Measured memory_bytes: 1732
a, b = gets.split.map(&:to_i)
loop {
    leap = (a..b).select{|y|
        y % 400 == 0 ? true :
        y % 100 == 0 ? false :
        y % 4 == 0 ? true : false
    }
    puts leap.empty? ? "NA" : leap
    a, b = gets.split.map(&:to_i)
    break if a == 0
    puts
}

Measured memory_bytes: 6112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int x = sc.nextInt();
		
		
		System.out.println((x-2)*180);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    reverse(a,a+n);
    int ans = a[0];
    int cnt = 0;
    int rest = n-2;
    for(int i = 1;rest > 0;i++){
        int tmp = min(2ll,rest); 
        //trace(tmp,rest);
        rest -= tmp;
        ans += a[i]*tmp;



    }
    

    cout << ans << endl;
    

    return 0;
}

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

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

ll s(ll a, ll b) {
	if (a < b) swap(a, b);
	return (a + b) * (a - b + 1) / 2 % MOD;
}

int main() {
	ll n, k;
	cin >> n >> k;
	if (k == n + 1) {
		cout << 1;
		return 0;
	}
	ll ans = 0;
	reps(i, k - 1, n + 1) {
		ans += (s(n, n - i) - s(i, 0) + 1) % MOD;
		ans %= MOD;
	}
	if (ans < 0) ans += MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define lol long long
template<class A,class B>inline bool chmax(A &a,const B &b){return(b>a&&(a=b,true));}
template<class A,class B>inline bool chmin(A &a,const B &b){return(b<a&&(a=b,true));}
using namespace std;
lol mod=1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin >>n;
  vector<int> fro(n),bak(n);
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >>a[i];
  fro[0]=a[0];
  bak.back()=a.back();
  for(int i=1;i<n;i++){
    fro[i]=gcd(fro[i-1],a[i]);
  }
  for(int i=n-2;i>=0;i--){
    bak[i]=gcd(bak[i+1],a[i]);
  }
  int ans=0;
  for(int i=1;i<n-1;i++){
    chmax(ans,gcd(fro[i-1],bak[i+1]));
  }
  chmax(ans,bak[1]);
  chmax(ans,fro[n-2]);
  cout <<ans<<'\n';
  return (0);
}

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

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc156_c();
        }

        static void abc156_c()
        {
            // ABC156 C - Rally
            // pの全探索で間に合う (1-100の範囲外は最適場所になりえない)
            long n = long.Parse(Console.ReadLine());
            long[] X = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            long min_work = 10010010010;
            for (int p=1; p<=100; p++)
            {
                long tmp_work = 0;
                for (int i=0; i<n; i++)
                    tmp_work += (long)Math.Pow(X[i] - p, 2);
                min_work = Math.Min(tmp_work, min_work);
            }
            Console.WriteLine(min_work);
        }
    }
}

Measured memory_bytes: 13396
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val m1 = sc.nextInt()
  sc.nextInt()
  val m2 = sc.nextInt()
  val d2 = sc.nextInt()

  if (m1 == m2) {
    println(0)
    return
  }
  if (m1 != m2 && d2 == 1) {
    println(1)
  } else {
    println(0)
  }
}

Measured memory_bytes: 31388
#include <iostream>
using namespace std;
int A[1000][1000]={{}};
int b[1000]={};
int main(void){
  int n, m, i, j;
  int sum;


  cin >> n >> m;

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

  for(i=0; i<m; i++){
      cin >>b[i];
  }


  for(i=0; i<n; i++){
      sum = 0;
      for(j=0; j<m; j++){
          sum += A[i][j] * b[j];
      }
      cout << sum << endl;
  }
}


Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int N;
    long long just;
    cin >> N >> just;
    vector<long long> A(N);
    vector<long long> sum(N + 1, 0);
    for(int i = 0; i < N; i++)cin >> A[i];
    sort(A.begin(), A.end());
    for(int i = 0; i < N; i++)sum[i + 1] = sum[i] + A[i];
    
    int ans = N - 1;
    for(int i = 1; i <= N; i++){
        if(sum[i] < just)continue;
        if(sum[i] == just)ans = i;
        if(sum[i] > just)ans = i - 1;
        break;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
using namespace std;
int inf = 1000000000;

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

map<string, int> mp;

string trans(vector< vector<int> > a){
  string t = "";
  for(int i=0; i<3; i++) for(int j=0; j<3; j++) t += to_string(a[i][j]);
  return t;
}

void dfs(vector< vector<int> > a, int turn){
  string t = trans(a);
  if( mp[t] != 0 && turn > mp[t] ) return;
  if( t == "123456780" ){
    // cout << t << " " << turn << " " << mp[t] << endl;
    mp[t] = turn;
    return;
  }
  if( turn > 15 ) return;
  mp[t] = turn;
  // cerr << t << " " << mp[t] << endl;

  for(int y=0; y<3; y++){
    for(int x=0; x<3; x++){
      if( a[y][x] == 0 ){
        for(int d=0; d<4; d++){
          int nx = x + dx[d]; int ny = y + dy[d];
          if( nx < 0 || ny < 0 || nx >= 3 || ny >= 3 ) continue;
          vector< vector<int> > b = a;
          swap(b[ny][nx], b[y][x]);
          string tt = trans(b);
          dfs(b, turn + 1);
        }
      }
    }
  }
  return;
}

void bfs(string sss){
  queue< pair<int, string> > q;
  q.push(make_pair(0, sss));
  map<string, int> mpb;
  while( !q.empty() ){
    pair<int, string> p = q.front();
    q.pop();

    string s = p.second;
    mpb[s] = p.first;
    // cerr << p.first << " " << p.second << endl;
    if( s == "123456780" ){
      cout << p.first << endl;
      return;
    }

    for(int i=0; i<9; i++){
      if( s[i] == '0' ){
        int y = i / 3;
        int x = i % 3;
        for(int d=0; d<4; d++){
          int nx = x + dx[d]; int ny = y + dy[d];
          // cerr << x << " " << y << " -> " << nx << " " << ny << endl;
          if( nx < 0 || ny < 0 || nx >= 3 || ny >= 3 ) continue;
          string t = s;
          swap(t[i], t[ny*3 + nx]);
          // cerr << t << endl;
          if( mpb[t] == 0 ) q.push( make_pair(p.first + 1, t) );
        }
      }
    }

  }
}

int main(){

  vector< vector<int> > a(3, vector<int>(3));
  for(int i=0; i<3; i++) for(int j=0; j<3; j++) cin >> a[i][j];
  // mp[trans(a)] = 0;
  // mp["123456780"] = inf;
  // dfs(a, 1);
  bfs(trans(a));
  // cout << mp["123456780"] - 1 << endl;
  return 0;
}

Measured memory_bytes: 26268
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long

using namespace std;

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

    int value = 0;
    int ans = 1;
    for(int i = 1;i <= n;i++){
        int div = i;
        int count = 0;
        while(div % 2 == 0 && div > 1){
            div /= 2;
            count++;
        }

        if(count >= value){
            value = count;
            ans = i;
        }
    }

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int ret = 0;
    for (int i = 1; i < n - 1; ++i) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1]))
            ret++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll w, h, n;
    cin >> w >> h >> n;
    ll x1, x2, y1, y2;
    x1 = y1 = 0;
    x2 = w;
    y2 = h;
    rep(i, n){
        ll x, y, a;
        cin >> x >> y >> a;
        if(a==1)x1 = max(x1, x);
        else if(a==2)x2 = min(x2, x);
        else if(a==3)y1 = max(y1, y);
        else y2 = min(y2, y);
    }
    cout << max((ll)0, x2-x1)*max((ll)0, y2-y1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N;
  cin >> N;
  ll sum = 0;
  ll absmin = 10000000000;
  ll under0 = 0;

  rep(i, N){
    ll a;
    cin >> a;
    sum += abs(a);
    if(absmin > abs(a)) absmin = abs(a);
    if(a < 0) under0++;
  }
  ll ans = sum - (under0 % 2) * 2 * absmin;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

const int MAX_N = 1000000;

class SegmentTree{
public:
    SegmentTree(){}
    SegmentTree(int n){init(n);}
    void init(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        
        REP(i, size){
            update(i, 0);
        }
    }
    void update(int k, int v){
        k += size - 1;
        seg1[k] = v;
        seg2[k] = k - (size-1);
        
        while(k > 0){
            k = (k-1) / 2;
            if(seg1[k*2+1] >= seg1[k*2+2]){
                seg1[k] = seg1[k*2+1];
                seg2[k] = seg2[k*2+1];
            }else{
                seg1[k] = seg1[k*2+2];
                seg2[k] = seg2[k*2+2];
            }
        }
    }
    P query(int l, int r){
        return _query(l, r, 0, 0, size);
    }
private:
    P _query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a){return mp(-1, -1);}
        if(a <= l && r <= b){return mp(seg1[k], seg2[k]);}
        P lp = _query(a, b, 2*k+1, l, (l+r)/2), rp = _query(a, b, 2*k+2, (l+r)/2, r);
        if(lp.first >= rp.first){
            return lp;
        }else{
            return rp;
        }
    }
    int seg1[MAX_N*4], seg2[MAX_N*4], size;
};

int N, Q;
SegmentTree st;

int main(){
    std::cin >> N >> Q;
    st.init(N);
    
    REP(i, Q){
        int a, v;
        std::cin >> a >> v;
        --a;
        int nv = st.query(a, a+1).first + v;
        st.update(a, nv);
        P res = st.query(0, N);
        std::cout << res.second+1 << " " << res.first << std::endl;
    }
}

Measured memory_bytes: 21636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] abc = br.readLine().split(" ");
        int a = Integer.parseInt(abc[0]);
        int b = Integer.parseInt(abc[1]);
        int c = Integer.parseInt(abc[2]);
        System.out.println(problem136a(a, b, c));
    }

    private static int problem136a(int a, int b, int c) {
        return Math.max((c - (a - b)), 0);
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define LL long long

using namespace std;

const int N = 2e5 + 7;
const LL mod = 1e9 + 7;
const int B = sqrt(1e5);

string s;

bool f( char c )
{
    if( c == 'R' || c == 'U' || c == 'D' )return true;
    return false;
}

bool ff( char c )
{
    if( c == 'L' || c == 'U' || c == 'D' )return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin >> s;
    for( int i = 0; i < (int)s.size(); i++ ){
        if( i % 2 == 0 && !f(s[i]) ){
            cout << "No";
            return 0;
        }
        if( i % 2 == 1 && !ff(s[i]) ){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>:: iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];

bool dfs(int node,int c)
{
    check[node]=true;
    arr2[node]=c;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            if(dfs(vi[node][child],c^1)==false)
            {
                return false;
            }
        }
        else if(arr2[node]==arr2[vi[node][child]])
        {
            return false;
        }
        //else if()
    }
    return true;
}

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int res1=(a+b)*c;
    res1/=2;
    cout<<res1;

}





Measured memory_bytes: 5924
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int i,n,max,min,a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++)
  scanf("%d",&a[i]);
  max=a[0];
  min=a[0];
  for(i=0;i<n;i++){
    if(a[i]<min)
    min=a[i];
    if(a[i]>max)
    max=a[i];
  }
printf("%d\n",max-min );
  return 0;
}


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

int main(){

	int a,b;
	string op;

	while(cin >> a >> op >> b, op!="?"){
		if(op=="+")
			cout << a+b << endl;
		else if(op=="-")
			cout << a-b << endl;
		else if(op=="*")
			cout << a*b << endl;
		else if(op=="/")
			cout << a/b << endl; 
	}

	return 0;
}

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

#define BLACK 0
#define GRAY 1
#define WHITE 2

using namespace std;

void DFS(int);

int ans = 0, color[100];
//vector <int> color;                                                                                                                                                                                       
vector< vector<int> > v;

int main(){

  int V, E, s, t;//, start;                                                                                                                                                                                 

  cin >> V >> E;
  //  cin >> s >> t;                                                                                                                                                                                        
  //  start = s;                                                                                                                                                                                            

  v.resize(V);

  //  v[s].push_back(t);                                                                                                                                                                                    
  //  for(int i=0; i<E-1; i++){                                                                                                                                                                             
  for(int i=0; i<E; i++){
    cin >> s >> t;
    v[s].push_back(t);
  }

  for(int i=0; i<V; i++)
    color[i] = WHITE;

  //  DFS(start);                                                                                                                                                                                           

  for(int i=0; i<V; i++)
    if(color[i] == WHITE) DFS(i);

  cout << ans << endl;

  //cout << V << E << endl;                                                                                                                                                                                 
  return 0;
}

void DFS(int u){
  int a;

  //  color[u] = GRAY; //colorをvector宣言した時segmentation fault                                                                                                                                          
  // color[u].push_back(GRAY);                                                                                                                                                                              
  color[u] = GRAY;

  for(int i = 0; i < v[u].size(); i++){
    a = v[u][i];
    if(color[a] == GRAY) ans = 1;
    if(color[a] == WHITE) DFS(a);
  }
  color[u] = BLACK;
}



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

using namespace std;

int main() {
  int n;
  while(cin >> n && n){
    int k,t;
    vector<vector<int> > p(n);
    vector<int> l;
    for(int i=0;i<n;++i){
      cin >> k;
      for(int j=0;j<k;++j) {
	cin >> t;
	p[i].push_back(t);
      }
      sort(p[i].begin(),p[i].end());
    }
    cin >> k;
    for(int i=0;i<k;++i){
      cin >> t;
      l.push_back(t);
    }
    sort(l.begin(),l.end());
    pair<int,int> ans;
    for(int i=0;i<n;++i){
      int tmp=0,cnt=0;
      for(int j=0;j<p[i].size();++j){
	if(tmp<l.size() && l[tmp]==p[i][j]) cnt++,tmp++;
      }
      if(cnt==l.size()) ans.first++,ans.second=i+1;
    }
    if(ans.first==1) cout << ans.second << endl;
    else cout << -1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3216
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define ll long long
#define clr(x) memset((x),0,sizeof(x))
using namespace std;
template<class T>
inline void read(T &res){
	static char ch;T flag=1;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
}
inline int readin(){
	static char ch;int flag=1,res;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
	return res;
}
inline int readst(char *s){
	static char ch;int len=0;
	while((ch=getchar())<'a'||ch>'z');s[len++]=ch;
	while((ch=getchar())>='a'&&ch<='z')s[len++]=ch;
	return --len;
}
int n,m;
int main(){
	read(n);
	while(n){
		if(__builtin_popcount(n)==1){
			cout<<n<<endl;
			return 0;
		}
		n--;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	long long h[n];
	for(int i=0;i<n;i++)cin>>h[i];
	long long dp[n+1];
	dp[0]=0;
	dp[1]=0;
	for(int i=2;i<=n;i++){
		if(i==2)
		dp[i]=dp[i-1]+abs(h[i-1]-h[i-2]);
		else
		dp[i]=min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]));
	}
	cout<<dp[n];
	return 0;
	
}


Measured memory_bytes: 5204
#include <stdio.h>
int main() {
	int x, a, b;
	scanf("%d %d %d",&x,&a,&b);
	
	int ax = 0;
	if (x > a)
	{
		ax = x - a;
	}
	else
	{
		ax = a - x;
	}
	
	int bx = 0;
	if (x > b)
	{
		bx = x - b;
	}
	else
	{
		bx = b - x;
	}
	
	if (ax > bx)
	{
		printf("B\n");
	}
	else 
	{
		printf("A\n");
	}
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 102030405060708090
#define MOD 1000000007

int main()
{
  int n;cin>>n;
  vector<vector<int>> a(n,vector<int>(n));
  int i,j;
  rep(i,n)rep(j,n)
  {
    cin>>a[i][j];
  }
  vector<ll> dp(1<<n,0);
  dp[0]=1;
  rep(i,(1<<n)-1)
  {
    int now=0;
    rep(j,n)
    {
      if(i&(1<<j))now++;
    }
    rep(j,n)
    {
      if(i&(1<<j))continue;
      if(a[now][j]==0)continue;
      dp[i|(1<<j)]+=dp[i];
      dp[i|(1<<j)]%=MOD;
    }
  }
  cout<<dp[(1<<n)-1]<<endl;
}


Measured memory_bytes: 16640