akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll maxAbsValExpr(vector<ll>& x, vector<ll>& y) {
        ll res = 0, n = x.size(), smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * x[0] + q * y[0] + 0;
                for (ll i = 1; i < n; ++i) {
                    cur = p * x[i] + q * y[i] ;
                    res = max(res, cur - smallest);
                    smallest = min(smallest, cur);
                }
            }
        }
        return res;
    }




int main(){
  ll n;
  cin>>n;
  vector<ll>x;
  vector<ll>y;
  for(ll i=0;i<n;i++){
    ll xc,yc;
    cin>>xc;
    x.push_back(xc);
    cin>>yc;
    y.push_back(yc);
  }
  cout<<maxAbsValExpr(x,y)<<endl;

}

Measured memory_bytes: 6628
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[][] a = new int[3][3];

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        a[i][j] = sc.nextInt();
      }
    }

    int n = sc.nextInt();

    int[] b = new int[n];

    for (int i = 0; i < n; i++) {
      b[i] = sc.nextInt();
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          if (a[j][k] == b[i]) {
            a[j][k] = -1;
          }
        }
      }
    }

    int sum = 0;

    for (int i = 0; i < 3; i++) {
      sum = 0;
      for (int j = 0; j < 3; j++) {
        sum += a[i][j];
      }
      if (sum == -3) {
        System.out.println("Yes");
        return;
      }
    }

    for (int i = 0; i < 3; i++) {
      sum = 0;
      for (int j = 0; j < 3; j++) {
        sum += a[j][i];
      }
      if (sum == -3) {
        System.out.println("Yes");
        return;
      }
    }

    sum = 0;

    for (int i = 0; i < 3; i++) {
      sum += a[i][i];
      if (sum == -3) {
        System.out.println("Yes");
        return;
      }
    }

    if (a[0][2] == a[1][1] && a[1][1] == a[2][0]) {
      System.out.println("Yes");
      return;
    }

    System.out.println("No");

  }
}


Measured memory_bytes: 21844
#小さい順に並べて入力
i_list = sorted(list(map(int,input().split())))

#2辺が同じであればyesそれいがいはnoを出力
if i_list[0] == i_list[1] and i_list[2] == i_list[3]:print("yes")
else:print("no")


Measured memory_bytes: 5596
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 9000000000000;
const ll mod = 2e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

int bd[2010][2010];

signed main() {
	int n,a;
	cin >> n >> a;
	cout << n * n - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

using namespace std;

int main() {
   int n;
   int a[100010];
	cin >> n;

   rep(i,n){
      cin >> a[i];
      a[i]--;
   }
   int x=0;

   rep(i,100010){
      if(x==1){
         cout << i << endl;
         return 0;
      }
      x=a[x];
   }

   cout << -1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
struct dian
{
    long long l,r;
};
bool cmp(dian a,dian b)
{
    return a.r<b.r;
}
int main()
{
    int n;
    cin>>n;
    dian a[n+2];
    for(int i=0;i<n;i++)
    {
        long long x,L;
        cin>>x>>L;
        a[i].l=x-L;
        a[i].r=x+L;
    }
    sort(a,a+n,cmp);
    long long res=1;
    int k=0;
    for(int i=1;i<n;i++)
    {
        if(a[i].l>=a[k].r)
        {
            k=i;
            res++;
        }
    }
    cout<<res;
}


Measured memory_bytes: 1792
n = int(input())
C = list(input())
cr = 0
cw = 0
for c in C:
    if c == 'R':
        cr += 1
    else:
        cw += 1

if cw == 0:
    print(0)
else:
    ans = 0
    l = 0
    for r in range(0, cw):
        if C[n-1-r] == 'R':
            while C[l] != 'W':
                l += 1
            l += 1
            ans += 1
    print(min(ans, cr))


Measured memory_bytes: 10656
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  vector<pair<ll, ll>> v, w;
  for (int i = 0; i < N; i++)
  {
    ll A, B;
    cin >> A >> B;
    v.emplace_back(A, B);
    w.emplace_back(B, A);
  }
  sort(v.begin(), v.end());
  sort(w.begin(), w.end());
  if (N % 2 == 0)
  {
    long double pre = (v[N / 2 - 1].first + v[N / 2].first) / 2.0;
    long double post = (w[N / 2 - 1].first + w[N / 2].first) / 2.0;
    ll ans = (post - pre) * 2 + 1;
    cout << ans << endl;
  }
  else
  {
    ll pre = v[N / 2].first, post = w[N / 2].first;
    cout << post - pre + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  int view=1;
  int high=MY.at(0);
  for(int i=1;i<N;i++){
    if(high<=MY.at(i)){
      view++;
      high=MY.at(i);
    }
  }
  cout << view << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	vector<int> e(4);
	rep(i, s.size()){
		e.at(i) = s[i] - '0';
	}
	rep(i, 1 << 3){
		int temp = e.at(0);
		rep(j, 3){
			if((i & (1 << j)) == 0) temp += e.at(j+1);
			else temp -= e.at(j+1);
		}
		if(temp == 7){
			rep(j, 4){
				cout << s[j];
				if(j == 3){
					cout << "=7" << endl;
				}else{
					if((i & (1 << j)) == 0) cout << "+";
					else cout << "-";
				}
			}
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/*
	0071:Summer of KMC
*/
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int a, b;
		int C[3] = { 0 };
		cin >> a >> b;
		
		if(a == 0 && b == 0) { break; }
		
		b -= a;
		
		while(b >= 1000 != 0) { C[2]++; b -= 1000; }
		while(b >= 500 != 0) { C[1]++; b -= 500; }
		while(b >= 100 != 0) { C[0]++; b -= 100; }
		
		cout << C[0] << ' ' << C[1] << ' ' << C[2] << endl;
	}
	
	return 0;
}

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

int main() {
  int t;
  string S;
  while(cin >> t >> S && t) {
    int N = S.size();
    int max = 0;
    int mc = 0;
    int bit = 0;
    for (int i= (1 << (N-1)); i< (1 << N); i++) {
      int l=0, f=0;
      int count = 0;
      for (int j=0; j<N; j++) {
	if (i & (1 << j)) {
	  l = f;
	  f = j+1;
	  count += stoi(S.substr(l, f-l));
	}
      }
      if (count > max && count <= t) {
	max = count;
	mc = 1;
	bit = i;
      } else if (count == max)  {
	mc++;
      }
    }
    if (mc == 0) {
      cout << "error" << endl;
    } else if (mc == 1) {
      cout << max << " ";
      int l=0, f=0;
      for (int j=0; j<N; j++) {
	if (bit & (1 << j)) {
	  l = f;
	  f = j+1;
	  cout << S.substr(l, f-l); // ここを文字列で出力するのが問題に忠実。
	  // しかし先頭に0がつく紙が答えになることはないので整数でも問題ない。
	  if (f < N) cout << " ";
	  else cout << endl;
	}
      }
    } else {
      cout << "rejected" << endl;      
    }
  }
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, *l, i, max, sum;

	scanf("%d", &n);

	if ((l = (int *)malloc(sizeof(int) * n)) == NULL)
		return 1;

	for (i = 0; i < n; i++)
		scanf("%d", l + i);

	for (i = 0, max = l[0], sum = 0; i < n; i++) {
		if (l[i] > max)
			max = l[i];
		sum += l[i];
	}

	if (max < sum - max)
		printf("Yes\n");
	else
		printf("No\n");

	free(l);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

string num = "01235789";

int main(){
    int n;
    while(cin >> n && n){
        string res = "";
        while(n > 0){
            res += num[n % 8];
            n /= 8;
        }
        cout << string(res.rbegin(), res.rend()) << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
using System;
using System.Collections.Generic;

class Program
{
    public void Proc()
    {
        string[] inpt = Console.ReadLine().Split(' ');
        int a = int.Parse(inpt[0]);
        int b = int.Parse(inpt[1]);
        int c = int.Parse(inpt[2]);
        int[] arr = new int[] { a, b, c };
        Array.Sort(arr);
        Console.WriteLine(arr[0] + " " + arr[1] + " " + arr[2]);
    }



    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 9180
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int H , W , need[3];
string s[110];

int main(){
    cin >> H >> W;
    rep(i,0,H) cin >> s[i];
    map<char,int> cnt;
    rep(i,0,H) rep(j,0,W) cnt[s[i][j]]++;
    need[2] = (H / 2) * (W / 2);
    need[1] = (H % 2) * (W / 2) + (H / 2) * (W % 2);
    need[0] = (H % 2) * (W % 2);
    for(auto e : cnt) {
        int x = e.se;
        need[0] -= x & 1;
        need[1] -= x >> 1 & 1;
        need[2] -= x >> 2;
    }
    bool ok = true;
    per(i,0,3) {
        if(need[i] < 0 && i) need[i - 1] += need[i] * 2 , need[i] = 0;
        ok &= need[i] <= 0;
    }
    puts(ok ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=998244353;
int n,m,a[405],b[405],i,j,k,l;
long long f[405][405][405],sa,sb,s,ans,inv[505];
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		s=s*s%M;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d %d",&a[i],&b[i]);
	f[0][0][0]=-1;
	for(i=1;i<=500;i++)
		inv[i]=qpow(i,M-2);
	for(i=1;i<=n;i++)
	{
		sa+=a[i];
		sb+=b[i];
		for(j=0;j<=sa;j++)
			for(k=0;k<=sb;k++)
			{
				s=1;
				f[i][j][k]=f[i-1][j][k];
				if(j>=a[i])
					for(l=0;l<=k&&l<b[i];l++)
					{
						f[i][j][k]=(f[i][j][k]-f[i-1][j-a[i]][k-l]*s)%M;
						s=s*a[i]%M*inv[l+1]%M;
					}
			}
	}
	for(i=1;i<=sa;i++)
	{
		s=1;
		for(j=0;j<=sb;j++)
		{
			ans=(ans+f[n][i][j]*qpow(qpow(i,M-2),j+1)%M*s%M*sa)%M;
			s=s*(j+1)%M;
		}
	}
	cout<<(ans%M+M)%M;
}

Measured memory_bytes: 512256
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>

using namespace std;
using record = tuple<int, int>;

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

  vector<record> records;
  for (long i = 0; i < n; i++) {
    int count;
    cin >> count;
    records.push_back({ i + 1, count });
  }

  sort(
    records.begin(),
    records.end(),
    [](record a, record b) { return get<1>(a) < get<1>(b); }
  );

  for (long i = 0; i < records.size(); i++) {
    cout << get<0>(records[i]);
    if (i != records.size()) {
      cout << " ";
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1780
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	int N, K;
	cin >> N >> K;
	vector<LL> X(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
	}
	LL ans = LINF;
	for (int i = 0; i + K-1 < N; ++i) {
		LL res = X[i + K - 1] - X[i];
		res += min(abs(X[i + K - 1]), abs(X[i]));
		chmin(ans, res);
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stdio.h>
#define M 1000400
using namespace std;
char H[M][14];

int h1(int key) {
	return key % M;
}

int h2(int key) {
	return 1 + (key % (M - 1));
}

int getChar(char ch) {
	if (ch == 'A') { return 1; }
	if (ch == 'C') { return 2; }
	if (ch == 'G') { return 3; }
	if (ch == 'T') { return 4; }
	return 0;
}

long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += getChar(str[i])*p;
		p *= 5;
	}
	return sum;
}

bool insert(char str[]) {
	long long key = getKey(str),h;
	int i;
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(str, H[h]) == 0) { return 1; }
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

bool find(char str[]) {
	long long key = getKey(str), h;
	int i;
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(str, H[h]) == 0) { return 1; }
		else if (strlen(H[h]) == 0) {
			return 0;
		}
	}
	return 0;
}

int main() 
{
	int n;
	cin >> n;
	char str[14],operation[7];
	for (int i = 0; i < n; i++) {
		cin >> operation;
		cin >> str;
		if (operation[0] == 'i') {
			insert(str);
		}
		if (operation[0] == 'f') {
			if (find(str)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}
}


Measured memory_bytes: 16680
import sys 
from collections import defaultdict 
 
class Graph: 
 
    def __init__(self): 
        global n
        self.graph = defaultdict(list) 
        self.parent = [None for i in range(0,n+1)]
    def addEdge(self,u,v): 
        self.graph[u].append(v) 
    def BFS(self, s): 
        visited = [False] * (len(self.graph)+1) 
        queue = [] 
        queue.append(s)   
        while queue: 
            s = queue.pop(0) 
            
            # print (s, end = " ") 
            for i in self.graph[s]: 
                
                if visited[i] == False: 
                    self.parent[i]=s
                    queue.append(i) 
                    visited[i]=True
            

[n,m]=[int(i) for i in input().split(' ')]
g = Graph() 
for i in range(0,m):
    [a,b]=[int(i) for i in input().split(' ')]
    g.addEdge(a,b)
    g.addEdge(b,a)
# print(g.graph)
g.BFS(1)
flag=0
for i in range(2,n+1):
    if g.parent[i]==None:
        print('No')
        flag=1
        break

if flag==0:
    print('Yes')
    for i in range(2,n+1):
        print(g.parent[i])
        9
   

Measured memory_bytes: 39316
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

string addString(string a,string b ){
	if(a.size()<b.size())swap(a,b);         //len(a)>len(b)???
	b = string(a.size()-b.size(),'0')+b;    //b????????????a??¨??????????????????????????????0??§?????????
	
	string ans = string(a.size()+1,'0');    //a?????????+1 ?????????0??§???????????????
	for(int i=(int)a.size()-1;i>=0;i--){    //?¶??????? & ??°????????????
		ans[i+1] += (a[i]-'0') + (b[i]-'0');
		if(ans[i+1]>='0'+10){
			ans[i] += 1;
			ans[i+1] -= 10;
		}
	}
	string ret = "";                        //??????????????°???0????¶????
	rep(i,ans.size()){
		if(ans[i]!='0'||i==ans.size()-1){
			ret = ans.substr(i,ans.size()-i);
			break;
		}
	}
	return ret;
}


int main(){
	int n;
	cin>>n;
	rep(i,n){
		string a,b;
		cin>>a>>b;
		string res = addString(a,b);
		if(res.size()>80)cout<<"overflow"<<endl;
		else cout<<res<<endl;
	}
}

Measured memory_bytes: 3220
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int res = 0;
        for(int i=0; i < N; i+=2)
          if(arr[i]%2 == 1) res++;
        System.out.println(res);
      }
   }

Measured memory_bytes: 32720
import itertools
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X,Y,Z,K = IL()
a = IL()
b = IL()
c = IL()

ab = []
for i in itertools.product(a,b):
  ab.append(sum(i))
ab.sort(reverse=True)

ans = []
for i in itertools.product(ab[:3000],c):
  ans.append(sum(i))
ans.sort(reverse=True)

for i in range(K):
  print(ans[i])

Measured memory_bytes: 142640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), q = sc.nextInt();
        String s = sc.next();
        int[] cnt = new int[n + 1];
        for (int i = 0; i < n - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                cnt[i + 2] += 1;
            }
        }

        for (int i = 1; i <= n; i++) {
            cnt[i] += cnt[i - 1];
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt(), r = sc.nextInt();

            int ans = cnt[r] - cnt[l - 1];
            if (s.charAt(l - 1) == 'C' && l >= 2 && s.charAt(l - 2) == 'A') ans--;
            System.out.println(ans);
        }
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 69316
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int ans=0;
  rep(i,k)ans+=a[n-1-i];
  cout<<ans<<endl;

}


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

typedef long long ll;
typedef long double ld;

int main(){
  string a,b;
  cin >> a >> b;
  bool same = true;
  if(b.size()>a.size()){
    for(ll i=0;i<a.size();i++){
      if(b[i]!=a[i]){
        same = false;
      }
    }
  }
  else{
    cout << "No";
  }
  if(same){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
ll A, B;
ll h[100000];

bool cond(ll x){
    ll count = 0;
    rep(i, N){
        ll r = h[i] - B * x;
        if(r > 0) count += 1 + (r - 1) / (A - B);
    }
    return count > x; // failed
}

// cond -- smaller is easier
ll binarySearch(){
    ll M = 1000000001;
    ll left = 0;
    ll right = M;

    if(!cond(0)) return 0;
    if(cond(M-1)) return M;

    while (left + 1 < right){
        int mid = (left + right) / 2;
        if(cond(mid)) {
            left = mid;
        }
        else{
            right = mid;
        }
    }
    return right;
}

int main() {
    cin >> N >> A >> B;
    rep(i, N) cin >> h[i];
    ll ret = binarySearch();
	cout << ret << endl;
}

Measured memory_bytes: 1024
def sq(n_left,num_min,list_p = []):
  if n_left == 0:
    print(" ".join(list(map(str,list_p))))
    return 0
  for i in range(min(num_min,n_left),0,-1):
    list_p.append(i)
    sq(n_left - i, i ,list_p)
    list_p.pop()

while(True):
  n = int(input())
  if n == 0:
    break
  sq(n,n)


Measured memory_bytes: 5724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    ll d[N][N];
    rep(i, N) rep(j, N) cin >> d[i][j];
    ll ans = 0;
    rep(i, N) rep(j, N){
        if(i >= j) continue;
        ll m = INF;
        rep(k, N){
            if(k == i || k == j) continue;
            m = min(m, d[i][k]+d[k][j]);
        }
        if(m < d[i][j]) {cout << -1 << endl; return 0;}
        if(m > d[i][j]) ans += d[i][j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
#define pll pair<ll,ll>

ll H,W,K;
vector<pll> ys[101010];
ll anum[101010];
ll dp[111][8];
ll i, j, k,l;
int main(){
    scanf("%lld%lld%lld",&H,&W,&K);

    dp[0][0] = 1;
    fornum(i,0,H){
        fornum(j,0,(1<<(W-1))){
            bool flag = false;
            fornum(k,0,W){
                if((j&(1<<k))&&(j&(1<<(k+1)))){
                    flag = true;
                    break;
                }
            }
            if(flag)
                continue;
            fornum(k,0,W){
                if(0<k&&(j&(1<<(k-1)))){
                    dp[i + 1][k - 1] = (dp[i + 1][k - 1] + dp[i][k])%MOD;
                }else if(k<W-1&&(j&(1<<k))){
                    dp[i + 1][k + 1] = (dp[i + 1][k + 1] + dp[i][k])%MOD;
                }else{
                    dp[i + 1][k] = (dp[i + 1][k] + dp[i][k])%MOD;
                }
            }
            
        }
    }
    
    printf("%lld\n", dp[H][K - 1]);
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;

string s;

signed main() {
    cin >> s;
    rep(i,s.size()) if (s[i] == '7') {
        Yes
        return 0;
    }
    No
}





Measured memory_bytes: 3632
def is_bad_nums(j: int, d: []) -> bool:
    while j:
        if j % 10 in d:
            return True
        j //= 10
    return False


def answer(n: int, k: int, d: []) -> int:
    for i in range(n, 100000):
        if is_bad_nums(i, d):
            continue
        return i


def main():
    n, k = map(int, input().split())
    d = list(map(int, input().split()))
    print(answer(n, k, d))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9084
using System;
using System.Linq;

namespace ABC132B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int cnt = 0;
            for (int i = 1; i < n-1; i++)
            {
                int x = p[i];
                int[] subarr = { p[i - 1], p[i], p[i + 1] };
                if (subarr.OrderBy(e=>e).ToArray()[1] == x)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13396
program teleporter
  implicit none
  integer :: n, a(200000) = 0, i, v = 1
  integer(8) :: k, cnt(200000) = -1_8, c = 0_8
  read(*,*) n, k
  read(*,*) a(1:n)
  do
    if (cnt(v) >= 0_8) exit
    cnt(v) = c
    v = a(v)
    c = c+1_8
    if (c == k) then
      write(*,'(i0)') v
      stop
    end if
  end do
  k = mod(k-cnt(v),c-cnt(v))
  do i = 1, n
    if (cnt(i)-cnt(v) == k) then
      write(*,'(i0)') i
      stop
    end if
  end do
end program teleporter

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

int main(){
#ifdef LOCAL
	freopen("inp.txt", "r", stdin );
	freopen("ans.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if(s=="SUN") cout << 7 << '\n';
	if(s=="MON") cout << 6 << '\n';
	if(s=="TUE") cout << 5 << '\n';
	if(s=="WED") cout << 4 << '\n';
	if(s=="THU") cout << 3 << '\n';
	if(s=="FRI") cout << 2 << '\n';
	if(s=="SAT") cout << 1 << '\n';
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		int[]h = new int [N];
		for(int i=0;i<N;i++) {
			h[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(h);

		int x = 1000000001;

		for(int i=0;i<N-K+1;i++) {
			if(x > h[i+K-1]-h[i]) {
				x = h[i+K-1]-h[i];
			}

		}
		System.out.println(x);
	}

}


Measured memory_bytes: 49732
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <queue>

#define INF 214748364

using namespace std;

struct edge { int from,to,cost;};

int main(){
	int V,E,r,
	    s,t,d,
	    score[1000];
	vector<edge> G;
	bool nl=true;
	
	scanf("%d %d %d",&V,&E,&r);
	for(int i=0;i<E;i++){
		scanf("%d %d %d",&s,&t,&d);
		G.push_back( {s,t,d} );
	}
	
	fill(score , score + V , INF);
	score[r] = 0;
	
	for(int i=0;i<V;i++){
		for(int j=0;j<E;j++){
			edge e = G[j];
			if(score[e.from] != INF && score[e.to] > score[e.from]+e.cost){
				score[e.to] = score[e.from]+e.cost;
				if(i == V-1) nl=false;
			}
		}
	}
	
	if(nl){
		for(int i=0;i<V;i++){
			if(score[i]==214748364) printf("INF\n");
			else printf("%d\n",score[i]);
		}
	}
	else printf("NEGATIVE CYCLE\n");
		
	return 0;
}


Measured memory_bytes: 3304
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <cstring>
using namespace std;

const int maxn = 50 + 7;

bool mat[maxn][maxn];
int a[maxn], b[maxn];
int o[maxn];
int n, tail;
bool ok(int up) {
	for (int i = 0; i <= 50; i++) 
		for (int j = 0; j <= 50; j++) 
			mat[i][j] = (i == j) ? 1:0;
	
	for (int k = 1; k <= up; k++) {
		for (int i = 0; i <= 50; i++) 
			for (int j = 0; j <= 50; j++) 
				if (mat[i % k][j]) 
					mat[i][j] = true;	
	}
	for (int k = tail - 1; k >= 0; k--) {
		for (int i = 0; i <= 50; i++) 
			for (int j = 0; j <= 50; j++) 
				if (mat[i % o[k]][j]) 
					mat[i][j] = true;	
	}
	
	
	for (int i = 1; i <= n; i++) 
		if (!mat[ a[i] ][ b[i] ]) return false;
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
	
	if (!ok(50)) {
		printf("-1\n");
		return 0;
	}
	
	long long ans = 0;
	for (int i = 50; i >= 1; i--) {
		if (!ok(i - 1)) {
			ans += (1LL << i);
			o[tail++] = i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val R, S, P = in.next().toInt
  val T = in.next().toArray

  //
  val hash = Map(
    'r' -> P,
    's' -> R,
    'p' -> S
  )

  var ans = 0L
  for (k <- 0 until K) {
    var i = k
    var pre = '1'
    while (i < N) {
      val c = T(i)
      if(pre == c) {
        pre = '1'
      }
      else {
        ans += hash(c)
        pre = c
      }

      i += K
    }
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 29356
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e;
    while(cin >> a >> b){
    c = a + b;
    d = a - b;
    e = a * b;
    if(c > d){
	    int x = c; c = d; d = x;
	}   
    	 
    if(d > e){
    	int x = e; e = d; d = x;
		}
	cout << e << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main() {
    string S;
    cin >> S;
    ll mi=MOD;
    rep(i,S.size()-2){
      if(abs(stoi(S.substr(i,3))-753)<mi){
        mi=abs(stoi(S.substr(i,3))-753);
      }
    }
    cout << mi << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main() {
  std::string s;
  std::cin >>s;
  std::string sep[] = {"dream", "dreamer", "erase", "eraser"};
  int dp[100100] = {};
  dp[0] = 1;
  for(int i=0;i < s.size(); ++i) {
    if(dp[i]) {
      for(std::string t : sep) {
        bool f = true;
        for(int j=0;j < t.size(); ++j) {
          f = (s[i+j]==t[j]?true:false);
          if(!f)break;
        }
        (f?dp[i+t.size()]=1:0);
      }
    }
  }
  std::cout << (dp[s.size()]?"YES":"NO") << "\n";
}


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

using namespace std;
#define ll long long
#define mod 1000000007

ll powx(ll x){
    if(x==0){
        return 1;
    }else{ 
        ll y=powx(x/2);
        if(x%2==0){
            return ((y%mod)*(y%mod))%mod;
        }else{
            return ((y%mod)*(y%mod)*2)%mod;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y,z,p,q,r,s,t;
    string a,b,c;
    cin>>x>>y;
    char ar[x][y];
    for(ll i=0;i<x;i++){
        for(ll j=0;j<y;j++){
            cin>>ar[i][j];
        }
    }
    ll arr[x][y];
    p=1;
    for(ll i=0;i<y;i++){
        if(ar[0][i]=='.'&&p==1){
            arr[0][i]=1;
        }else{
            arr[0][i]=0;
            p=0;
        }
    }
    p=1;
    for(ll i=0;i<x;i++){
        if(ar[i][0]=='.'&&p==1){
            arr[i][0]=1;
        }else{
            arr[i][0]=0;
            p=0;
        }
    }
    for(ll i=1;i<x;i++){
        for(ll j=1;j<y;j++){
            if(ar[i][j]=='#'){
                arr[i][j]=0;
            }else{
                arr[i][j]=(arr[i-1][j]+arr[i][j-1])%mod;
            }
        }
    }
    cout<<arr[x-1][y-1]<<endl;
    return 0;
}


Measured memory_bytes: 9088
from functools import reduce
import fractions
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
N = int(input().rstrip())
As = input().rstrip().split(" ")
As = [int(p) for p in As]
 
cand = lcm_list(As)
 
sum = 0
 
for num in As:
    sum = sum + cand // num
 
print(sum % (10**9 + 7) )

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

int main() {
 string S;
 cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
import numpy as np

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

# cumsum
i = 0
A_sum = [0]
while (i < len(A)) and (A_sum[i] + A[i] <= K):
    A_sum.append(A_sum[i] + A[i])
    i += 1
    
i = 0
B_sum = [0]
while (i < len(B)) and (B_sum[i] + B[i] <= K):
    B_sum.append(B_sum[i] + B[i])
    i += 1

# count
max_book = 0
ind = len(B_sum) - 1
for i in range(len(A_sum)):
    while (A_sum[i] + B_sum[ind] > K) and (ind > 0):
        ind -= 1
    if i + ind > max_book:
        max_book = i + ind

print(max_book)

Measured memory_bytes: 58864
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val xs = StdIn.readLine().split(' ').map(_.toDouble)
  val ys = StdIn.readLine().split(' ').map(_.toDouble)
  
  def pat1(): Double = (xs zip ys).foldLeft(0D){ (acc, xy) =>
      acc + scala.math.abs(xy._1 - xy._2)
  }

  def pat2(): Double = (xs zip ys).foldLeft(0D){ (acc, xy) =>
    acc + scala.math.pow(scala.math.abs(xy._1 - xy._2), 2)
  }

  def pat3(): Double = (xs zip ys).foldLeft(0D){ (acc, xy) =>
    acc + scala.math.pow(scala.math.abs(xy._1 - xy._2), 3)
  }

  def patL(): Double = (xs zip ys).foldLeft(0D){ (acc, xy) =>
    if(acc > scala.math.abs(xy._1 - xy._2)) acc else scala.math.abs(xy._1 - xy._2)
  }

  val r1 = pat1()
  val r2 = scala.math.sqrt(pat2())
  val r3 = scala.math.cbrt(pat3())
  val rL = patL()

  println(f"$r1%.6f")
  println(f"$r2%.6f")
  println(f"$r3%.6f")
  println(f"$rL%.6f")
  
}


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

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n, m;
    cin >> n >> m;
    cout << (n * (n - 1) / 2 + m * (m - 1) / 2) << '\n';
}



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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int N;
    cin >> N;
    string S[N];
    REP(i, N) {
    	cin >> S[i];
    }

    map<char, int> count_map[N];
    for (int i = 0; i < N; ++i) {
	    for (char c = 'a'; c <= 'z'; ++c) {
	    	count_map[i][c] = 0;
	    }
	    for (int j = 0; j < S[i].size(); ++j) {
	    	count_map[i][S[i][j]]++;
	    }
	}

	map<char, int> min_map;
	for (char c = 'a'; c <= 'z'; ++c) {
	    	min_map[c] = 100;
	}
	for (int i = 0; i < N; ++i) {
	    for (char c = 'a'; c <= 'z'; ++c) {
	    	min_map[c] = min(min_map[c], count_map[i][c]);
	    }
	}

	string ans = "";
	for (char c = 'a'; c <= 'z'; ++c) {
	   for (int i = 0; i < min_map[c]; ++i) {
	   		ans += c;
	   }
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  while(cin >> a >> b){
    string ab = a + b;
    stringstream ss;
    ss << ab;
    int num;
    ss >> num;
    bool ans = false;
    REP(i,330){
      if(i * i == num) ans = true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n%2==0)
        cout<<n<<endl;
    else 
        cout<<n*2<<endl;
    return 0;
}
/*
4
128 4 340
*/



Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>

using namespace std;
map<char, int> m;
string s;

int main(){
    cin >> s;
    for(int i=0;i<s.length();i++){
        m[s[i]]++;
    }
    bool ans=true;
    for(char i='a';i<='z';i++){
        if(m[i]%2 != 0){
            ans=false;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.reset().nextLong();
    long a = sc.reset().nextLong();
    long b = sc.reset().nextLong();
    sc.close();

    long ab = a + b;
    long p = n / ab;
    long q = n % ab;
    long o = (p * a) + (q > a ? a : q);

    System.out.println(o);
  }
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    cout << n * (n-1) / 2 + m * (m-1) / 2 << endl;
        
    return 0;
}

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

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll a,b,c;
	string s;

	cin >> a >> b >> c;



	cout << c << " " << a << " " << b << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		int sn = Integer.parseInt(br.readLine());
		List<Integer> slist = Arrays.stream(br.readLine().split(" "))
				.map(Integer::parseInt)
				.collect(Collectors.toList());
		int qn = Integer.parseInt(br.readLine());
		List<Integer> qlist = Arrays.stream(br.readLine().split(" "))
				.map(Integer::parseInt)
				.collect(Collectors.toList());
		
		int count = 0;
		for(int q: qlist){
			if(binarySearch(slist, q, Comparator.naturalOrder()) != -1){
				count++;
			}
		}
		
		System.out.println(count);
	}
	
	public static <T> int binarySearch(List<T> list, T target, Comparator<T> comp){
		int left = 0;
		int right = list.size();
		while(left < right){
			int mid = (left + right) / 2;
			int c = comp.compare(list.get(mid), target);
			if(c == 0){
				return mid;
			}else if(c < 0){
				left = mid + 1;
			}else{
				right = mid;
			}
		}
		return -1;
	}
}


Measured memory_bytes: 62816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
int main()
{
    ll n,i,j,x=0,y=0;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    for(i=n-1;i>0;i--)
    {
        if(a[i]==a[i-1])
            {
                x=a[i];
                i-=2;
                break;
            }
    }
    //printf("%d",i);
    for(j=i;j>0;j--)
    {
        if(a[j]==a[j-1])
            {
                y=a[j];
                j--;
                break;
            }
    }
    printf("%lld",x*y);


    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> gr={0,2,0,1,0,1,0,0,1,0,1,0};
  int x,y;
  cin>>x>>y;
  if(gr[x-1]==gr[y-1])
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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

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

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

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,t;
    cin >> n >> t;
    ll c[n], ti[n];
    F0R(i,n) cin >> c[i] >> ti[i];
    ll mn = 10002;
    F0R(i,n){
      if(mn > c[i] && ti[i] <= t) mn = c[i];
    }
    if(mn == 10002) cout << "TLE"<<endl;
    else cout << mn<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256