akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int main(int argc, const char *argv[])
{
    int n, m, a, b;
    cin >> n >> m;
    map<int, bool> x, y;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if (a == 1)
        {
            x[b] = true;
        }
        else if (a == n)
        {
            x[b] = true;
        }
        if (b == 1)
        {
            y[a] = true;
        }
        else if (b == n)
        {
            y[a] = true;
        }
    }

    for (int i = 2; i < n; i++)
    {
        if (x[i] && y[i])
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


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

def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    size = A[0]
    ret = 1
    for i in range(1, N):
        if A[i]<=2*size:
            size += A[i]
            ret += 1
        else:
            size += A[i]
            ret = 1
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14316
#include<bits/stdc++.h>
#include<unordered_map>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define ll long long
#define ld long double
#define mk make_pair
#define loop(i,intial,n)  for(int i=int(intial);i<n;i++)
#define loopn(j,n) for(int j=int(n);j>=0;j--)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
///////////////////////////////////////
#define SCD(a) scanf("%d",&a)
#define SCD2(a,b) scanf("%d %d",&a,&b)
#define SCLL(a) scanf("%lld",&a)
#define SCLL2(a,b) scanf("%lld %lld",&a,&b)
#define PRD(a) printf("%d\n",a)
#define PRLL(a) printf("%lld\n",a)
///////////////////////////////////////
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const ll oo = (ll) 1e13;
const double EPS = 1e-4;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");

int main()
{
	afify();
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0] ){
		cout<<"YES"<<endl;
	}
	else {cout<<"NO"<<endl;}


return 0;
}

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

using namespace std;

vector<int> memo(1000000, -1);

int recursion(const int n) {
  if (n < 0) {
    return std::numeric_limits<int>::max();
  }
  if (n == 0) {
    return 0;
  }
  if (memo[n] != -1) {
    return memo[n];
  }
  vector<int> count;
  for (auto draw :
       {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049}) {
    count.push_back(recursion(n - draw));
  }
  memo[n] = *min_element(count.begin(), count.end()) + 1;
  return memo[n];
}

int main() {
  int n;
  cin >> n;
  cout << recursion(n) << endl;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int a[m];
    rep(i,m) cin >> a[i];

    int p=0,q=0;

    for(int i=0;i<m;i++){
        if(a[i]<x){
            p++;
        }

        if(a[i]>x){
            q++;
        }
    }

    cout << min(p,q) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <bitset>
using namespace std;

typedef complex< int > Point;

int N;
Point p[24];
int R[24], C[24];
char f[1 << 24];

void read_plate(void);
void solve(void);
char dp(int);
bool is_valid(int, int);

int main() {
  while (cin >> N, N) {
    read_plate();
    solve();
  }

  return 0;
}

void read_plate(void) {
  for (int i = 0; i < N; ++i) {
    int x, y;
    cin >> x >> y >> R[i] >> C[i];
    p[i] = Point(x, y);
  }
}

void solve(void) {
  fill(&f[0], &f[1 << N], char(-1));
  cout << int(dp((1 << N) - 1)) << endl;
}

char dp(int m) {
  if (f[m] != -1) return f[m];
  if (m == 0)     return char(0);

  f[m] = char(0);
//  cout << "m = " << bitset< 7 >(m) << endl;
  for (int i = 0; i < N; ++i)
    if ((1 << i & m) && is_valid(i, m))
      for (int j = 0; j < N; ++j)
        if ((1 << j & m) && i != j && C[i] == C[j] && is_valid(j, m))
          f[m] = max(f[m], char(dp(m & ~(1 << i) & ~(1 << j)) + 2));

  return f[m];
}

bool is_valid(int qi, int qm) {
  for (int i = qi - 1; i >= 0; --i)
    if ((1 << i & qm) && norm(p[i] - p[qi]) < (R[i] + R[qi]) * (R[i] + R[qi]))
      return false;
  return true;
}

Measured memory_bytes: 17552
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
A = LI()

A.sort(reverse=True)
p = 0
c = 1
ans = 0
for i in range(1,N):
    ans += A[p]
    if c == 1:
        c = 0
        p += 1
    else:
        c = 1

print(ans)

Measured memory_bytes: 94196
def getN():
    return int(input())

def getlist():
    return list(map(int, input().split()))

n = getN()
def isodd(n):
    print((n-1)*(n-3)//2 + (n-1))
    for i in range(n-1):
        for j in range(i):
            if i != j and i+j != n-2:
                print(i+1, j+1)
    for i in range(n-1):
        print(n, i+1)



def iseven(n):
    print(n*(n-2)//2)
    for i in range(n):
        for j in range(i):
            if i!= j and (i+j) != n-1:
                print(i+1,j+1)
if n % 2 == 0:
    iseven(n)
else:
    isodd(n)

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

int main() {
  size_t N;

  std::cin >> N;

  auto s_factor = N + (N+1)%2;

  std::vector<std::pair<size_t, size_t>> ans;

  for (size_t i=1; i<N; i++) {
    for (size_t j=i+1; j<N+1; j++) {
      if (j == s_factor-i) continue;
      ans.emplace_back(i, j);
    }
  }

  std::cout << ans.size() << '\n';
  for (auto const& p: ans)
    std::cout << p.first << ' ' << p.second << '\n';

  return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = sc.nextInt();
			if (m == 0)
				break;
			String[] nums = new String[m];
			final Map<String, Integer> p = new HashMap<String, Integer>();
			for (int i = 0; i < m; i++) {
				String key = sc.next();
				nums[i] = (p.containsKey(key) ? "0" : "") + key;
				boolean st[] = new boolean[10];
				boolean sp[] = new boolean[10];
				p.put(nums[i], 0);
				for (int j = 0; j < 10; j++) {
					int fst = sc.nextInt();
					p.put(nums[i], p.get(nums[i]) + fst);
					if (j - 1 >= 0 && (sp[j - 1] || st[j - 1]))
						p.put(nums[i], p.get(nums[i]) + fst);
					if (j - 2 >= 0 && st[j - 2] && st[j - 1])
						p.put(nums[i], p.get(nums[i]) + fst);
					if (fst == 10) {
						st[j] = true;
						if (j == 9) {
							int f = sc.nextInt();
							int s = sc.nextInt();
							p.put(nums[i], p.get(nums[i]) + f);
							p.put(nums[i], p.get(nums[i]) + s);
							if (st[8]) {
								p.put(nums[i], p.get(nums[i]) + f);
							}
						}

					} else {
						int snd = sc.nextInt();
						p.put(nums[i], p.get(nums[i]) + snd);
						if (j - 1 >= 0 && st[j - 1])
							p.put(nums[i], p.get(nums[i]) + snd);
						if (snd + fst == 10) {
							sp[j] = true;
							if (j == 9) {
								int f = sc.nextInt();
								p.put(nums[i], p.get(nums[i]) + f);
							}
						}
					}
				}
			}
			Arrays.sort(nums, new Comparator<String>() {
				public int compare(String a, String b) {
					int pa = p.get(a);
					int pb = p.get(b);
					if (pa != pb) {
						return pb - pa;
					} else {
						return Integer.parseInt(a) - Integer.parseInt(b);
					}
				}
			});
			for (int i = 0; i < nums.length; i++) {
				System.out.println(Integer.parseInt(nums[i]) + " "
						+ p.get(nums[i]));
			}
		}
	}
}

Measured memory_bytes: 12000
N, M, X, Y = map(int, input().split())
max_X = max(list(map(int, input().split())))
min_Y = min(list(map(int, input().split())))

for Z in range(X+1, Y+1):
    if max_X < Z <= min_Y:
        print("No War")
        exit()
else:
    print("War")


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#include <atcoder/all>
#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 namespace atcoder;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    vector<int> c = convolution(a, b);
    rep(i, n+m-1) cout << c[i] << (i == n+m-2 ? '\n' : ' ');
}


Measured memory_bytes: 19024
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <vector>
#include <utility>
#define N 320
using namespace std;

vector<pair<int, int> > e[N];
pair<long long, int> f[N][N];
bool u[N];

void Check(pair<long long, int> &a, pair<long long, int> b)
{
    if(a.first > b.first || (a.first == b.first && a.second < b.second))
        a = b;

    return;
}

void Dijkstra(int s, int l, int n)
{
    int i, v, t;
    pair<long long, int> w;

    for(i = 0; i < n; i ++)
    {
        u[i] = false;
        f[s][i] = make_pair(LLONG_MAX >> 2, 0);
    }
    f[s][s] = make_pair(0, l);

    while(true)
    {
        for(i = 0, t = -1; i < n; i ++)
            if(!u[i] && (t == -1 || (f[s][t].first > f[s][i].first || (f[s][t].first == f[s][i].first && f[s][t].second < f[s][i].second))))
                t = i;
        if(t == -1 || f[s][t].first == (LLONG_MAX >> 2))
            break;
        u[t] = true;

        // printf("select %d : %lld %d\n", t, f[s][t].first, f[s][t].second);

        for(i = 0; i < (signed)e[t].size(); i ++)
            if(!u[e[t].at(i).first])
            {
                v = e[t].at(i).first;
                w = f[s][t];
                w.second -= e[t].at(i).second;
                if(w.second < 0)
                {
                    w.second = l - e[t].at(i).second;
                    w.first ++;
                }
                Check(f[s][v], w);
            }
    }

    return;
}

int main(void)
{
    int n, m, l;
    int u, v, w;
    int i;

    scanf("%d %d %d", &n, &m, &l);
    while(m --)
    {
        scanf("%d %d %d", &u, &v, &w);
        if(w <= l)
        {
            e[-- u].push_back(make_pair(-- v, w));
            e[   v].push_back(make_pair(   u, w));
        }
    }

    // Dijkstra(4, l, n);
    for(i = 0; i < n; i ++)
        Dijkstra(i, l, n);
    scanf("%d", &m);
    while(m --)
    {
        scanf("%d %d", &u, &v);
        if(f[-- u][-- v].first == (LLONG_MAX >> 2))
            printf("-1\n");
        else
            printf("%lld\n", f[u][v].first);
    }

    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;
ll w;
int main(){
	string s;
	cin>>s;
	for(ll i=s.size()-1; i>=0; i--){
		if(s[i]=='B') ans+=w;
		else w++;
	}
	cout<<ans<<endl;	
}


Measured memory_bytes: 640
import itertools
import math

N = int(input())
point = list()
for i in range(N):
	point.append(list(map(int,input().split())))

target = list(itertools.permutations(point))
distance = 0
# 全てのパターンを調べる
for i in range(len(target)):
	# 距離を求める	
	for j in range(len(target[i])-1):
		cul = (target[i][j][0] - target[i][j+1][0])**2 + (target[i][j][1] - target[i][j+1][1])**2
		distance += math.sqrt(cul)
print(distance/len(target))

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

using namespace std;

#define MAX_N 100
#define MAX_M 50
#define INF (1<<29)

int main()
{
    int N, M;
    double L;
    cin >> N >> M >> L;
    vector<double> P(N), T(N), V(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i] >> T[i] >> V[i];
        P[i] /= 100;
    }
    double p[MAX_N][MAX_M+1][MAX_M+1];
    memset(p, 0, sizeof(p));

    for (int i = 0; i < N; i++) {
        p[i][0][0] = 1;
        for (int j = 0; j < M; j++) {
            for (int k = 0; k < M; k++) {
                p[i][j+1][k]   += p[i][j][k] * (1 - P[i]);
                p[i][j+1][k+1] += p[i][j][k] * P[i];
            }
        }
    }
    
    for (int i = 0; i < N; i++) {
        double res = 0;
        for (int j = 0; j <= M; j++) {
            double r = 1;
            bool win = 1;
            for (int k = 0; k < N; k++) {
                if (i == k) {
                    continue;
                }
                double rr = 0;
                bool ok = 0;
                for (int l = M; l >= 0; l--) {
                    if (V[k]*L+V[k]*V[i]*T[i]*j <
                        V[i]*L+V[i]*V[k]*T[k]*l) {
                        ok = 1;
                        rr += p[k][M][l];
                    } else {
                        break;
                    }
                }
                if (!ok) {
                    win = 0;
                    break;
                }
                r *= rr;
            }
            res += (win ? r * p[i][M][j] : 0);
        }
        printf("%.8f\n", res);
    }
    return 0;
}

Measured memory_bytes: 5304
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int a, b; cin>>a>>b;
    int use = 1;
    int ans = 0;
    while (use < b) {
        use+=(a-1);
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
  int k, n;
  cin >> k >> n;
  vector<int> a(n);

  for (int i = 0; i < n; i++)
    cin >> a[i];

  int max = 0;
  for (int i = 0; i < n; i++) {
    int diff;
    if (i+1 == n)
      diff = k - a[i] + a[0];
    else
      diff = a[i+1] - a[i];
    if (max < diff)
      max = diff;
  }
  cout << k - max << endl;
  return 0;
}


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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS

    int a ,b;
    cin >> a >> b;
    cout << max(a - b, max(a + b, a * b));

    return 0;
}

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

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C-A+B, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input().split() for i in range(n)]
for i in range(n):
    s[i][1] = int(s[i][1])
    s[i].append(i+1)
sorted_list = sorted(s, key=lambda x:(x[0], -x[1]))
for i in range(n):
    print(sorted_list[i][2])

Measured memory_bytes: 38384
#include <stdio.h>

int main(void){

  int n,m;
  scanf("%d %d", &n, &m);
  int a[m];
  for (int i = 0; i < m; i++) {
    scanf("%d", &a[i]);
  }
  long mod = 1000000007;
  long move[n+1];
  for (int i = 0; i < n+1; i++) {
    move[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    move[a[i]] = -1;
  }
  move[0] = 1;
  if (move[1] != -1) {
    move[1] = 1;
  }
  for (int i = 2; i < n+1; i++) {
    if (move[i] == -1) {
      continue;
    }
    if (move[i-1] != -1) {
      move[i] += move[i-1];
      move[i] %= mod;
    }
    if (move[i-2] != -1) {
      move[i] += move[i-2];
      move[i] %= mod;
    }
  }
  long answer = move[n];
  if (answer < 0) {
    answer = 0;
  }
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 1280
import java.awt.print.Printable;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
   
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        int amida[] = new int[n+1];
 
        for(int i=1;i<=n;i++){
            amida[i] = i;
        }
        for(int i=0;i<w;i++){
            String str = sc.next();
            String[] strs = str.split(",");
 
            int a = Integer.parseInt(strs[0]);
            int b = Integer.parseInt(strs[1]);
 
            int temp = amida[a];
 
            amida[a]=amida[b];
 
            amida[b]=temp;
        }
        for(int i=1;i<=n;i++){
            System.out.println(amida[i]);
        }
    }   
}


Measured memory_bytes: 25908
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x1 - dy
y4 = y1 + dx

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(System.out);
        
        String[] pCodeStyle = br.readLine().split(" ");
        int pCodeStyleFront = Integer.parseInt(pCodeStyle[0]);
        int pCodeStyleBack = Integer.parseInt(pCodeStyle[1]);
        
        String S = br.readLine();
        
        while(true){
            if(S.length() == pCodeStyleFront + pCodeStyleBack + 1){
                if(S.indexOf("-") == pCodeStyleFront){
                    if(S.indexOf("-", pCodeStyleFront + 1) < 0){
                        writer.println("Yes");
                        break;
                    }
                }
            }
            writer.println("No");
            break;
        }
        br.close();
        writer.close();
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 int main() {
	int A,B;
   cin>>A>>B;
   int sum=A+B;
   if(sum%3==0){cout<<"Possible";}
   else if(A%3==0){cout<<"Possible";}
   else if(B%3==0){cout<<"Possible";}
   else{cout<<"Impossible";}
	}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        int N = cin.Nextint;

        var A = new long[N];
        var B = new long[N];

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


        long cnt = 0;
        for (int i = N - 1; i >= 0; i--)
        {
            var d = (A[i] + cnt) % B[i];
            if (d == 0) continue;
            cnt += B[i] - d;
        }

        WriteLine(cnt);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 8484
/*3.4 hightierra*/
#include <stdio.h>
 
int main(void){
    //変数Nを定義、値を入力
    int N;
    scanf("%d",&N);

    int i,j; //for文のカウンタ
    int judge = 0; //九九で表せるかの判定

    /*二重ループで九九にあるかを判定*/
    for(i=1; i<10; i++){
      	for(j=1; j<10; j++){
          if(N == i*j){
            judge = 1; //表せたらjudgeを１に
            break; //内側for文を抜ける
          }
      	}
        if(judge){
            break; //外側for文を抜ける
        }
    }
    // 判定
    if(judge){
      	printf("Yes\n");
    }else{
      	printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string.h>

int x_size, y_size;

using namespace std;

int rev(int r, int map[][10])
{
	int tmap[10000][10];
	int ret = 0;
	
	for (int i = 0; i < y_size; i++){
		if ((r >> i) & 1 == 1){
			for (int j = 0; j < x_size; j++){
				tmap[j][i] = (map[j][i] == 1 ? 0 : 1);
			}
		}
		else {
			for (int j = 0; j < x_size; j++){
				tmap[j][i] = map[j][i];
			}
		}
	}
	for (int i = 0; i < x_size; i++){
		int count[2] = {0, 0};
		for (int j = 0; j < y_size; j++){
			count[tmap[i][j]]++;
		}
		ret += max(count[0], count[1]);
	}
	
	return (ret);
}

int main(void)
{
	while (1){
		int map[10000][10];
		int ans = 0;
		
		cin >> y_size >> x_size;
		
		if (y_size == 0 && x_size == 0)break;
		
		for (int y = 0; y < y_size; y++){
			for (int x = 0; x < x_size; x++){
				cin >> map[x][y];
			}
		}
		
		for (int i = 0; i <= (1 << y_size); i++){
			ans = max(ans, rev(i, map));
		}
		
		cout << ans << endl;
	}
	return (0);
}

Measured memory_bytes: 1644
N=int(input())
D1 = [0] * N
D2 = [0] * N
for i in range(N):
    D1[i], D2[i]= map(int, input().split())
count=0
for i in range(N-2):
    if D1[i]==D2[i]:
        if D1[i+1]==D2[i+1]:
            if D1[i+2]==D2[i+2]:
                count=count+1
if count>=1:
    print("Yes")
else:
    print("No")

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

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> A(n);
    ll max_a = 0;
    rep(i, 0, n) cin >> A[i];
    rep(i, 0, n) max_a = max(max_a, A[i]);

    ll digit = 1, base = 1;
    while(base <= max_a or base <= k) base <<= 1, ++digit;
    // ++digit, base <<=1;

    vector<vector<ll>> dp(digit+2, vector<ll>(2, -1));
    dp[digit+1][0] = dp[digit][0] = 0;
    for (; base > 0; base >>=1, --digit)
    {
        ll zero = 0, one = 0;
        rep(i, 0, n)
        {
            zero += (A[i] & base) ^ 0LL;
            one += (A[i] & base) ^ base;
        }

        ll now = (k & base) >> (digit-1);
        now %= 2LL;

        // smaller -> smaller
        if (dp[digit+1][1] != -1)
            dp[digit][1] = max(dp[digit][1], dp[digit+1][1] + max(one, zero));

        // same -> same
        if (now)
            dp[digit][0] = max(dp[digit][0], dp[digit+1][0] + one);
        else
            dp[digit][0] = max(dp[digit][0], dp[digit+1][0] + zero);

        // same -> smaller
        if (now)
            dp[digit][1] = max(dp[digit][1], dp[digit+1][0] + zero);
        
        // cout << digit << ' ' << max(zero, one) << ' ' << dp[digit+1][1] << ' ' << base << ' ' << zero << ' ' << one << ' ' << now << endl;
    }
    cout << max(dp[1][1], dp[1][0]) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long const MOD = 1000000007;
long long dp[2002][2002];

int main()
{
    // get input
    int N, M;
    cin >> N >> M;
    vector<int> S(N + 1), T(M + 1);
    S[0] = T[0] = 0;
    for (int i = 1; i <= N; i++)
        cin >> S[i];
    for (int i = 1; i <= M; i++)
        cin >> T[i];

    // get position
    map<int, queue<int>> smap;
    for (int i = 1; i <= N; i++)
        smap[S[i]].push(i);

    for (int i = 1; i <= M; i++)
    {
        queue<int> que = smap[T[i]];
        int p = -1;
        if (que.size() > 0)
            p = que.front(), que.pop();

        for (int j = 1; j <= N; j++)
        {
            if (p != -1 and p == j)
            {   
                dp[i][j] = (1 + dp[i][j - 1] - dp[i - 1][j - 1] + dp[i - 1][j] + dp[i - 1][j - 1]) % MOD;
                if (que.size() > 0)
                    p = que.front(), que.pop();
            }
            else
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1]) % MOD;

            while (dp[i][j] < 0)
                dp[i][j] += MOD;
        }
    }

    cout << (1 + dp[M][N]) % MOD<< endl;
    return 0;
}


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c;
    k = a % b;
    for (int i = 1; i < 100; i++)
    {
        if (i > 1 && k * i % b == k)
        {
            cout << "NO" << endl;
            break;
        }
        if (k * i % b == c)
        {
            cout << "YES" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int main(){
	int n,k,q;
	cin>>n>>k>>q;
	vector<int> aq(q);
	rep(i,q){
		cin>>aq.at(i);
	}
	if(k>q){
		rep(i,n){
			cout<<"Yes"<<endl;
		}
	}else{
		vector<int> an(n,(k-q));
		rep(i,q){
			an.at(aq.at(i)-1)++;
		}
		rep(i,n){
			if(an.at(i)>0){
				cout<<"Yes"<<endl;
			}else{
				cout<<"No"<<endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		if ( n%500 <= a ) System.out.println("Yes"); 
		else System.out.println("No"); 
	}
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
/*
 * Be careful of overflow
 * Array bounds
 * Assert a!=0 when performing x/a
 * Check base condition for recursion
 * Iterator -> O(1), Element -> O(log n) while using erase
 * 1LL<<x when x>32
 * Be sure of what you are going to code (exception dp)
 * Don't try fancy tricks during contest
 * You can always make a bad round to a good enough round
 */ 

int h[300009],w[300009];
vector<pii> tar;
vector<pii> hh,ww;

set<int> hhh,www;

void solve()
{
	int H,W;
	cin>>H>>W;
	int m,i;
	cin>>m;
	for(i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		h[a]++;
		w[b]++;
		tar.pb({a,b});
	}
	
	for(i=1;i<=H;i++)
	{
		if(h[i]) hh.pb({h[i],i});
	}
	
	sort(all(hh),greater<pii>());
	
	for(i=1;i<=W;i++)
	{
		if(w[i]) ww.pb({w[i],i});
	}
	sort(all(ww),greater<pii>());
	
	int ans = hh[0].fi + ww[0].fi;
	
	i=0;
	while(i<S(hh) && hh[i].fi == hh[0].fi)
	{
		hhh.insert(hh[i].se);
		i++;
	}
	
	i=0;
	while(i< S(ww) && ww[i].fi == ww[0].fi)
	{
		www.insert(ww[i].se);
		i++;
	}
	int cnt=0;
	for(auto u:tar)
	{
		if(hhh.count(u.fi) && www.count(u.se))
		{
			cnt++;
		}
	}
	ll tot = 1LL * S(hhh) * S(www);
	if(tot == cnt ) ans--;
	cout<<ans<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 40732
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int n, A[MAX];
    
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    
    int maxv = -2000000000;
    int minv = A[0];
    
    for(int i=1; i<n; i++){
        maxv = max(maxv, A[i]-minv);
        minv = min(minv, A[i]);
        
    }
    
    cout << maxv << endl;
    
    return 0;
}


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

int a[400];
long long cost[400][400], dp[400][400];

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

    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> a[i];

    for (int i=0; i<n; i++) {
        cost[i][i] = a[i];
        dp[i][i] = 0;
    }
    for (int diff=1; diff<n; diff++)
        for (int i=0; i+diff<n; i++) {
            int j = i + diff;
            dp[i][j] = LLONG_MAX;
            for (int k=i; k<j; k++)
                if (dp[i][k] + dp[k+1][j] + cost[i][k] + cost[k+1][j] < dp[i][j]) {
                    cost[i][j] = cost[i][k] + cost[k+1][j];
                    dp[i][j] = dp[i][k] + dp[k+1][j] + cost[i][k] + cost[k+1][j];
                }
        }

    cout << dp[0][n-1] << "\n";

    return 0;
}


Measured memory_bytes: 2816
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;    
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) 
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << ' ';
    cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
    ll ans = 1;
    while (n) 
    {
        if (n&1) ans = (ans*a)%modulo;
        a = (a*a)%modulo; n = n >> 1;
    }
    return ans;
}

void solve() 
{
    int n; cin >> n;
    int x[n];
    For(i,0,n)
    {
        cin >> x[i];
    }    
    int ans = 1e9;
    For(i,1,101)
    {
        int curr = 0;
        For(j,0,n)
        {
            curr += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans, curr);
    }
    cout << ans << endl;
}

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

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

int main(){
  /*処理系*/
  string S = "";
  cin >> S;
  int si;
  for (si = 0; si < 2; si++)
  {
    if(S[si] != S[si+1])
      break;
  }
  if(si == 2){
    cout << "No";
  }
  else{
    cout << "Yes";
  }
  return 0;
}

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

using namespace std;
#define                     IO                                              ios_base::sync_with_stdio(0); cin.tie(0)

#define MAX 100005

int n;
int cell[MAX][4];
int memo[MAX][4];


int call(int col,int row){
    if(row == n) return 0;
    if(memo[row][col] != -1) return memo[row][col];
    if(col == 0) return memo[row][col] = cell[row][col] + max(call(1,row + 1),call(2,row + 1));
    else if(col == 1) return memo[row][col] = cell[row][col] + max(call(0,row + 1),call(2,row + 1));
    else if(col == 2) return memo[row][col] = cell[row][col] + max(call(1,row + 1),call(0,row + 1));
}

int main(){
IO;
    cin >> n;
    memset(memo,-1,sizeof(memo));
    for(int r = 0; r < n; r++)
        for(int c = 0; c < 3; c++)
            cin >> cell[r][c];
    int res = call(0,0);
    res = max(res,call(1,0));
    res = max(res,call(2,0));
    cout << res << '\n';

}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int count = 0; boolean flag = false; int max = 0;
		for (int i = 0; i < s.length; i++) {
			if(flag) {
				if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C') count++;
				else {
					flag = false;
					max = Math.max(max,count);
					count = 0;
				}
			}else {
				if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C') {
					flag = true;
					count = 1;
				}
			}
		}
		max = Math.max(max,count);
		System.out.println(max);
		sc.close();
	}
}

Measured memory_bytes: 23124
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    long long x,y;
    cin >> x >> y;
    cout << __gcd(x,y) << endl;
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int dp[110][110];
int calc(int a,int b){
	if(~dp[a][b])return dp[a][b];
	for(int i=2;i<=a;i+=2){
		if(calc(a-i,b+i/2)==0)return dp[a][b]=1;
	}
	for(int i=2;i<=b;i+=2){
		if(calc(a+i/2,b-i)==0)return dp[a][b]=1;
	}
	return dp[a][b]=0;
}
int main(){
	long long a,b;
	scanf("%lld%lld",&a,&b);
	if(ABS(a-b)>1)printf("Alice\n");
	else printf("Brown\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,L;
    cin >> N >> L;
    ll i,mn=500,ans=0;
    for(i=0;i<N;i++){
        ans+=L+i;
        if(abs(mn)>abs(L+i))mn=L+i;
    }
    cout << ans-mn;
    return 0;
}

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

MAX = max(X, Y)
MIN = 2*C*max(X, Y)
i = MAX
x=X
y=Y

while i > 0:
    tmpC = (MAX-i)*2*C
    total = (A*x)+(B*y)+tmpC
    if(MIN > total):
        MIN = total
    i-=1
    if(x!=0):
        x-=1
    if(y!=0):
        y-=1

print(MIN)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int sx, sy, tx, ty;

int main(){
	cin >> sx >> sy >> tx >> ty;
	
	REP(i,tx-sx) cout << "R";
	REP(i,ty-sy) cout << "U";
	
	REP(i,tx-sx) cout << "L";
	REP(i,(ty-sy)+1) cout << "D";
	
	REP(i,(tx-sx)+1) cout << "R";
	REP(i,(ty-sy)+1) cout << "U";
	
	cout << "LU";
	
	REP(i,(tx-sx)+1) cout << "L";
	REP(i,(ty-sy)+1) cout << "D";
	
	cout << "R" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n % 2 == 1)
    {
        cout << n / 2 * (n / 2 + 1) << endl;
    }
    else
    {
        cout << (n / 2) * (n / 2) << endl;
    }
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()

def main():
    a, b = map(int, input().split())
    sum = a + b
    d = a - b
    times = a * b
    if sum >= d:
        ans = sum
    else:
        ans = d
    if ans < times:
        print(times)
        return
    print(ans)
        
    
main()


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>
#include <cctype>

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i)
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i)

#define DEBUG(...) fprintf(stderr , __VA_ARGS__)

template<typename T>inline int chkmin(T &x , const T &y){ return x > y ? x = y , 1 : 0; }
template<typename T>inline int chkmax(T &x , const T &y){ return x < y ? x = y , 1 : 0; }

template<typename T>inline T read(T &f)
{
	f = 0 ; int x = 1 ; char c = getchar();
	while(!isdigit(c)) c = x == '-' ? -1 : 1 , c = getchar();
	while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
	return f *= x;
}

using int64 = long long;
using uint64 = unsigned long long;

const int N = 100000 + 5;

int n , X , Y , Z;

int64 S , Ans;

struct Node
{
	int64 x , y , d;
	int operator < (const Node &rhx) const
	{
		return d < rhx.d;
	}
} A[N];

int64 ret[2] , suf[N] , pre[N];

#include <set>

std::multiset<int64> M[2];

const int64 INF = 1ll << 60;

int main()
{
	n = read(X) + read(Y) + read(Z);
	rep(i , 1 , n)
	{
		static int x , y , z;
		read(x) , read(y) , read(z);
		x -= z , y -= z , S += z;
		A[i] = {x , y , x - y};
	}
	std::sort(A + 1 , A + 1 + n);
	auto inc = [&](int x , int op)
	{
		M[op].insert(x);
		ret[op] += x;
	};
	auto dec = [&](int x , int op)
	{
		auto it = M[op].find(x);
		M[op].erase(it);
		ret[op] -= x;
	};
	auto ins = [&](int x , int op)
	{
		int mn = *M[op].begin();
		if(mn > x) return;
		inc(x , op) , dec(mn , op);
	};
	rep(i , 1 , Y) inc(A[i].y , 0);
	pre[Y] = ret[0];
	rep(i , Y + 1 , n - X)
	{
		ins(A[i].y , 0);
		pre[i] = ret[0];
	}
	per(i , n , n - X + 1) inc(A[i].x , 1);
	suf[n - X + 1] = ret[1];
	per(i , n - X , Y + 1)
	{
		ins(A[i].x , 1);
		suf[i] = ret[1];
	}
	Ans = -INF;
	rep(i , Y , n - X) chkmax(Ans , suf[i + 1] + pre[i]);
	printf("%lld\n" , Ans + S);
	return 0;
}


Measured memory_bytes: 7168
N =int(input())
A = list(map(int,input().split()))

S = [0]
X = [0]
for a in A:
    S.append(S[-1]+a)
    X.append(X[-1]^a)

l,r = 1,1
ans = 0
p = 1
while r <= N:
    if S[r]-S[l-1] == X[r]^X[l-1]:
        if p==0:
            ans -= (r-l)*(r-l+1)//2
        r += 1
        p = 1
    else:
        if p ==1:
            ans += (r-l)*(r-l+1)//2
        l += 1
        p = 0
ans += (r-l)*(r-l+1)//2
print(ans)

Measured memory_bytes: 30628
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int[] Nor = {20,19,20,19,20,19,20,19,20,19};
			int SumN = 195;
			int[] Spe = {20,20,20,20,20,20,20,20,20,20};
			int SumS = 200;
			int mine = 196471;
			
			while(sc.hasNext()) {
				int n = sc.nextInt();
				for(int j=1;j<=n;j++) {
					int day = 0;
					int y = sc.nextInt();
					int m = sc.nextInt();
					int d = sc.nextInt();
					for(int i=1;i<=y;i++) {
						if(i%3==0) {
							if(i == y) {
								if(m==1)
									day += d;
								else
									for(int k=m-1;k>=0;k--) {
										if(k == m-1)
											day += d;
										else
											day += Spe[k];
											
									}
							}
							else
								day += SumS;
						}
						else {
							if(i==y) {
								if(m==1)
									day += d;
								else
									for(int k=m-1;k>=0;k--) {
										if(k == m-1)
											day += d;
										else
											day += Nor[k];
									}
							}
							else
								day += SumN;
						}
					}
					System.out.println(mine-day);
				}
			}
		}
	}
}



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

int main(){
	int n, l, a[100000] = {}, pre = 0;
	long long int max = -1, sum = 0;
	cin >> n >> l;
	for(int i = 0;i<n;i++){
		cin >> a[i];
		a[i] = l - a[i];
	}
	pre = 0;
	sum = 0;
	for(int i = 0;i<n;i++){
		if(pre < a[i]) {
			pre = a[i];
			sum = a[i];
		}
		else sum += a[i];
		pre = a[i];
		if(sum > max) max = sum;
	}
	pre = 0;
	sum = 0;
	for(int i = n-1;i>=0;i--){
		if(pre < a[i]) {
			pre = a[i];
			sum = a[i];
		}
		else sum += a[i];
		pre = a[i];
		if(sum > max) max = sum;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3472