akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;


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


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

    int win = 0, lose = 0;
    rep(i, s.size()) {
        auto c = s[i];
        if (i & 1) {
            if (c == 'g') win++;
        }
        else {
            if (c == 'p') lose++;
        }
    }

    cout << win - lose << endl;

    return 0;
}

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

int main()
{
  int l, r, d, ans = 0;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++)
  {
    if (i % d == 0)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
W,H,N = map(int,input().split())
#corner決定
left = 0
under =0
right = W
upper = H

for _ in range(N):
    x,y,a = map(int,input().split())
    if a ==1:
        left = max(x,left)
    elif a ==2:
        right =min(x,right)
    elif a == 3:
        under = max(y,under)
    elif a == 4:
        upper = min(y,upper)
#面積決定
if (right-left)>0 and (upper-under)>0:
    S = (right-left)*(upper-under)
    print(S)
else:
    print(0)

Measured memory_bytes: 3064
arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end

if arr[0] == arr[1] and arr[0] == arr[2]
  puts 1
elsif
  arr[0] != arr[1] and arr[0] != arr[2] and arr[1] != arr[2]
  puts 3
else
  puts 2
end

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<climits>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair <int, int>
#define piii pair<int, pii>
#define vi vector<int>
#define vpii vector<pii>

#define read1(a) int a; scanf("%d", &a)
#define read2(a, b) int a, b; scanf("%d %d", &a, &b)
#define read3(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c)

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

#define readgi(n) F0R(i, n) { scanf("%d", &arr[i]); }
#define readgs(n) F0R(i, n) { scanf(" %c", &arr[i]); }

#define f first
#define s second

#define usaco(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout);

#define println1(a) printf("%d\n", a);
#define println2(a, b) printf("%d %d\n", a, b);
#define println3(a, b, c) printf("%d %d %d\n", a, b, c);
#define pv(v) for (int i : v) { printf("%d ", i); } printf("\n");

const int MOD = 1000000007;
const int MAX = 2005;

vi g[MAX];
bool v[MAX][MAX];
int dist[MAX][MAX];
int n, k;

void dfs(int st, int i) {
    v[st][i] = true;
    for (int j : g[i]) {
        if (!v[st][j]) {
            dist[st][j] = dist[st][i] + 1;
            dfs(st, j);
        }
    }
}

int ct(int r1, int r2) {
    int ans = 0;
    FOR(i, 1, n+1) {
        if (dist[r1][i] <= k/2 || dist[r2][i] <= k/2) { ans++; }
    }
    return ans;
}
int main() {
    scanf("%d %d", &n, &k);
    vector<pii> edges;
    F0R(i, n-1) {
        read2(a, b);
        g[a].pb(b); g[b].pb(a);
        edges.pb(mp(a, b));
    }
    FOR(i, 1, n+1) { dfs(i, i); }
    int maxx = -1;
    if (k%2 == 0) {
        FOR(i, 1, n+1) { maxx = max(maxx, ct(i, i)); }
    }
    else {
        F0R(i, edges.size()) {
            maxx = max(maxx, ct(edges[i].f, edges[i].s));
        }
    }
    cout << n - maxx << endl;
}


Measured memory_bytes: 20096
def main():
    X = int(input())
    if 2000 <= X:
        return print(1)
    if X < 100:
        return print(0)
    if X < 1000:
        c = str(X)
        c = int(c[0])*100 + int(c[0])*5
        if X <= c:
            return print(1)
        else:
            return print(0)
    else:
        c = str(X)
        c = int(c[:2])*100 + int(c[:2])*5
        if X <= c:
            return print(1)
        else:
            return print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <climits>
#include <stack>
#define FOR(i,p,k) for(int i = (p);i<(k);i++)
typedef long long int LL;
using namespace std;

void dane() {
	string s;
	cin>>s;
	
	cout<<s.substr(0,4)<<" "<<s.substr(4)<<"\n";
}

int main() {
  dane();
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int A;
    static int B;
    static long[] X;


    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        X = sc.nextLongArray(N);

        System.out.println( solve() );
    }

    private static long solve() {
        long sum = 0;
        for (int i = 0; i < N-1; i++) {
            long walk = (X[i+1] - X[i])*A;
            sum += Math.min(walk, B);
        }
        return sum;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 35796
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

string f(int a){
	string s=to_string(a);
	while(s.size()-6)s="0"+s;
	return s;
}
signed main(){
	int n,m;
	cin>>n>>m;
	vs out(m);
	vvp in(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;
		in[a].pb({b,i});
	}
	rep(i,n){
		sort(all(in[i]));
		rep(j,in[i].size())out[in[i][j].second]=f(i+1)+f(j+1);
	}
	rep(i,m)cout<<out[i]<<endl;
}















Measured memory_bytes: 12416
S = input().strip()
N = len(S)
if N<5:
    print("NO")
else:
    flag = 0
    cur = N
    while cur>0:
        if cur>=7 and S[cur-7:cur]=="dreamer":
            cur -= 7
        elif cur>=6 and S[cur-6:cur]=="eraser":
            cur -= 6
        elif cur>=5 and S[cur-5:cur] in ["dream","erase"]:
            cur -= 5
        else:
            flag = 1
            break
    if flag==0:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9252
#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 int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; 
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)           


void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();
	string s, t; 
	cin >> s >> t; 

	int sz_t = t.size(), ans = inf; 
	for(int i = 0; i  + sz_t <=  s.size(); ++ i)
	{
		string ss = s.substr(i, sz_t); 

		int can = 0; 
		for(int j = 0; j < sz_t; ++ j)
		{
			can += (t[j] != ss[j]); 
		}

		ans = min(ans, can); 
	}

	cout << ans; 

	return 0;
}

Measured memory_bytes: 3660
open Batteries
let rec perm n ls =
  if n = 0 then [[]]
  else flatmap (fun x -> List.map (fun y -> x :: y)
                                  (perm (n - 1) (remove x ls)))
               ls
and remove x ls = List.filter (fun y -> x <> y) ls
and flatten = function
  [] -> []
| x::xs -> x @ (flatten xs)
and flatmap func ls = flatten (List.map func ls)


let n = read_int ()
let rec m lst =
  match lst with
   [] -> ""
  | first :: rest -> first ^ m rest
let p = m (read_line () |> String.split_on_char ' ')
let q = m (read_line () |> String.split_on_char ' ')
let rec g k =
  match k with
   0 -> []
  | _ -> k :: g (k-1)
let all = 
  let rec h lst =
    match lst with
     [] -> []
    | first :: rest -> m(List.map string_of_int first) :: h rest
  in List.sort compare (h(perm n (g n)))

let _ = 
  let rec o target l s =
    match l with
     [] -> 0
    | first :: rest -> if first = target then s else o target rest (s+1)
  in let jj t = if t < 0 then t * (-1) else t
    in print_endline(string_of_int (jj( (o p all 1) - (o q all 1))))


Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int s = 0;
    rep(i, n) s ^= a[i];
    rep(i, n) a[i] ^= s;
    rep(i, n) cout << a[i] << endl;

    return 0;
}

Measured memory_bytes: 3948
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    int n, m;
    cin >> n >> m;
    int d[200000];
    rep(i,m){
        int l,r;
        cin >> l >> r;
        l--;
        d[l]++;
        d[r]--;
    }
    rep1(i, 1, n + 10) d[i] += d[i - 1];
    int cnt = 0;
    rep(i,n+10){
        if(d[i]==m)
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long f[87],n;
int main(){
    cin>>n;
    f[0]=2;
    f[1]=1;
    for(int i=2;i<=n;i++)
        f[i]=f[i-1]+f[i-2];
    cout<<f[n]<<endl;
}

Measured memory_bytes: 256
# include"stdio.h"
int main(){
    int w,a,b;
    scanf("%d %d %d",&w,&a,&b);
    if(a==b) printf("0\n");
    if(a>b){
        b+=w;
        if(a-b>0) printf("%d\n",a-b);
        else printf("0\n");
    }
    if(a<b){
        a+=w;
        if(b-a>0) printf("%d\n",b-a);
        else printf("0\n");
    }
}


Measured memory_bytes: 1688
package main

import (
	"fmt"
)

//const pi = math.Pi

func main() {
	var a, b, c, d, e, k int
	fmt.Scan(&a, &b, &c, &d, &e, &k)
	if e-a > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}

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

#define INF INT_MAX

using namespace std;

vector <int> D;
int n=0;

void initRMQ(int n_){

  n = 1;
  while(n <= n_) n *= 2;
 
  D.resize(2*n-1);

  for(int i=0; i<2*n-1-1; i++) D[i] = 0;
}


void add(int k, int a){

  k += n - 1;
  D[k] += a;

  while(k > 0){
    k = (k-1) / 2;
    D[k] = D[k*2+1] + D[k*2+2];
  }
}


int query(int a, int b,int k, int l, int r){

  if(r <=a || b <= l) return 0;
  if(a <= l && r <= b) return D[k];
   
  int vl = query(a, b, k*2+1, l, (l+r)/2);
  int vr = query(a, b, k*2+2,(l+r)/2, r);
  return vl + vr;
  
}


int getSum(int a, int b){

  return query(a, b+1, 0, 0, n);
}


int main(){
  int N, q, com, x, y;

  cin >> N >> q;

  //  D.resize(N);
  initRMQ(N);

  for(int i=0; i<q; i++){
    cin >> com >> x >> y;

    if(com == 0) add(x, y);
    else if(com == 1){ cout << getSum(x, y); cout << endl;}
  }
}



Measured memory_bytes: 3840
import math
k = int(input())
a = []
for i in range(1, k+1):
    for j in range(1, k+1):
        x = math.gcd(i, j)
        for l in range(1, k+1):
            y = math.gcd(l, x)
            a.append(y)
print(sum(a))

Measured memory_bytes: 71468
#include <stdio.h>

int main()
{

    int i, j, temp, v[100000], N;
    double ans;
    scanf("%d", &N);
    for (i = 1; i <= N; ++i)
        scanf("%d", &v[i]);
    for (i = 1; i <= N; ++i)
    {
        for (j = i + 1; j <= N; ++j)
        {
            if (v[i] > v[j])
            {
                temp = v[i];
                v[i] = v[j];
                v[j] = temp;
            }
        }
    }
    ans = v[1];
    for (i = 2; i <= N; i++)
    {
        ans = (ans + v[i]) / 2;
    }
    printf("%lf", ans);
    return 0;
}

Measured memory_bytes: 128
# A - Weather Prediction
# 1日毎に　晴れ（Sunny） 曇り（Cloudy） 雨（Rainy） の順に変化する
# 晴 → 曇 → 雨 → 晴 → 曇 → 雨 → ...

# 文字列 S の入力
S = input()
# print(S)

# 明日の天気を表示させる
# 今日の天気で分岐し、printで表示
if S == 'Sunny':
    # print('Cloudy')
    answer = 'Cloudy'
elif S == 'Cloudy':
    # print('Rainy')
    answer = 'Rainy'
elif S == 'Rainy':
    # print('Sunny')
    answer = 'Sunny'

print(answer)


Measured memory_bytes: 8796
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int x = min(B, D) - max(A, C);
	if(x > 0){
      cout << x;
    }else{
      cout << 0;
    }
	return 0;
}

Measured memory_bytes: 256
# ABC062A - Grouping
x, y = list(map(int, input().rstrip().split()))
lst = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11]]

for i in lst:
    if x in i and y in i:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int a = 10 * (S[0] - '0') + (S[1] - '0');
  int b = 10 * (S[2] - '0') + (S[3] - '0');
  if ((a == 0 || a > 12) && 1 <= b && b <= 12)
    cout << "YYMM" << endl;
  else if ((b == 0 || b > 12) && 1 <= a && a <= 12)
    cout << "MMYY" << endl;
  else if (a != 0 && b != 0 && !(a > 12 && b > 12))
    cout << "AMBIGUOUS" << endl;
  else
    cout << "NA" << endl;

  return 0;
}


Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

string arr[3] = {"Sunny", "Cloudy", "Rainy"};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if (arr[i]== s)
        {
            cout << arr[(i + 1) % 3];
        }
    }

    return 0;
}	

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

s = sum(A)
idx = 0
s1 = 0
half = s//2
for i, a in enumerate(A):
    s1 += a
    if half < s1:
        idx = i
        break

s2 = sum(A[i+1:])
ans1 = abs(s1-s2)
s3 = sum(A[i:])
ans2 = abs(s1-s3-A[i])
print(min([ans1, ans2]))


Measured memory_bytes: 89040
import sys
s = list(str(input()))
t = list(str(input()))
ss = sorted(s)
st = sorted(t)
rst = sorted(t, reverse=True)

if (len(s) < len(t)):
    if (''.join(ss) == ''.join(t[:len(s)])):
        print('Yes')
        sys.exit()
m = min(len(s), len(t))
for i in range(m):
    #print(ss[i] , rst[i])
    if (ss[i] < rst[i]):
        print('Yes')
        sys.exit()
print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	int t = x2-x1,y=y2-y1;
	cout<<x2-y<<" "<<y2+t<<" "<<x1-y<<" "<<y1+t<<endl;
	return 0;
}


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

#define Debug(x) x
typedef int regular_int;
// #define int ll
typedef long long ll;

regular_int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(12) << fixed;

	int n;
	cin >> n;
	cout << n * n * n << endl; 
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define T pair<int, int>
#define ordered_set tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    // test(){
        int n;
        cin >> n;
        string s;
        cin >> s;
        vector<set<int>> a(3);
        // 0 = R, 1 = G, 2 = B;
        for(int i=0; i<n; i++){
            if(s[i] == 'R') a[0].ins(i);
            else if(s[i] == 'G')    a[1].ins(i);
            else a[2].ins(i);
        }
        vector<int> posR(n, 0), posB(n, 0), posG(n, 0);
        s[0] == 'R'? posR[0] = 1: (s[0] == 'B'? posB[0] = 1: posG[0] = 1);
        for(int i=1; i<n; i++){ 
            posR[i] = posR[i-1];
            posB[i] = posB[i-1];
            posG[i] = posG[i-1];
            if(s[i] == 'R') posR[i]++;
            if(s[i] == 'G') posG[i]++;
            if(s[i] == 'B') posB[i]++;
        }       
        // pos for r, now i look for g and b
        int ans = 0;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(i != j){
                    for(auto x: a[i]){
                        for(auto y: a[j]){
                            if(x < y){
                                if(i+j == 1){
                                    ans += posB[y]-posB[x];
                                    if((x+y)%2 == 0 && s[(x+y)/2] == 'B'){
                                        ans--;
                                        // cerr << "here" << endl;
                                    }
                                }
                                if(i+j == 2){
                                    ans += posG[y]-posG[x];
                                    if((x+y)%2 == 0 && s[(x+y)/2] == 'G'){
                                        ans--;
                                        // cerr << "here2" << endl;
                                    }
                                }
                                if(i+j == 3){
                                    ans += posR[y]-posR[x];
                                    if((x+y)%2 == 0 && s[(x+y)/2] == 'R'){
                                        ans--;
                                        // cerr << "here3" << endl;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    // }
}

Measured memory_bytes: 3868
#include<cstdio>
#include<cstring>
const int MAXN=3010;

int n,a[MAXN];
long long f[MAXN][MAXN];

inline long long max(long long x,long long y){
	return x>y?x:y;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int len=1;len<=n;len++)
		for(int r=1;r<=n;r++){
			int l=r-len+1;
			if(l<1)
				continue;
			f[l][r]=max(a[l]-f[l+1][r],a[r]-f[l][r-1]);
		}
	printf("%lld\n",f[1][n]);
	return 0;
}

Measured memory_bytes: 70016
import java.util.*;



public class Main{

	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 int[] B=new int[N-1];
	 int[] A=new int[N];
	 for(int i=0;i<N-1;i++) {
		 B[i]=sc.nextInt();
	 }
	 A[0] = B[0];
	 A[N-1]=B[N-2];
	 if(N>=3) {
		 for(int i=1;i<N-1;i++) {
			 A[i]=Math.min(B[i-1], B[i]);
		 }
	 }
	 
	 long result= 0;
	 
	 for(int i=0;i<N;i++) {
		 result += A[i];
	 }
	 
	 System.out.println(result);
	 
	 
 }
	


}



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

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

		bool is_good = false;

		for(int i=1; i<=9; i++) {
			if (N == (111*i)) {
					is_good = true;
					break;
			}
			if ((N >= (1110*i)) && (N <= ((1110*i)+9))) {
					is_good = true;
					break;
			}
		}

		for(int i=0; i<=9; i++) {
				for(int j=1; j<=9; j++) {
					if (N == ((1000*i)+(111*j))) {
							is_good = true;
							break;
					}
				}
				if (is_good) {
						break;
				}
		}

		for(int i=1; i<=9; i++) {
			if (N == (1000*i)) {
					is_good = true;
					break;
			}
		}

		if (is_good) {
				cout << "Yes" << endl;
		} else {
				cout << "No" << endl;
		}

		return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
using namespace std;

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

    vector<vector<long long> > G(n);
    vector<pair<long long, long long> > vp;

    for(long long i = 0; i < n-1; i++){
        long long x, y;
        cin >> x >> y;
        G[x-1].push_back(y-1);
        G[y-1].push_back(x-1);
        vp.push_back(make_pair(x-1, y-1));
    }

    long long maxv = 0;

    for(long long i = 0; i < n; i++){
        maxv = max(maxv, (long long)G[i].size());
    }

    map<pair<long long, long>, long long> I;
    vector<long long> cs(n, 0);

    vector<bool> used(n, false);
    queue<long long> que;
    used[0] = true;

    que.push(0);

    while(!que.empty()){
        long long v = que.front();
        que.pop();

        long long current = 1;

        for(long long i = 0; i < G[v].size(); i++){
            if(used[G[v][i]] == true){
                continue;
            }
            if(current == cs[v]) current++;

            cs[G[v][i]] = I[make_pair(v, G[v][i])] = I[make_pair(G[v][i], v)] = current;
            current++;
            used[G[v][i]] = true;
            que.push(G[v][i]);
        }
    }

    cout << maxv << endl;

    for(long long i = 0; i < n-1; i++){
        cout << I[vp[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 24076
import java.util.Scanner;

public class Main {
   
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int W,H,x,y,r;
        W=scan.nextInt();
        H=scan.nextInt();
        x=scan.nextInt();
        y=scan.nextInt();
        r=scan.nextInt();
        if(x-r>=0 && y-r>=0 && x+r<=W && y+r<=H){
        	System.out.println("Yes");
        }
        else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 26260
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    cnt = {}
    max_num = 0
    for _ in range(N):
        s = input().rstrip('\n')
        if s not in cnt:
            cnt[s] = 1
        else:
            cnt[s] += 1
        if cnt[s] > max_num:
            max_num = cnt[s]

    ans = []
    for s in cnt:
        if cnt[s] == max_num:
            ans.append(s)
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


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

int main() {
	int n; scanf("%d", &n);
	vector<vector<int>> days(3, vector<int>(n));

	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &days[0][i], &days[1][i], &days[2][i]);
	}

	vector<vector<int>> dp(3, vector<int>(n, 0));
	dp[0][0] = days[0][0];
	dp[1][0] = days[1][0];
	dp[2][0] = days[2][0];

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				dp[j][i] = max(dp[j][i], dp[k][i - 1] + days[j][i]);
			}
		}
	}

	int ans = 0;
	ans = max({ans, dp[0].back(), dp[1].back(), dp[2].back()});
	printf("%d\n", ans);
}

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    string s;
    cin >> n >> s;
    int now = 0;
    for(int i = 0; i < n - 1; i++){
        if(s[i + 1] == 'E')
        now++;
    }
    int ans = now;
    for(int i = 1; i < n; i++){
        if(s[i] == 'E')
        now--;
        if(s[i - 1] == 'W')
        now++;
        ans = min(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 900
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        w: isize,
        a: isize,
        b: isize
    };
    use std::cmp::max;
    println!("{}", max(max(0, a - b - w), b - a - w));
}


Measured memory_bytes: 2108
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		if (N == 1) {
			System.out.println("Hello World");
		}else if(N == 2) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println(A + B);
		}
	}

}

Measured memory_bytes: 22100
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).OrderByDescending(x => x).ToArray();
            long res = 1;
            if (a.Contains(0))
            {
                Console.WriteLine("0");
                Environment.Exit(0);
            }
            try
            {
                checked
                {
                    for (int i = 0; i < a.Length; i++)
                    {
                        res *= a[i];
                        if (res > 1000000000000000000)
                        {
                            Console.WriteLine("-1");
                            Environment.Exit(0);

                        }
                    }
                }
            }
            catch (OverflowException ex)
            {
                Console.WriteLine("-1");
                Environment.Exit(0);
            }
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 44452
#include<stdio.h>

int main(void){
	int ary[3];
	int i,j,tmp;
	
	scanf("%d %d %d",&ary[0],&ary[1],&ary[2]);
	
	for (i=0; i<3; ++i) {
    	for (j=i+1; j<3; ++j) {
			if (ary[i] > ary[j]) {
				tmp =  ary[i];
				ary[i] = ary[j];
				ary[j] = tmp;
			}
		}
	}
	
	printf("%d",ary[0]+ary[1]);	
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
 
int main() {
    int m, d; cin>>m>>d;
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            if(j%10 >= 2 && (j/10) >= 2 && (j%10 * (j/10)) == i) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 4000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

const int maxn = 1e6+5;
int n, m;
struct node {
    int to, next, w;
    bool operator < (const node& a) const {
        return w > a.w;
    }
} e[maxn<<1];
int cnt, head[maxn];
void add(int u, int v, int w) {
    e[cnt] = node{v, head[u], w};
    head[u] = cnt++;
}
bool vis[maxn];
int dis[maxn];
void dij(int st, int ed) {
    priority_queue<node> q;
    memset(dis,INF,sizeof(dis));
    memset(vis,false,sizeof(vis));
    dis[st] = 0;
    q.push(node{st, 0, 0});
    while (!q.empty()) {
        node u = q.top();
        q.pop();
        if(vis[u.to]) continue;
        vis[u.to] = 1;

        for (int i = head[u.to]; ~i; i = e[i].next) {
            int to = e[i].to;
            if (dis[to] > dis[u.to] + e[i].w) {
                dis[to] = dis[u.to] + e[i].w;
                q.push(node{to, 0, dis[to]});
            }
        }
    }
    printf("%d\n", dis[ed] == INF?-1:dis[ed]/2);
}
map<int, int>mp[maxn];
void init() {
    cnt = 0;
    memset(head,-1,sizeof(head));
    for (int i = 1 ; i <= n ; i ++) {
        mp[i].clear();
    }
}
int getid(int x, int y) {
    if (!mp[x][y]) mp[x][y] = ++n;
    return mp[x][y];
}
int main() {
    while(~scanf("%d%d", &n, &m)) {
        init(); int ed = n;
        for (int i = 1 ; i <= m ; i ++) {
            int u, v, c;
            scanf("%d%d%d", &u, &v, &c);
            int uc = getid(u, c);
            int vc = getid(v, c);
            add(uc, vc, 0); add(vc, uc, 0);
            add(u, uc, 1); add(uc, u, 1);
            add(v, vc, 1); add(vc, v, 1);
        }
        dij(1, ed);
    }
    return 0;
}


Measured memory_bytes: 93556
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)

bool conccomp(int x, int y, int p, int q){
	return (p*y>x*q);
}

int main(void){
	int n,i,j,cnt[55][26],l;
	string s[55],ans;
	fill(cnt[0],cnt[55],0);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> s[i];
		for(j=(s[i].length()-1); j>=0; --j){
			cnt[i][s[i][j]-'a']++;
		}
	}
	for(j=0; j<26; ++j){
		l = INF;
		for(i=0; i<n; ++i){
			l = min(cnt[i][j],l);
		}
		for(i=0; i<l; ++i){
			ans += (char)('a'+j);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define lli long long int

lli duapangkat(lli a) {
	lli ret = 1;
	for (lli p = 0; p < a; p++)
		ret *= 2;
	return ret;
}

int main() {
	lli n, k, satu[45], ans = 0, x, zero, one, two, tempe, a;
	scanf("%lld %lld", &n, &k);
	memset(satu, 0, sizeof satu);
	for (lli i = 0; i < n; i++) {
		scanf("%lld", &a);
		x = 0;
		while (a > 0) {
			if (a & 1)
				satu[x]++;
			a /= 2;
			x++;
		}
	}
	x = 0;
	for (lli i = 39; i >= 0; i--) {
		two = duapangkat(i);
		tempe = 0;
		one = satu[i];
		zero = n - one;
		if (((x + two) <= k) && (one < zero)) {
			tempe = 1;
			x += two;
		}
		if (tempe < 1)
			ans += (one * two);
		else
			ans += (zero * two);
	}
	printf("%lld\n", ans);
	return 0;
}

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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    
	string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0;i<s.size();++i) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3900
#include <iostream>
using namespace std;
static const int N = 100;

int main() {
    int M[N][N];
    int n, u, k, v;

    cin >> n;

    for ( int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if ( j != 0 ) {cout << " ";}
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>
int main(){
  int n,k;
  scanf("%d%d", &n,&k);
  char s[n+1];
  scanf("%s", s);
  if (s[k-1] == 'A') s[k-1] = 'a';
  if (s[k-1] == 'B') s[k-1] = 'b';
  if (s[k-1] == 'C') s[k-1] = 'c';
  printf("%s", s);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  ll tmp;
  map<ll, int> amap, bmap, cmap;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    amap[tmp]++;
    bmap[tmp%M]++;
  }
  for(int i=1;i<=100000;++i) {
    cmap[i%M] += amap[i]/2;
  }
  ll ans = 0;
  for(int i=0;i<M;++i) {
    if(i>M-i) break;
    if(i==0) {
      ans += bmap[i]/2;
    }
    else if(i!=M-i) {
      if(bmap[i]>bmap[M-i]) {
        ans += bmap[M-i];
        ans += min(cmap[i], (bmap[i]-bmap[M-i])/2);
      }
      else {
        ans += bmap[i];
        ans += min(cmap[M-i], (bmap[M-i]-bmap[i])/2);
      }
    }
    else {
      ans += bmap[i]/2;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 22380
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long l = read.to!long;
	long n = read.to!long;
	
	long[] xs;
	foreach(i; 0 .. n) xs ~= read.to!long;
	
	// 右から始め、右にi本、左にj本焼いて右で終わるとする
	// このとき折り返しの回数は min(i - 1, j) を f とすると右も左も f
	// 折り返すのは i - f - 1 番から i - 2 番までと、i 番から i + f - 1 番まで
	// 折り返さないのは i - 1 番
	// sum xs[i - f - 1 .. i - 1] * 2 + xs[i - 1] + l * f * 2 - sum xs[i .. i + f] * 2
	
	// 左から始め、右にi本、左にj本焼いて左で終わるとする
	// このとき折り返しの回数は min(i, j - 1) を f とすると右も左も f
	// 折り返すのは i - f 番から i - 1 番までと、i + 1 番から i + f 番まで
	// 折り返さないのは i 番
	// sum xs[i - f .. i] * 2 + (l - xs[i]) + l * f * 2 - sum xs[i + 1 .. i + f + 1] * 2
	
	// 左から始め、右にi本、左にj本焼いて右で終わるとする
	// このとき折り返しの回数は min(i, j) を f とすると右は f - 1 で左は f
	// 折り返すのは i - f 番から i - 2 番までと、i 番から i + f - 1 番まで
	// 折り返さないのは i - 1 番
	// sum xs[i - f .. i - 1] * 2 + xs[i - 1] + l * f * 2 - sum xs[i .. i + f] * 2
	
	// 右から始め、右にi本、左にj本焼いて左で終わるとする
	// このとき折り返しの回数は min(i, j) を f とすると右は f で左は f - 1
	// 折り返すのは i - f 番から i - 1 番までと、i + 1 番から i + f - 1番まで
	// 折り返さないのは i 番
	// sum xs[i - f .. i] * 2 + (l - xs[i]) + l * f * 2 - sum xs[i + 1 .. i + f] * 2
	
	long[] sum = [0]; // sum[i] は0からiの前までの和
	foreach(i; 0 .. n) sum ~= sum[$ - 1] + xs[i];
	
	long ans = -1;
	foreach(i; 1 .. n + 1){
		long j = n - i;
		long f = min(i - 1, j);
		long a = (sum[i - 1] - sum[i - f - 1]) * 2 + xs[i - 1] + l * f * 2 - (sum[i + f] - sum[i]) * 2;
		if(a > ans) ans = a;
		debug writeln("i: ", i);
		debug writeln("a: ", a);
		debug writeln("ans: ", ans);
	}
	foreach(i; 0 .. n){
		long j = n - i;
		long f = min(i, j - 1);
		long a = (sum[i] - sum[i - f]) * 2 + (l - xs[i]) + l * f * 2 - (sum[i + f + 1] - sum[i + 1]) * 2;
		if(a > ans) ans = a;
		debug writeln("i: ", i);
		debug writeln("a: ", a);
		debug writeln("ans: ", ans);
	}
	foreach(i; 1 .. n){
		long j = n - i;
		long f = min(i, j);
		long a = (sum[i - 1] - sum[i - f]) * 2 + xs[i - 1] + l * f * 2 - (sum[i + f] - sum[i]) * 2;
		if(a > ans) ans = a;
		debug writeln("i: ", i);
		debug writeln("a: ", a);
		debug writeln("ans: ", ans);
	}
	foreach(i; 1 .. n){
		long j = n - i;
		long f = min(i, j);
		long a = (sum[i] - sum[i - f]) * 2 + (l - xs[i]) + l * (f - 1) * 2 - (sum[i + f] - sum[i + 1]) * 2;
		if(a > ans) ans = a;
		debug writeln("i: ", i);
		debug writeln("a: ", a);
		debug writeln("ans: ", ans);
	}
	
	ans.writeln;
}


Measured memory_bytes: 4988
#include "bits/stdc++.h"
using namespace std;

const int maxn = 1e5;

int n;

int type[maxn];;

inline int query(int x) {
    printf("%d\n", x);
    fflush(stdout);
    char ans[10];
    scanf(" %s", ans);
    if(ans[0] == 'M') return 0;
    if(ans[0] == 'F') return 1;
    if(ans[0] == 'V') return 2;
}

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

    for(int i = 0; i < n; ++i) type[i] = -1;

    int l = 0;
    int r = n - 1;

    type[l] = query(l);
    if(type[l] == 2) return 0;
    type[r] = type[l] ^ 1;
    type[l + 1] = type[l] ^ 1;

    while(l < r) {
	int mid = (l + r) >> 1;
	type[mid] = query(mid);
	if(type[mid] == 2) return 0;

	if(type[mid - 1] == -1) type[mid - 1] = type[mid] ^ 1;
	if(type[mid + 1] == -1) type[mid + 1] = type[mid] ^ 1;
	if((mid - l) % 2 == 0) {
	    if(type[mid] != type[l]) r = mid - 1;
	    else l = mid + 1;
	}
	else {
	    if(type[mid] != type[l]) l = mid + 1;
	    else r = mid - 1;
	}
    }

    query(l);

    return 0;
}


Measured memory_bytes: 1236
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>


int main(){
	int n, l, max=0, sum=0;
	scanf("%d\n", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &l);
		sum += l;
		if(l>max) max = l;
	}
	sum -= max;
	if(max < sum)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n,y; cin>>n>>y;
  rep(i,n+1){
    for(int j=0;i+j<=n;j++){
      int k=n-i-j;
      int sum=10000*i+5000*j+1000*k;
      if(sum==y){
        cout<<i<<" "<<j<<" "<<k<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int retu,gyou,A[100][100],sum=0,i,j,almost=0;

  scanf("%d %d",&gyou,&retu);
  for(i=0;i<gyou;i++){
    for(j=0;j<retu;j++){
      scanf("%d",&A[i][j]);
      almost+=A[i][j];
    }
  }
  for(i=0;i<gyou;i++){
    for(j=0;j<retu;j++){
      printf("%d ",A[i][j]);
      sum+=A[i][j];
    }
    printf("%d\n",sum);
    sum = 0;
  }

  for(j=0;j<retu;j++){
    for(i=0;i<gyou;i++){
      sum += A[i][j];
    }
    printf("%d ",sum);
    sum = 0;
  }
  printf("%d\n",almost);
  return 0;
}



Measured memory_bytes: 2100
import sys
from collections import deque

H,W=map(int,input().split())
si,sj=[int(x)-1 for x in input().split()]
ti,tj=[int(x)-1 for x in input().split()]
A=[[*next(sys.stdin)] for _ in range(H)]

N=-1
for i in range(H):
    for j in range(W):
        if A[i][j]!='.':
            continue
        N+=1
        stk=[(i,j)]
        while stk:
            ii,jj=stk.pop()
            A[ii][jj]=N
            for ni,nj in (ii-1,jj),(ii,jj+1),(ii+1,jj),(ii,jj-1):
                if not (0<=ni<H and 0<=nj<W):
                    continue
                if A[ni][nj]!='.':
                    continue
                stk.append((ni,nj))

s=t=-1
dirs=[-2,-1,0,1,2]
adj=[{*()} for _ in range(N+1)]
for i in range(H):
    for j in range(W):
        u=A[i][j]
        if u=='#':
            continue
        if i==si and j==sj:
            s=u
        elif i==ti and j==tj:
            t=u
        for di in dirs:
            for dj in dirs:
                if di==dj==0:
                    continue
                ni,nj=i+di,j+dj
                if not (0<=ni<H and 0<=nj<W):
                    continue
                v=A[ni][nj]
                if v=='#':
                    continue
                if u!=v:
                    adj[u].add(v)
                    adj[v].add(u)

que=deque()                
que.append(s)
vis={s}
m=-1
ok=False
while que:
    m+=1
    for _ in range(len(que)):
        u=que.popleft()
        if u==t:
            ok=True
            break
        for v in adj[u]:
            if v in vis:
                continue
            vis.add(v)
            que.append(v)
    if ok:
        break

if ok:
    print(m)
else:
    print(-1)


Measured memory_bytes: 201324
#include <stdio.h>
 
int main() {
    int day_num[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int m, d;
    char name[7][16] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
 
    int day_count;
    int i;
 
    while(1) {
        day_count = 0;
        scanf("%d %d", &m, &d);
        if(m == 0) break;
 
        for(i = 0; i < m - 1; i++)
            day_count += day_num[i];
 
        day_count += d;
 
        printf("%s\n", name[day_count % 7]);
    }
 
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i] >> p[i];
    
    const ll inf = 5e18;
    auto xcost = make_vec<ll>(1<<n, n);
    fill_v<ll>(xcost, inf);
    auto ycost = xcost;

    rep(i, 1<<n) {
        rep(j, n) {
            xcost[i][j] = abs(x[j]);
            ycost[i][j] = abs(y[j]);
        }
        rep(j, n) rep(k, n) if (i >> k & 1) {
            chmin(xcost[i][j], (ll)abs(x[j] - x[k]));
            chmin(ycost[i][j], (ll)abs(y[j] - y[k]));
        }
    }

    vector<ll> ans(n+1, inf);
    
    rep(i, 1<<n) {
        int cnt = __builtin_popcount(i);
        for (int j = i; j >= 0; --j) {
            j &= i;
            ll cost = 0;
            rep(k, n) {
                if (!(i >> k & 1)) cost += 1LL * p[k] * min(xcost[j][k], ycost[i-j][k]);
            }
            chmin(ans[cnt], cost);
        }
    }

    rep(i, n+1) cout << ans[i] << endl;
}


Measured memory_bytes: 12928