akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<string> s(N);
  cin >> s;
  int ans = 0;
  int X = 0, Y = 0, Z = 0;
  for (string &str : s) {
    for (int i = 0; i + 1 < str.size(); i++) {
      if (str.substr(i, 2) == "AB") ans++;
    }
    if (str[0] == 'B' && str[str.size() - 1] == 'A')
      X++;
    else if (str[str.size() - 1] == 'A')
      Y++;
    else if (str[0] == 'B')
      Z++;
  }
  if (Y + Z == 0) {
    ans += max(0, X - 1);
  } else if (Y == 0 || Z == 0) {
    ans += X;
  } else {
    ans += min(Y - 1, Z - 1) + X + 1;
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


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

int main() {
  string N;
  
  cin >> N;
 
  if( (N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]) )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

int main() {
    while (true) {
        int n, r, a[50];

        cin >> n >> r;
        if ( n == 0 && r == 0) { break; }

        for (int i = 0; i < n; i++) {
            a[i] = n-i;
        }

        for (int i = 0; i < r; i++) {
            int p, c;
            cin >> p >> c;
            rotate(a, a+p-1, a+p+c-1);
        }

        cout << a[0] << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int[] res = new int[20];
        long[] a = new long[1];
        int pos = 0;
        for(int i=1; i<=20; i++) {
            pos = dfs(i, 0, 0, pos, res, a, k);
            if(pos == k) {
                System.out.println(a[0]);
                return;
            }
        }
    }

    static int dfs(int n, int d, int prev, int pos, int[] res, long[] a, int k) {
        if(n == d) {
            //System.out.println(pos + 1 + "" + Arrays.toString(res));
            pos++;
            if(pos == k) {
                long q = 0;
                for(int i=0; i<n; i++) {
                    q *= 10;
                    q += res[i];
                }
                a[0] = q;
            }
            return pos;
        }
        if(d==0) {
            for(int i=1; i<=9; i++) {
                res[d] = i;
                pos = dfs(n, d+1, i, pos, res, a, k);
                if(pos == k) return pos;
            }
        } else {
            for(int i=Math.max(prev-1, 0); i<=Math.min(prev+1, 9); i++) {
                res[d] = i;
                pos = dfs(n, d+1, i, pos, res, a, k);
                if(pos == k) return pos;
            }
        }
        return pos;
    }

}

Measured memory_bytes: 23508
/*author:revolIA*/
/*明日を変えるなら今日変えなきゃ*/
#include<bits/stdc++.h>
#define pi 3.1415926535
using namespace std;
const int maxn = 1e6+7;
int a,b,x;
int main(){
    scanf("%d%d%d",&a,&b,&x);
    double ans;
    if(a*a*b>2*x){
        ans = atan(a*b*b/(x*2.0))*180/pi;
    }else{
        ans = atan(2.0*(a*a*b-x)/(a*a*a))*180/pi;
    }
    printf("%.9f\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
  
int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  int sum = 0;
  int max = 0;
  for(int i=0;i<N;i++){
    sum += L[i];
    if(max < L[i]){
      max = L[i];
    }
  }
  if(max>=sum-max){
    cout << "No\n";
  }else{
    cout << "Yes\n";
  }
}


Measured memory_bytes: 256
s = input()
ret = True
for i in range(len(s)//2 - 1):
    if s[i] != s[len(s)-1-i]:
        ret = False
        break
    if s[i] != s[len(s)//2 -1 -i]:
        ret = False
        break
if ret:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  $a[$i] = intval(fgets(STDIN));
}
$sum = 0;
$a[-1] = 0;
for($i = 0; $i < $n; $i++){
  $s = $a[$i-1] + $a[$i];
  $add = intdiv($s,2); 
  if($add > 0){
    $a[$i] -= $add * 2 - $a[$i-1];
  }
  $sum+=$add;
}
printf("%d\n", $sum);


Measured memory_bytes: 12788
import java.io.IOException;
import java.util.Scanner;

/**
 * 選択ソート
 * 
 *
 */

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = s.nextInt();
		}
		
		selectionSort(arr, n);
		
	}
	
	public static void selectionSort(int[] arr, int n) {
		int count = 0;
		for (int i = 0; i < n; i++) {
			int minj = i;
			for (int j = i; j < n; j++) {
				if (arr[j] < arr[minj]) {
					minj = j;
				}
			}
			if (i != minj) {
				count++;
			}
			int tmp = arr[i];
			arr[i] = arr[minj];
			arr[minj] = tmp;
		}
		printArray(arr);
		System.out.println(count);
	}
	
	public static void printArray(int[] arr) {
		String ans = "";
		for (int i = 0; i < arr.length; i++) {
			ans += arr[i] + " ";
		}
		System.out.println(ans.trim());
	}
}


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

using namespace std;

int A[100];
constexpr int maxidx=8;

int coloridx(int rate){
  return min(maxidx,rate/400);
}

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> A[i];
  }
  
  int ratemap[maxidx+1]={0};
  for(int i=0;i<N;++i){
    ratemap[coloridx(A[i])]++;
  }
  
  int colornum = 0;
  for(int i=0;i<maxidx;++i){
    if(ratemap[i]>0) colornum++;
  }

  if(colornum==0){
    cout << 1 << " ";
  }else{
    cout << colornum << " ";
  }
  
  cout << colornum+ratemap[maxidx] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int a, b;
  
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }else{
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;
	
	string ans;
	for(;n>0; n/=26){
		n--;
		ans += char('a' + n%26);
	}
	reverse(all(ans));
	cout << ans <<"\n";
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

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

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int a,b;
	cin>>a>>b;
	if(a==1)
	{
		if(b==1)
			cout<<"Draw";
		else
			cout<<"Alice";
	}
	else if(b==1)
	{
		cout<<"Bob";
	}
	else
	{
		if(a>b)
			cout<<"Alice";
		else if(a<b)
			cout<<"Bob";
		else
			cout<<"Draw";
	}
	return 0;	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String str = sc.next();
			int [][] data = new int[3][3];
			for(int i = 0; i < str.length(); i++){
				int iind = i / 3;
				int jind = i % 3;
				char c = str.charAt(i);
				switch(c){
				case 'o':
					data[iind][jind] = 1;
					break;
				case 'x':
					data[iind][jind] = 0;
					break;
				case 's':
					data[iind][jind] = -1;
				}
			}
			String ans = "";
			if(data[0][0] == data[1][0]  && data[1][0] == data[2][0]){
				if(data[0][0] == 0){
					ans = "x";
				}
				else if (data[0][0] == 1){
					ans = "o";
				}
			}
			if(data[0][0] == data[0][1]  && data[0][1] == data[0][2]){
				if(data[0][0] == 0){
					ans = "x";
				}
				else if(data[0][0] == 1){
					ans = "o";
				}
			}
			if(data[0][2] == data[1][2]  && data[1][2] == data[2][2]){
				if(data[2][2] == 0){
					ans = "x";
				}
				else if(data[2][2] == 1){
					ans = "o";
				}
			}
			if(data[2][0] == data[2][1]  && data[2][1] == data[2][2]){
				if(data[2][2] == 0){
					ans = "x";
				}
				else if(data[2][2] == 1){
					ans = "o";
				}
			}
			if(data[0][0] == data[1][1]  && data[1][1] == data[2][2]){
				if(data[2][2] == 0){
					ans = "x";
				}
				else if(data[2][2] == 1){
					ans = "o";
				}
			}
			if(data[0][2] == data[1][1]  && data[1][1] == data[2][0]){
				if(data[0][2] == 0){
					ans = "x";
				}
				else if(data[0][2] == 1){
					ans = "o";
				}
			}
			if(data[1][0] == data[1][1]  && data[1][1] == data[1][2]){
				if(data[1][1] == 0){
					ans = "x";
				}
				else if(data[1][1] == 1){
					ans = "o";
				}
			}
			if(data[0][1] == data[1][1]  && data[1][1] == data[2][1]){
				if(data[1][1] == 0){
					ans = "x";
				}
				else if(data[1][1] == 1){
					ans = "o";
				}
			}
			if(ans.length() == 0){
				ans = "d";
			}
			System.out.println(ans);
		}
		
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int2(H, W);
    int2(h, w);

    if (H % h) {
        std::cout << "Yes" << std::endl;
        vi ans(H+1, 0);
        ans[H] = 1;
        for (int i = H-h; i > 0; i -= h) {
            ans[i] = ans[i+h]+1;
        }
        rep(i, H) {
            if (!ans[i]) ans[i] = -(i / h);
        }
        for (int i = H; i > 0; i--) {
            ans[i] = ans[i] - ans[i-1];
        }
        Rep(i, ans.size()) {
            rep(j, W) {
                std::cout << ans[i] << " ";
            }
            cout << endl;
        }
    } else if (W % w) {
        std::cout << "Yes" << std::endl;
        vi ans(W+1, 0);
        ans[W] = 1;
        for (int i = W-w; i > 0; i -= w) {
            ans[i] = ans[i+w]+1;
        }
        rep(i, W) {
            if (!ans[i]) ans[i] = -(i / w);
        }
        for (int i = W; i > 0; i--) {
            ans[i] = ans[i] - ans[i-1];
        }
        rep(i, H) {
            Rep(j, ans.size()) {
                std::cout << ans[j] << " ";
            }
            cout << endl;
        }
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_N 100
using namespace std;
int n;
int d[MAX_N];

struct edge {
	int to, cost;
	edge(int to_, int cost_) : to(to_), cost(cost_) {}
};
typedef pair<int, int> P;
vector<edge> G[MAX_N];

void Dijkstra(int start) {
	fill(d, d + n, INF);
	priority_queue<P, vector<P>, greater<P>> que;
	d[start] = 0;
	que.push(P(0, start));

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

int main()
{
	cin >> n;
	for (int i = 0, u, k; i < n; i++) {
		cin >> u >> k;
		for (int j = 0, v, c; j < k; j++) {
			cin >> v >> c;
			G[u].push_back(edge(v, c));
		}
	}
	Dijkstra(0);
	for (int i = 0; i < n; i++) {
		cout << i << ' ' << d[i] << endl;
	}
	return 0;
}

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

void intervals(int max, vector<int>& G) {
    int g = 1;
    while (g <= max) {
        G.push_back(g);
        g = 3 * g + 1;
    }
}

int insertionSort(int N, int A[], int g) {
    int n_swapped = 0;
    for (int i = g; i < N; i++) {
        int v = A[i];
        int iBef = i - g;
        while (0 <= iBef && v < A[iBef]) {
            A[iBef + g] = A[iBef];
            iBef -= g;
            n_swapped++;
        }
        A[iBef + g] = v;
    }
    return n_swapped;
}

int shellSort(int N, int A[], vector<int>& G) {
    int n_swapped = 0;
    for (int i = G.size() - 1; i >= 0; i--) {
        n_swapped += insertionSort(N, A, G[i]);
    }
    return n_swapped;
}

/* ALDS1_2_D: Shell Sort */
int main() {
    int N;
    cin >> N;

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

    vector<int> G;
    intervals(N, G);

    int n_swapped = shellSort(N, A, G);

    cout << G.size() << endl << G.back();
    for (int i = G.size() - 2; i >= 0; i--)
        cout << " " << G[i];
    cout << endl;

    cout << n_swapped << endl;
    for (int i = 0; i < N; i++)
        cout << A[i] << endl;

    return 0;
}

Measured memory_bytes: 5120
x = int(input())
if x<=11:
  if x<=6:
    print(1)
  else:
    print(2)
else:
  tmp = x//11
  tmp2 = x%11
  if tmp2==0:
    print(2*tmp)
  elif tmp2<=6:
    print(2*tmp+1)
  else:
    print(2*tmp+2)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readb(n, k);
	int ans = 0;
	FOR (i, k, n + 1)
	    ans = (ans + n*(n + 1)/2 - (n - i + 1)*(n - i)/2 - i*(i - 1)/2 + 1) % mod;
	
	print(ans);
}









Measured memory_bytes: 3608
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string X = Console.ReadLine();
            var str = X.Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);

            Console.WriteLine(x + (y / 2));
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
const int N=1e5+50;
int n,vis[N],ans,x;
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		ans+=vis[x];
		vis[x]=1;
	}
	printf("%d\n",n-(ans+1)/2*2);
}

Measured memory_bytes: 512
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()

cut = 1
ans = 0

for i in range(cut, len(S) - 1):
    left = []
    right = []

    for c in range(len(S)):
        if (c < i):
            left.append(S[c])
        else:
            right.append(S[c])

    all_len = len(set(left) & set(right))
    if (all_len > ans):
        ans = all_len

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (auto&& u : d) cin >> u;
  sort(begin(d), end(d));
  int x = d[n / 2] - d[n / 2 - 1];
  cout << x << endl;
}

Measured memory_bytes: 1024
import heapq
INF = 100000000000000

def make_adj_list(v):
    adj_list = []
    for i in range(v):
        adj_list.append([])
    return adj_list

def dijkstra(v, e, adj_list, s):
    heap = []
    d = []
    pre = []
    for i in range(v):
        d.append(INF)
        pre.append(s)
    d[s] = 0
    heapq.heappush(heap, (0, s))
    while len(heap) != 0:
        candidate_d, now_v = heapq.heappop(heap)
        if d[now_v] < candidate_d:
            continue
        for v, cost in adj_list[now_v]:
            if d[v] > d[now_v] + cost:
                d[v] = d[now_v] + cost
                heapq.heappush(heap,(d[v], v))
                pre[v] = now_v
    return d, pre

def main():
    v, e, s = map(int, input().split())
    adj_list = make_adj_list(v)
    for i in range(e):
        a = [int(i) for i in input().split()]
        adj_list[a[0]].append((a[1], a[2]))
        
    d, pre = dijkstra(v, e, adj_list, s)

    for i in range(v):
        if d[i] == INF:
            print("INF")
        else:
            print(d[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 90048
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string a, b, c; cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <time.h>
#include <bits/stdc++.h>

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const ll INF=1e18+5;
int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    IO;
    int n ,w;
    cin>>n>>w ;
    pair<ll , ll > arr[n+1];
    ll all=0;
    for (int i = 0; i<n; ++i) {
        cin>>arr[i].first>>arr[i].second;
        all+=arr[i].second;
    }
    vector<ll> values (all+2,INF);
    values[0]=0;
    for(int i =0 ;i < n ; i++){
        vector<ll> temp_values=values;

        for(int j = 0 ; j+arr[i].second<=all; j++){
           temp_values[j+arr[i].second]=min(values[j+arr[i].second],values[j]+arr[i].first);
        }
        values=temp_values;
    }
    ll ans=0;
    for(int i =all ;i>=0 ;i--){
        if(values[i]<=w){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Ele = struct{
  int a;
  long b;
};

//昇順
int acs(const void *x, const void *y)
{
  return ((Ele *)x)->a - ((Ele *)y)->a;
}

int main() {
  long N, K;
  cin >> N >> K;
  Ele a[N];
  for (int i=0; i<N; i++)
    cin >> a[i].a >> a[i].b;
  qsort(a, N, sizeof(Ele), acs);
  long cnt = 0;
  int i;
  for (i=0; i<N; i++) {
    cnt += a[i].b;
    if (cnt >= K)
      break;
  }
  cout << a[i].a << endl;
  return 0;
}

Measured memory_bytes: 3324
X, N = map( int, input().split() )
p = list( map(int, input().split()) )

y_min = 101 - X
ans = 101

for i in range(0,101):
    x = 100 - i 
    
    if x in p:
        continue

    y = abs( X - x )

    if y_min >= y:
        y_min = y
        ans = x
        
print(ans)





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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a) cout << k << endl;
    else if(k > a && k <= a + b) cout << a << endl;
    else cout << ((k - (a + b)) * (-1) + a) << endl;
}

Measured memory_bytes: 3636
#coding:utf-8
import math
import string
import time
import fractions

s = raw_input()

if len(s) < 5:
	print 'NO'

else:
	while True:
		tmp = len(s)
		if s[-6:] == 'eraser':
			s = s[:-6]
		elif s[-7:] == 'dreamer':
			s = s[:-7]
		elif s[-5:] == 'dream' or s[-5:] == 'erase':
			s = s[:-5]

		if tmp == len(s):
			print 'NO'
			break
		if len(s) == 0:
			print 'YES'
			break


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};

int main(){
  int n,k;cin>>n>>k;
  ll dp[2][k+10];
  ll sum[2][k+10];
  for(int i=0;i<k+10;i++)sum[1][i]=sum[0][i]=dp[0][i]=dp[1][i]=0;
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    // cout<<(i+1)%2<<endl;
    ll hoge;cin>>hoge;
    sum[(i+1)%2][0]=dp[(i+1)%2][0]%MOD;
    for(ll j=1;j<=k;j++){
      sum[(i+1)%2][j]=sum[(i+1)%2][j-1]+dp[(i+1)%2][j];
      sum[(i+1)%2][j]%=MOD;
      //cout<<sum[(i+1)%2][j]<<" ";
    }
    //sum[(i+1)%2][k+1]=sum[(i+1)%2][k]%MOD;
    // cout<<endl;
    for(ll j=0;j<=k;j++){
      if(j==min(j,hoge))dp[i%2][j]=sum[(i+1)%2][j]%MOD;
      else dp[i%2][j]=(sum[(i+1)%2][j]-sum[(i+1)%2][j-min(hoge,j)-1])%MOD;
      //cout<<dp[(i+1)%2][j]<<" ";
    }
    //cout<<endl;
  }
  cout<<(dp[n%2][k]%MOD+MOD)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <cstdlib>
#include <typeinfo>

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

void trace(int A[], int N) {
  for (int i = 0; i < N; ++i) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

string str_tolower(string s) {
  transform(s.begin(), s.end(), s.begin(),
            [](unsigned char c) { return tolower(c); });
  return s;
}

double deg2rad(double deg) {
  return deg * M_PI / 180; // 2πラジアン = 360度
}

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

int a, b, C;

int main() {
  cin >> a >> b >> C;

  double c = sqrt(
      pow(a, 2)
      +
      pow(b, 2)
      -
      2 * a * b * cos(deg2rad(C))
  );

  double S = ((double) a * b) / 2 * sin(deg2rad(C));
  printf("%f\n", S);

  double L = a + b + c;
  printf("%f\n", L);

  // S = a * h / 2
  // 2S = a * h
  // 2S / a = h
  double h = 2 * S / a;
  printf("%f\n", h);
}



Measured memory_bytes: 3332
#include<stdio.h>
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main(){
    vector<int> v(5,0); 
    int k;
    bool flag = true;
    for(int i = 0;i< 5;i++ ){
        cin >> v.at(i) ;
    }
    cin >> k ;
    for (int i = 0;i < v.size();i++){
        for (int j = 0;j < v.size() ; j++){
          // cout << abs(v.at(i) - v.at(j)) << endl;
            if(abs(v.at(i) - v.at(j)) > k){
                flag = false;
                break;
                
            }
        }
    }
    if (flag){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}




Measured memory_bytes: 256
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

import heapq
def solve(N, M, A):
    pq = [-x for x in A]
    heapq.heapify(pq)

    for _ in xrange(M):
        x = -heapq.heappop(pq)
        x /= 2
        heapq.heappush(pq, -x)
    return -sum(pq)


N, M = rrm()
print solve(N, M, rrm())


Measured memory_bytes: 42996
#include<bits/stdc++.h>
using namespace std;
int a[26][100005];
int num[26];
int main()
{
    string n,m;
    cin>>n>>m;
    memset(a,-1,sizeof(a));
    memset(num,-1,sizeof(num));
	int len=n.length();
	unsigned long long ans=len;
    for(int i=0;i<len;++i){
    	if(n[i]==m[0])	ans=min((int)ans,i);
		for(int j=num[n[i]-'a']+1;j<=i;++j){
			a[n[i]-'a'][j]=i;
		}
		num[n[i]-'a']=i;
	}
    for(int i=0;i<m.length();++i){
    	if(num[m[i]-'a']==-1){
    		cout<<-1;return 0;
		}
		if(a[m[i]-'a'][ans%len]==-1){
			ans=(ans/len+1)*len+a[m[i]-'a'][0];
		}
		else{
			ans=a[m[i]-'a'][ans%len]+ans/len*len;
		}++ans;
	}
	cout<<ans;
}

Measured memory_bytes: 10752
#include <stdio.h>
int main(void)
{
  int a,b,c,i=0;
  //printf("整数A,B,Cを入力してください(A,B,Cはいずれも 1以上 9以下の整数)");
  do{
    scanf("%d",&a);
  }while(a<1 || 9<a);
  do{
    scanf("%d",&b);
  }while(b<1 || 9<b);
  do{
    scanf("%d",&c);
  }while(c<1 || 9<c);
  if(a==b)
    i++;
  if(b==c)
    i++;
  if(c==a)
    i++;
  if(i==1)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const long double EPS = 1e-14;
const int maxn = 100500;
const int mod = 1e9 + 7;
vector < int > a;
int n, k, q;

bool can(int x, int y){
    int ans = 0;
    for(int i = 0 ; i < n ; ++i){
        if(a[i] < x) continue;
        int j = i, cnt = 0;
        while(j < n && a[j] >= x){
            cnt += a[j] <= y;
            ++j;
        }
        ans += max(0LL, min(j - i - k + 1, cnt));
        i = j - 1;
    }
    return ans >= q;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k >> q;
    a.resize(n);
    vector < int > al;
    for(auto &x : a) cin >> x, al.push_back(x);
    sort(all(al));
    al.erase(unique(all(al)), al.end());
    int ans = 1e18;
    for(int i = 0 ; i < sz(al) ; ++i){
        int lo = i, hi = sz(al) - 1;
        while(lo <= hi){
            int mid = (lo + hi) >> 1;
            if(can(al[i], al[mid])) hi = mid - 1;
            else lo = mid + 1;
        }
        if(hi < sz(al) - 1) ans = min(ans, al[hi + 1] - al[i]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main()
{
    ll x, y;

    cin >> x >> y;
    if (y % 2 == 0 && 2 * x <= y && y <= 4 * x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
n,m=map(int,input().split())
a=list(map(int,input().split()))
info=[]
for i in range(m):
    b,c=map(int,input().split())
    info.append([c,b])
a=sorted(a) #小さい順に
info=sorted(info,reverse=True)
b=[] #n枚まで、大きい順に変えられるやつを記録
total=0
def add(num,s):
    global b
    for i in range(s):
        b.append(num)
        
for i in range(m):
    total+=info[i][1]
    if n<=total:
        total-=info[i][1]
        add(info[i][0],n-total)
        break
    add(info[i][0],info[i][1])
l=len(b)
ans=0
for i in range(n):
    if i<=l-1:
        ans+=max(a[i],b[i])
    else:
        ans+=a[i]
print(ans)

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

int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  
  int count = 0;
  
  //500円玉での払い方
  for(int i = 0; i <= A; i++){
    //100円玉での払い方  
    for(int j = 0; j <= B; j++){
      //50円玉での払い方
      for(int k = 0; k <= C; k++){
        
        if (X == ((500 * i) + (100 * j) + (50 * k))){
          count++;
        }

      }
    }
  }
  
  cout << count << endl;
  
}
  
 

Measured memory_bytes: 3576
from sys import stdin
def input():
    return stdin.readline().strip()

import heapq

def main():
    h, w, k = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())

    # surround the square with '@'
    c = [['@'] * (w+2)]
    for _ in range(h):
        i = list('@' + input() + '@')
        c.append(i)
    c.append(['@'] * (w+2))

    # Dijkstra
    # seen[x][y] = the minimum cost of (x, y)
    # if seen[x][y] == -1, (x, y) is unresearched
    seen = [[-1] * (w+2) for _ in range(h+2)]

    # todo[i] == (cost, x, y, direction)
    todo = [(0, x1, y1, 0)]
    heapq.heapify(todo)

    # direction
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]

    while len(todo) > 0:
        cost, xi, yi, direction = heapq.heappop(todo)

        # only straight
        if seen[xi][yi] != -1:
            if (seen[xi][yi]+k-1)//k * k > cost:
                xj, yj = xi + dx[direction], yi + dy[direction]
                if c[xj][yj] == '.':
                    heapq.heappush(todo, (cost+1, xj, yj, direction))
            continue
        seen[xi][yi] = cost

        # goal
        if xi == x2 and yi == y2:
            print((cost+k-1)//k)
            exit()
        
        # 4 directions
        for j in range(4):
            xj, yj = xi + dx[j], yi + dy[j]
            if c[xj][yj] == '.':
                if j == direction:
                    if seen[xj][yj] == -1 or (seen[xj][yj]+k-1)//k * k > cost:
                        heapq.heappush(todo, (cost+1, xj, yj, j))
                elif seen[xj][yj] == -1:
                    heapq.heappush(todo, ((cost+k-1)//k * k + 1, xj, yj, j))

    print(-1)

main()

Measured memory_bytes: 189332
D=int(input())
c=list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]
t= [int(input()) for i in range(D)]
v=0
LD=[0]*26

for i in range(D):
  v+=s[i][t[i]-1]
  LD[t[i]-1]=i+1  
  for j in range(26):
    v-=c[j]*(i+1-LD[j])
  print(v)

Measured memory_bytes: 9268
unittest
{
	assert( [ "3", "011" ].solve == "2\n1\n1" );
	assert( [ "23", "00110111001011011001110" ].solve == "2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3" );
	
	assert( [ "3", "000" ].solve == "1\n1\n1" );		// 追加ケース
	assert( [ "3", "100" ].solve == "0\n1\n2" );		// 追加ケース
	assert( [ "3", "111" ].solve == "2\n2\n1" );		// 追加ケース
}



import core.bitop;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto x = input.front.to!( dchar[] );
	
	// 立っているビットをカウント
	auto px = x.count( '1' );
	
	// x % ( x._popcnt - 1 ) を計算
	auto pm = px - 1;
	auto rms = new long[ n ];
	auto rmt = 0L;
	if( 0 < pm )
	{
		for( auto i = 0L, r = 1L % pm; i < rms.length; i++, r = ( r << 1 ) % pm )
		{
			rms[ i ] = r;
			if( x[ n - 1 - i ] == '1' ) rmt = ( rmt + r ) % pm;
		}
	}
	
	// x % ( x._popcnt + 1 ) を計算
	auto pp = px + 1;
	auto rps = new long[ n ];
	auto rpt = 0L;
	for( auto i = 0L, r = 1L % pp; i < rps.length; i++, r = ( r << 1 ) % pp )
	{
		rps[ i ] = r;
		if( x[ n - 1 - i ] == '1' ) rpt = ( rpt + r ) % pp;
	}
	
	// f(xi)を計算
	auto anss = new long[ n ];
	foreach( i, ref ans, b; lockstep( anss, x ) )
	{
		// 一回目の計算（xが64bitに収まらないので事前計算＋ビット反転箇所の差分で計算）
		auto r = 0L;
		if( b == '1' )
		{
			if( pm == 0 ) continue;
			r = ( rmt - rms[ $ - 1 - i ] + pm ) % pm;
		}
		else
		{
			r = ( rpt + rps[ $ - 1 - i ] ) % pp;
		}
		ans++;
		
		// 二回目以降の計算
		for( auto p = r._popcnt; 0 < r; p = r._popcnt, r %= p )
		{
			ans++;
		}
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 15692
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int BIT_FLAG_0 = (1<<0);
const unsigned int BIT_FLAG_1 = (1<<1);
const unsigned int BIT_FLAG_2 = (1<<2);
const unsigned int BIT_FLAG_3 = (1<<3);
const unsigned int BIT_FLAG_4 = (1<<4);
const unsigned int BIT_FLAG_5 = (1<<5);
const unsigned int BIT_FLAG_6 = (1<<6);
const unsigned int BIT_FLAG_7 = (1<<7);


#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;



int main(void){
  int n,k;
  string S;
  cin>>n;
  cin>>S;
  cin>>k;
  char temp=S[k-1];
  FOR(i,0,S.length() ){
    if(S[i]!=temp){S[i]='*';}
    
  }

  cout<<S<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char c[MAXN];

void solve(){
	scanf("%s", &c[0]);
	for(int i = 1; c[i]; i++){
		if (c[i] == c[i - 1]){
			printf("%d %d\n", i, i + 1);
			return;
		}
		if (i > 1 && c[i] == c[i - 2]){
			printf("%d %d\n", i - 1, i + 1);
			return;
		}
	}
	printf("-1 -1\n");
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        line = line.concat(line);
        String pattern = sc.nextLine();
        if(line.contains(pattern)) System.out.println("Yes");
        else System.out.println("No");
        
   
    }
}


Measured memory_bytes: 26264
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::{min,max};

#[fastout]
fn main() {
    input! {
        n: usize,
        c: Chars,
    }

    let mut lw : i32= 0;
    let mut rr = c.iter().filter(|&&x| x == 'R').count() as i32;
    let mut ans : i32= min(rr, n as i32-rr);
    for i in 0..n{
        if c[i] == 'W'{
            lw += 1;
        }else{
            rr -= 1;
        }
        let tmp = max(lw,rr);
        // println!("lw {}, rr {} tmp {}",lw,rr,tmp);
        ans = min(tmp,ans);
    }

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


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

int main(){
	int n;
	int p[52];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&p[i]);
	}
	
	int cnt = 0;
	for(int i = 0 ; i < n ; i ++){
		if(p[i] != i+1)cnt ++;
	}
	if(cnt <= 2)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);
        var k = int.Parse(spl[2]);

        for(int i=a; i <= b; i++) {
            if(i < a+k || b-k < i)
                Console.WriteLine(i);
        }

        return null;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s, t; cin >> s >> t;
	int a, b; cin >> a >> b;
	string u; cin >> u;
	if(u == s) --a;
	else --b;
	cout << a << " " << b << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
    string s; cin >> s;
    int num = 0, ans = 1000;

    for (int i = 0; i < s.length() - 2; i++) {
        num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        ans = min(ans, abs(num - 753));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main(n,a):
  ret=[0]*n
  d={}
  for i,x in enumerate(a):
    if x in d:
      d[x].append(i)
    else:
      d[x]=[i]
  v=sorted(list(d.keys()),reverse=True)
  cnt_idx=0
  min_idx=n+1
  for i,x in enumerate(v):
    cnt_idx+=len(d[x])
    min_idx=min(min_idx,d[x][0])
    nx=0
    if i<len(v)-1:nx=v[i+1]
    ret[min_idx]+=cnt_idx*(x-nx)
  return ret

n=int(input())
a=list(map(int,input().split()))
print(*main(n,a),sep='\n')


Measured memory_bytes: 34720
//
// Created by moono on 2018/10/27.
//

#include <iostream>
#include <string>
#include <set>
using namespace std;


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

    char c;
    char table[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> c;
            table[i][j] = c;
        }
    }




    //
    set<int> compress_row, compress_col;


    //
    for (int i = 0; i < H; ++i) {
        bool can_compress = true;
        for (int j = 0; j < W; ++j) {
            if(table[i][j] == '#') {
                can_compress = false;
                break;
            }
        }
        if(can_compress) compress_row.insert(i);
    }


    //
    for (int j = 0; j < W; ++j) {
        bool can_compress = true;
        for (int i = 0; i < H; ++i) {
            if(table[i][j] == '#') {
                can_compress = false;
                break;
            }
        }
        if(can_compress) compress_col.insert(j);
    }


//    for (int i = 0; i < H; ++i) {
//        for (int j = 0; j < W; ++j) {
//            cout << table[i][j];
//        }
//        cout << endl;
//    }
//    cout << compress_row.size() << endl;
//    cout << compress_col.size() << endl;


    // 
    for (int i = 0; i < H; ++i) {
        if(compress_row.find(i) != compress_row.end())
            continue;

        for (int j = 0; j < W; ++j) {
            if(compress_col.find(j) != compress_col.end()){
                continue;
            }
            cout << table[i][j];
        }
        cout << endl;
    }




    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int K, N;

    cin >> K >> N;

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

    int D[N];
    for(int i = 0; i < N - 1; i++) {
        D[i] = A[i + 1] - A[i];
    }
    D[N - 1] = A[0] + (K - A[N - 1]);

    int allDis = 0;
    for(int i = 0; i < N; i++) {
        allDis += D[i];
    }

    int ans = 1000000000;
    for(int i = 0; i < N; i++) {
        ans = min(ans, allDis - D[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define iii pair<pair<int,int>,int>
#define f(x,y,z) for(int x = y ; x <= z ; x++)
#define fs(arr,n) for(int i = 1 ; i <= n ; i++) cin >> arr[i];
#define fsm(arr,n,m) for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) cin >> arr[i][j];
#define fp(arr,n) for(int i = 1 ; i <= n ; i++) cout << arr[i] << " ";
#define fpm(arr,n,m) for(int i = 1 ; i <= n ; i++){ for(int j = 1 ; j <= m ; j++) {cout << arr[i][j] << " ";} cout << "\n"}
#define N 100005
using namespace std;
int n,m,arr[N];
int main() 
{
    fast_io();
    cin >> n >> m;
    for(int i = 1 ; i <= m ; i++)
	{
		int a,b;
		cin >> a >> b;
		arr[a]++;
		arr[b]++;
    }
	for(int i = 1 ; i <= n ; i++)
	{
		if(arr[i]%2 == 1)
		{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES" ;
	
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 3e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];

void solve()
{
	int x, y;
	cin >> x >> y;
	if(y & 1)
	{
		cout << "No" << endl;
		return;
	}
	int ptr = 0;
	for(int i = 0; i <= y; i += 2, ptr++)
	{
		if(ptr + (y - i) / 4 == x and (y - i) % 4 == 0)
		{
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 3636
A,B,C,X,Y = map(int, input().split())

ans = X * A + Y * B

ans = min(ans, 2 * C * (max(X,Y)))

if X>=Y:
    ans = min(ans, A*(X-Y) + 2*C*Y)

else:
    ans = min(ans, B*(Y-X) + 2*C*X)

print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long N = sc.nextLong();
 	long A = sc.nextLong();
 	long B = sc.nextLong();
  long sho = N/(A+B);
  	long amari = N%(A+B);
  	long ans=0;
     
  	ans = sho * A;
  
  
  	if(amari<=A){
     ans += amari; 
    }else{
      ans += A;
    }
  
	System.out.print(ans);
	}
}

Measured memory_bytes: 21972
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int num=sc.nextInt();
		int sum=0;
		num-=num%5;
		do{
			if(num/500>0){
				sum+=(num/500)*1000;
				num%=500;
			}
			else if(num/5>0){
				sum+=(num/5)*5;
				num%=5;
			}
			else break;
		}while(num>0);
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    vector<int> a(n);
    in_arr(int, a, n);
    rep(i, n){
        int b;
        cin >> b;
        a[i] -= b;
        if(a[i] < 0){
            sum += abs(a[i]) / 2;
        }else{
            sum -= a[i];
        }
    }
    if(sum >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256