akhauriyash/Code-Regression huggingface dataset:
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int tc;
    tc=1;
	//cin>>tc;
	for(int t=1;t<=tc;t++)
	{
        int n;
        cin>>n;
        int x = 1000 - (n%1000);
        cout<<x%1000;
	}

return 0;
}

Measured memory_bytes: 3644
N, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

ans = 0
(N - 1).times do |i|
  next if a[i] + a[i+1] <= x
  y = a[i] + a[i+1] - x
  ans += y
  a[i+1] = [0, a[i+1] - y].max
end

p ans


Measured memory_bytes: 11140
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n;
int a[111][3];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i][1]>>a[i][2];
  int st=0;
  for(int i=1;i+2<=n;i++){
    st|=(a[i][1]==a[i][2] && a[i+1][1]==a[i+1][2] && a[i+2][1]==a[i+2][2]);
  }
  if(st)cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3632
# include<iostream>
# include<cstring>
using namespace std;
int main ()
{
	 string s;
	 cin>>s;
	 int k;
	 cin>>k;
	 if(s.length()==1)
	 {
	 	 cout<<k/2<<endl;
	 	 return 0;
	 }
	 bool isallsame = true;
	 for(int i=1;i<s.length();i++)
	 {
	 	  if(s[i]!=s[0])
	 	  {
	 	  	isallsame = false;
		   }
	 }
	 
	 if(isallsame==true)
	 {
	 	 cout<<s.length()*k/2<<endl;
	 	 return 0;
	 }
	 
	 long long  sum =0;
	 for(int i=0;i<s.length();)
	 {
	 	 int j=i+1;
	 	 int l=0;
	 	 while(j<s.length()&&s[j]==s[i])
	 	 {
	 	 	 j++;
	 	 	 l++;
		  }
		  //cout<<"l="<<l<<endl;
		  i=j;
		  sum += (l+1)/2;
	 }
	 char s1[200];
	 for(int i=0;i<2*s.length();i++)
	 {
	 	 
	 	  s1[i] =s[i%s.length()];
	 	  
	 }
	 
	 long long  sum1 =0;
	 for(int i=0;i<strlen(s1);)
	 {
	 	 int j=i+1;
	 	 int l=0;
	 	 while(j<strlen(s1)&&s1[j]==s1[i])
	 	 {
	 	 	 j++;
	 	 	 l++;
		  }
		  //cout<<"l="<<l<<endl;
		  i=j;
		  sum1 += (l+1)/2;
	 }	
	 
	 
	 long long sum2 = sum + (sum1-sum)*(k-1);
	 cout<<sum2<<endl;
	 
 } 

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (a, b, q) = readIntegerList()
    val jinja = LongArray(a) { readLong() }
    val tera = LongArray(b) { readLong() }
    repeat(q) {
        val x = readLong()

        var right = a
        var left = -1
        while (right - left > 1) {
            val mid = (right + left) / 2
            if (jinja[mid] > x) right = mid else left = mid
        }

        var rightb = b
        var leftb = -1
        while (rightb - leftb > 1) {
            val mid = (rightb + leftb) / 2
            if (tera[mid] > x) rightb = mid else leftb = mid
        }

        var ans = if (right in jinja.indices && rightb in tera.indices)
            max(jinja[right], tera[rightb]) - x else Long.MAX_VALUE

        if (right in jinja.indices && (rightb - 1) in tera.indices) {
            ans = min(ans, (jinja[right] - x) * 2 + x - tera[rightb - 1])
            ans = min(ans, (x - tera[rightb - 1]) * 2 + jinja[right] - x)
        }

        if ((right - 1) in jinja.indices && rightb in tera.indices) {
            ans = min(ans, (x - jinja[right - 1]) * 2 + tera[rightb] - x)
            ans = min(ans, (tera[rightb] - x) * 2 + x - jinja[right - 1])
        }

        ans = if ((right - 1) in jinja.indices && (rightb - 1) in tera.indices)
            min(ans, x - min(jinja[right - 1], tera[rightb - 1])) else ans

        out.println(ans)
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 62356
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    N, K = map(int, sysread().split())
    ans = 0
    for b in range(K+1, N+1):
        if K == 0:
            ans -= 1
        count = b-1 -K + 1
        alpha = (N-b+1) % b
        prim_add = (N-b+1) // b + 1
        prim = b-1 - alpha + 1
        if count <= prim:
            ans += count * prim_add
            continue
        ans += prim * prim_add
        L = (count - prim) // b
        resid = (count - prim) % b
        ans += ((prim_add + 1 + (L+prim_add)) * L // 2) * b
        ans += (L+ prim_add + 1) * resid

    print(ans)
if __name__ == "__main__":
    run()


Measured memory_bytes: 9240
# coding: utf-8
# Your code here!
import math

L = [int(i) for i in input().split()]
A=L[0]
B=L[1]
H=L[2]
M=L[3]
H_deg=(H/12)*360+(M/60)*30
M_deg=(M/60)*360
if abs(H_deg-M_deg)>abs(M_deg-H_deg):
    deg=abs(M_deg-H_deg)
else:
    deg=abs(H_deg-M_deg)
# print(deg)
AN=A*A+B*B-2*A*B*math.cos(math.radians(deg))
ANS=math.sqrt(AN)
print('{:.9f}'.format(ANS))

Measured memory_bytes: 9332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int a,b,flag=1;
    string s;
    cin >> a >> b >> s;
    rep(i,a)if(s[i]=='-')flag=0;
    if(s[a]!='-')flag=0;
    rep(i,b)if(s[i+a+1]=='-')flag=0;
    cout << (flag?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n, k;
  cin >> n >> k;
  V<int> l(n);

  rep(i, n) {
    cin >> l[i];
  }

  sort(l.rbegin(), l.rend()) ;

  int ans = 0;
  rep(i, k) {
    ans += l[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    const double rad=180.0/3.14159265358979323;
    double a,b,wat;
    cin>>a>>b>>wat;
    int air=a*a*b-wat;
    if(air*2.0<=a*a*b)printf("%.10lf\n",atan2(air*2.0/(a*a),a)*rad);
    else printf("%.10lf\n",atan2(b,2.0*wat/(a*b))*rad);
    return 0;
}


Measured memory_bytes: 4088
import sys

x, n = map(int, input().split())

if n == 0:
  print(x)
  sys.exit()

p = set(map(int, input().split()))

q = set(range(102))

r = q - p

ans = 0
diff = 1000

for i in r:
  if abs(x - i) < diff:
    diff = abs(x - i)
    ans = i
    
print(ans)



Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Look at me please ... that's what she said
#define MOD 1000000007
using namespace std;
const int INF = 1e6 + 9;
int main(){
    ios::sync_with_stdio(false);
    //cin.tie(0); ///activate when submit
    ll n;
    cin>>n;
    cout<<n*n<<endl;
    return 0;
}    

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/abc144/tasks/abc144_a

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {

    int A, B;
    cin >> A >> B;
    
    if(A>9||B>9) {
        print(-1);
    } else {
        print(A*B);
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50


def run():
    S = input()
    ans = 0
    max_val = 0
    for s in S:
        if s == 'R':
            ans += 1
            max_val = max(max_val, ans)
        else:

            ans = 0
    print(max_val)

if __name__ == "__main__":
    run()

Measured memory_bytes: 26936
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",(b-a)*2+a);
	return 0;
}

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

#define MAX_N 100000
#define MAX_NUM 10

string S, T, U, V, pass;
int t[MAX_N + 1][3];
int u[MAX_N + 1][3];
int v[MAX_N + 1], cnt;
char W[MAX_NUM + 2] = "0123456789X";

int main() {
	while (cin >> S)
	{
		pass = "";
		T = ""; U = ""; V = "";
		memset(t, 0, sizeof(t));
		memset(u, 0, sizeof(u));
		memset(v, 0, sizeof(v));
		cnt = 0;
		S += ' ';
		for (int i = 0; i < S.size(); i++)
		{
			if (S[i] == '+')
			{
				T = pass;
				pass = "";
			}
			else if (S[i] == '=')
			{
				U = pass;
				pass = "";
			}
			else if (S[i] == ' ')
			{
				V = pass;
				pass = "";
			}
			else
			{
				pass += S[i];
			}
		}
		for (int i = 0; i < T.size(); i++)
		{
			for (int j = 0; j < MAX_NUM + 1; j++)
			{
				if (W[j] == T[i])
				{
					t[T.size() - 1 - i][0] = j;
				}
			}
		}
		for (int i = 0; i < U.size(); i++)
		{
			for (int j = 0; j < MAX_NUM + 1; j++)
			{
				if (W[j] == U[i])
				{
					t[U.size() - 1 - i][1] = j;
				}
			}
		}
		for (int i = 0; i < V.size(); i++)
		{
			for (int j = 0; j < MAX_NUM + 1; j++)
			{
				if (W[j] == V[i])
				{
					t[V.size() - 1 - i][2] = j;
				}
			}
		}
		for (int h = 0; h < MAX_NUM; h++)
		{
			if (h == 0)
			{
				if (V[0] == 'X' && V.size() >= 2)
				{
					goto F;
				}
				if (U[0] == 'X' && U.size() >= 2)
				{
					goto F;
				}
				if (T[0] == 'X' && T.size() >= 2)
				{
					goto F;
				}
			}
			for (int i = 0; i < MAX_N; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					if (t[i][j] == MAX_NUM)
					{
						u[i][j] = h;
					}
					else {
						u[i][j] = t[i][j];
					}
				}
			}
			for (int i = 0; i < MAX_N; i++)
			{
				v[i] = 0;
			}
			for (int i = 0; i < MAX_N; i++)
			{
				v[i] += u[i][0] + u[i][1];
				if (v[i] >= MAX_NUM)
				{
					v[i] -= 10;
					v[i + 1]++;
				}
			}
			for (int i = 0; i < MAX_N; i++)
			{
				if ((u[i][2] != v[i]) || (u[i][2] == MAX_NUM && v[i] == h))
				{
					goto F;
				}
			}
			cout << h << endl;
			cnt++;
		F:;
		}
		if (cnt == 0)
		{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 3936
n = int(input())
nlen =len(str(n))
ans = 0
 
if n <= 9:
  print(n)
else:
  for i in range(1,nlen):
    if i % 2 == 1:
      ans += 10 ** i -10 ** (i-1)
  if nlen % 2 == 1:
    ans = ans + (n - 10**(nlen-1) + 1)
  print(ans)

Measured memory_bytes: 9052
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ab = a + b;
    int cd = c + d;
    if (ab > cd) {
        cout << "Left\n";
    } else if (ab == cd) {
        cout << "Balanced\n";
    } else {
        cout << "Right\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_n=1e5+100;
const ll inf=0x3f3f3f3f;
int t,n,a[max_n],dp[max_n],k;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=inf;
        for(int j=1;j<=k;j++){
            if(i-j>=0) {
                dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
            }else break;
        }
    }cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 4420
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    ll n,k;
    cin>>n>>k;
    if(k%2!=0){
        cout<<(n/k)*(n/k)*(n/k)<<"\n";
    }
    else {
        ll a=0,b=0;
        for(int i=1;i<=n;++i){
            if(i%k==0)++a;
            else if(i%k==k/2)++b;
        }
        cout<<a*a*a+b*b*b<<"\n";
    }
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
/**
?????§?????????????????????

??\????????????????????????H cm ?????? W cm
????????§????????????????????¢?????????????????°?????????????????????????????????

#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
?????????????????? 6 cm ?????? 10 cm ???????????¢?????¨??????????????????

????????¢???????????? "#" ??¨????????????????????????????????????

Input
??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????

H W

H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????

Output
?????????????????????????????????????????? H cm ?????? W cm ?????????????????????????????????

?????????????????????????????????????????????????????\??????????????????

Constraints
1 ??? H, W ??? 300

Sample Input
3 4
5 6
3 3
2 2
1 1
0 0
Sample Output
#.#.
.#.#
#.#.

#.#.#.
.#.#.#
#.#.#.
.#.#.#
#.#.#.

#.#
.#.
#.#

#.
.#

#
 */

#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  unsigned int H, W;

  while (true) {
    while (true) {
      std::string Param;

      getline(std::cin, Param);
      std::istringstream iss(Param);
      iss >> H >> W;

      if (H > 300 || W > 300) {
        std::cout << "Error: 1 <= H, W <= 300" << std::endl;
      } else {
        break;
      }
    }
    if (H == 0 && W == 0) {
      break;
    } else {
      std::string FirstChar, NextChar;

      for (size_t i = 0; i < H; i++) {
        if (i % 2) {
          FirstChar = ".";
          NextChar = "#";
        } else {
          FirstChar = "#";
          NextChar = ".";
        }
        for (size_t j = 0; j < W; j++) {
          if (j % 2) {
            std::cout << NextChar;
          } else {
            std::cout << FirstChar;
          }
        }
        std::cout << std::endl;
      }
      std::cout << std::endl;
    }
  }
  return 0;
}

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

int main() {
    int A, B;
    string op;
    cin >> A >> op >> B;
    if (op == "+") {
    cout << A+B << endl;
    }
    if (op == "-") {
    cout << A-B << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	vector<int> a(n + 2, 0);
	for (int i = 1; i < n + 1; ++i) cin >> a[i];

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

	for (int i = 1; i < n + 1; ++i) {
		int original_dist 
			= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
		int skipped_dist
			= abs(a[i + 1] - a[i - 1]);
		cout << allsum - original_dist + skipped_dist << "\n";
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

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

    int n = 1;
    if(D == 1) n = 100;
    else if (D == 2) n = 10000;

    if(N != 100) cout << N * n << endl;
    else cout << (N+1) * n << endl; 

    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

const ll MAX = (ll)1e16;

int main()
{
    ll K;
    cin >> K;

    ll t = std::max((MAX + K - 1) / MAX, (ll)2);
    ll n = K / t;
    ll m = K % t;
    vector<ll> v(t);
    REP(i, t)
    {
        if (i < m)
            v[i] = t - 1 + n + (t - (m - 1));
        else
            v[i] = t - 1 + n - m;
    }

    cout << t << endl;
    REP(i, t)
    {
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
A = sys.stdin.readline()
a = A.rstrip()
s = a.split(' ')
s1 = int(s[0]) + int(s[1])
s2 = int(s[0]) - int(s[1])
s3 = int(s[0]) * int(s[1])

print(max(s1,s2,s3))

Measured memory_bytes: 3060
# DPで解く方法
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = LI()
# dp[i][j] : i を選んで ai と ai + 1 の符号を反転(j = 0 させない, j = 1 させる)場合の a1 + a2 + ... + ai-1 + ai の最大値
dp = [[0] * 2 for _ in range(n + 1)]
dp[0][0] = 0  # dp[0] : 何も選んでいない（開始地点）
dp[0][1] = -float('inf')  # 定義されていないためすごい小さい値を入れる
for i in range(n):
    dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i])  # i + 1を選んで反転させない
    dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i])  # i + 1を選んで反転させる
print(dp[n][0])


Measured memory_bytes: 31232
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define c4(n,m,k,l) cin>>n>>m>>k>>l
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long b=0,c=0,d=0,e,n,m,x;
  c3(n,m,x);
  int a[n]={};
  rep(i,0,m){
    c(c);
    if(c<=x) b++;
    else d++;
  }
  co(min(b,d));
  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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 k = 0; k < N; k++) {
			b[k] = sc.nextInt();
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					if (b[k] == A[i][j]) {
						A[i][j] = 0;
					}
				}
			}
		}
		sc.close();

		if ((A[0][0] == A[1][0] && A[1][0] == A[2][0]) || (A[0][1] == A[1][1] && A[1][1] == A[2][1])
				|| (A[0][2] == A[1][2] && A[1][2] == A[2][2]) || (A[0][0] == A[0][1] && A[0][1] == A[0][2])
				|| (A[1][0] == A[1][1] && A[1][1] == A[1][2]) || (A[2][0] == A[2][1] && A[2][1] == A[2][2])
				|| (A[0][0] == A[1][1] && A[1][1] == A[2][2]) || (A[0][2] == A[1][1] && A[1][1] == A[2][0])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23124
#include<stdio.h>

int main(void){

 int a,b,c,i,n;

 scanf("%d %d %d",&a,&b,&c);

 n=0;

 for(i=a;i<=b;i++){

  if(c%i==0){

   n++;

  }

 }

 printf("%d\n",n);

 return 0;

}

 

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    string S;
    cin >> N >> S;
    if(N%2){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0; i<N/2; i++){
        if(S[i]!=S[i+N/2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN


int main(void){
	ll n,a[300010],ans=0;
	cin>>n;
	rep(i,3*n)cin>>a[i];
	sort(a,a+3*n);
	rep(i,n)ans+=a[3*n-2-i*2];//0-origin
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n,x,z=0;
    cin>>n;
    x=n;
    while(x!=0)
    {
        z=(z*10)+x%10;
        x/=10;
    }
    if(z==n)
        cout<<"Yes";
    else
        cout<<"No";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	

	void solve(){
		
		
		ini(n);
		ini(x);
		int tmp[n];
		FOR(i,0,n){
			in(tmp[i]);
		}
		int tmp1= 1;
		FOR(i,0,x){
			tmp1*=tmp[i];
		}
		int tmpx = tmp[0];
		FOR(i,x,n){
			// out((tmp1/tmpx)*tmp[i],tmp1);
			if(tmp[i]>tmp[i-x])out("Yes");
			else out("No");
			tmp1/=tmpx;
			tmp1*=tmp[i];
			tmpx = tmp[i-x+1];
		}
		

		
		


			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int rec(int n,int c)
{
    if(n==1)
    {
        ++c;
        return c;
    }
    c+=2*rec(n/2,c)+1;
    return c;
}
signed main()
{
    SPEED;
    int h;
    cin>>h;
    cout<<rec(h,0);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    S = input()
    Q = int(input())

    que = deque(S)

    rev = False
    for _ in range(Q):
        T = input()

        if len(T) == 1:
            rev = not rev
        else:
            t, F, C = T.split()
            # 先頭
            if int(F) == 1:
                if not rev:
                    que.appendleft(C)
                else:
                    que.append(C)
            # 末尾
            else:
                if not rev:
                    que.append(C)
                else:
                    que.appendleft(C)

    if rev:
        que = reversed(que)
    print(*que, sep="")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 108076
N,Q = map(int, input().split())
parentNodes = [0] * (N+1) #i番目のノードの親番号
counter = [0] * (N+1)

for i in range(N-1):
	a, b = map(int, input().split())
	parentNodes[b] = a
 
for _ in range(Q):
	p,x = map(int, input().split())
	counter[p] += x
 
for i in range(1,N+1):
	counter[i] += counter[parentNodes[i]]
 
print(*counter[1:])

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

using namespace std;

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

  int N,H,W; cin>>N>>H>>W;
  struct Panel {
    int r,c,a;
  };
  vector<Panel> panels(N);
  for (auto& p : panels) {
    cin >> p.r >> p.c >> p.a;
    p.r--; p.c--;
  }
  sort(panels.begin(), panels.end(), [](auto l, auto r) {return l.a > r.a;});

  struct Graph {
    int n = 1;
    int e = 0;
    void operator+=(const Graph& x) {
      n += x.n;
      e += x.e;
    }
  };
  vector<Graph> gdata(H+W);
  vector<int> parents(H+W);
  iota(parents.begin(), parents.end(), 0);
  auto root = [f=[&](auto root, int x) {
    if (parents[x] == x)
      return x;
    return parents[x] = root(root, parents[x]);
  }] (int x) {
    return f(f, x);
  };
  auto unite = [&](int rx, int ry) {
    if (rx > ry)
      swap(rx, ry);
    parents[ry] = rx;
  };
  auto check = [&](int x, int y) {
    auto rx = root(x);
    auto ry = root(y);
    if (rx == ry) {
      if (gdata[rx].e+1 <= gdata[rx].n) {
        unite(rx, ry);
        gdata[root(rx)].e++;
        return true;
      }
    } else {
      if (gdata[rx].e+gdata[ry].e+1 <= gdata[rx].n+gdata[ry].n) {
        unite(rx, ry);
        gdata[root(rx)] += gdata[root(rx)^rx^ry];
        gdata[root(rx)].e++;
        return true;
      }
    }
    return false;
  };

  long ans = 0;
  unordered_map<int, vector<int>> sr, sc;
  for (auto p : panels) {
    if (check(p.r, H+p.c)) {
      ans += p.a;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3840
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int a[n];
    forn(i,n)   cin>>a[i];
    int num=1, cnt=0;
    forn(i,n){
        if(a[i]==num){
            num++;
            continue;
        }
        else{
            cnt++;
        }
    }
    if(cnt<n)
        cout<<cnt<<endl;
    else
        cout<<-1<<endl;
    return 0;
}



Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol k, n; cin >> k >> n;
    vector<lol> a(n), b(n);
    REP(i, n)
    {
        cin >> a[i];
        if(i)
            b[i] = a[i] - a[i-1];
    }
    b[0] = a[0] + (k - a[n-1]);
    lol maxi = a[0];
    REP(i, n)
    {
        maxi = max(maxi, b[i]);
    }
    result = k - maxi;
    //cout << k << " " << maxi << endl;

    cout << result << endl;
    return 0;
}

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

int main()
{
    int n ;
    cin>>n ;
    vector<long long> v  ;
    for(int i = 0 ; i<n ; i++){
        long long x ;
        cin>>x ;
        v.push_back(x) ;
    }
    long long ans = 0 ;
    sort(v.begin(),v.end()) ;
    int i = 0 ;
    while(i<n){
        long long a = v[i] ;
        int cnt = 0 ;
        while(v[i] == a){
            cnt++ ;
            i++ ;
        }
        if(cnt%2 != 0) ans++ ;
    }
    cout<<ans<<endl ;
    return 0;
}


Measured memory_bytes: 1400
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
using namespace std;

signed main()
{
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int mn = min(A, B), mx = max(A, B);
    for (ri i = mn; i <= mx; ++i) {
        int now = A * i * B;
        if (now & 1) {
            return cout << "Yes" << endl, 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	if(x-r<0||y-r<0||x+r>w||y+r>h) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 584
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int n;
    cin>>n;
    
    int l[1000];
    int r[1000];
    
    int count=0;
    
    for(int i=0;i<n;i++){
        cin>>l[i]>>r[i];
        
        count+=r[i]-l[i]+1;
    }
    
    
    cout<<count<<endl;
    
   
    return 0;
}








Measured memory_bytes: 256
import math

r = 0

def format_input(filename = None):
	global r
	if filename == None:
		r = int(input())

	elif filename == '__random__':
		from random import randint as rng
		r = rng(1, 10**2)
		print(r)

def get_answer():
	answer = 2 * r * math.pi
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 9120
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
const int maxn=300000,maxt=maxn<<2;

int n,K,a[maxn+5],MAX[maxt+5];

#define EOLN(x) ((x)==10 || (x)==13 || (x)==EOF)
inline char readc(){
	static char buf[100000],*l=buf,*r=buf;
	return l==r && (r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<typename T> int readi(T &x){
	T tot=0;char ch=readc(),lst='+';
	while (!isdigit(ch)) {if (ch==EOF) return EOF;lst=ch;ch=readc();}
	while (isdigit(ch)) tot=(tot<<1)+(tot<<3)+(ch^48),ch=readc();
	lst=='-'?x=-tot:x=tot;return EOLN(ch);
}
void Insert(int pos,int F,int l=0,int r=maxn,int p=1){
	if (l==r) {MAX[p]=max(MAX[p],F);return;} int mid=l+(r-l>>1);
	if (pos<=mid) Insert(pos,F,l,mid,p<<1); else Insert(pos,F,mid+1,r,p<<1|1);
	MAX[p]=max(MAX[p<<1],MAX[p<<1|1]);
}
int Ask(int L,int R,int l=0,int r=maxn,int p=1){
	if (L==l && r==R) return MAX[p]; int mid=l+(r-l>>1);
	if (R<=mid) return Ask(L,R,l,mid,p<<1); else if (L>mid) return Ask(L,R,mid+1,r,p<<1|1);
	else return max(Ask(L,mid,l,mid,p<<1),Ask(mid+1,R,mid+1,r,p<<1|1));
}
int main(){
	readi(n);readi(K);
	for (int i=1;i<=n;i++) readi(a[i]);
	for (int i=1;i<=n;i++){
		int L=max(a[i]-K,0),R=min(a[i]+K,maxn);
		Insert(a[i],Ask(L,R)+1);
	}
	printf("%d\n",MAX[1]);return 0;
}

Measured memory_bytes: 6968
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

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


Measured memory_bytes: 3100
#define _GLIBCXX_DEBUG
#include <cstdio>
using namespace std;
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
#define FOR(i,x,y) for(int i=x;i<y;i++)
typedef long long ll;
int main() {
  ll a, b, x;
  ll y=0;
  scanf("%lld%lld%lld", &a, &b, &x);
  printf("%lld",  b/x-a/x + (a%x==0?1LL:0LL));
}

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


Measured memory_bytes: 4844
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


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

	int sum = 0;
	int m = INT_MIN;
	for(int i=0 ; i<n ; i++)
	{
		int temp;
		cin >> temp;
		sum += temp;
		m = max(m , temp);
	}

	if(m < sum-m)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int N;
	cin >> N;
	vector<LL> A(3 * N);
	REP(i, 3 * N) cin >> A[i];

	SORT(A);
	LL ret = 0;
	REP(i, N) ret += A[3 * N - 2 * i - 2];

	cout << ret << endl;


	return 0;
}


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

int main(void){
    // Your code here!
    int D;
    cin >> D;
    
    int c[27];
    int i=0;
    int j=0;
    for (i = 0; i<26; i++){
        cin >> c[i];
    }
    
    int s[D][26];
    for (i = 0; i<D;i++){
        for (j=0; j<26; j++){
            cin >> s[i][j] ;
        }
    }
    
    int t[D];
    for (i = 0; i<D; i++){
        cin >> t[i];
        t[i]--;
    }
    
    int day=0;
    int last[365][26] = {};
    long long int sat = 0;
    
    day = 0;
    last[day][t[day]] = day + 1;
    sat += s[day][t[day]];
    for (i= 0; i < 26; i++){
        sat -= c[i] * (day + 1 - last[day][i]);
    }
    cout << sat << endl;
    
    for (day = 1; day<D; day++){
        for (i = 0; i<26; i++){
            last[day][i] = last[day-1][i];
        }
        last[day][t[day]] = day + 1;
        sat += s[day][t[day]];
        
        for (i= 0; i < 26; i++){
            sat -= c[i] * (day + 1 - last[day][i]);
        }
        
        cout << sat << endl;
    }
    

}


Measured memory_bytes: 3664
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String arr[] = S.split("");
 		//int N = sc.nextInt();
		if (arr[2].equals(arr[3])&&arr[4].equals(arr[5])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
      	sc.close();
    }
		
		
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	long long sum = 0;
	long long len = s.size();
	for(long long i=0;i<len;i++){
			long long  t = i,js1=0,js2=0;
			while(1){
				if(t == len-1){
					if(s[t] == '<')
						js1++;
					else
						js2++; 
					break;
				}
				if(s[t] == '>' && s[t + 1]  == '<'){
					js2++;
					break;
				}
				if(s[t] == '>')
					js2++;
				else if(s[t] == '<')
					js1++;
				t++;
			}
			i = t;
			if(js1 <= js2){
				long long  ss1 = 0;
				sum += (ss1 + (js1-1)) * js1 / 2;
				long long  ss2 = 1;
				sum += (ss2 + js2) * js2 / 2; 
			}
			else{
				long long  ss1 = 1;
				sum += (ss1 + js1) * js1 / 2;
				long long  ss2 = 0;
				sum += (ss2 + (js2-1)) * js2 / 2;
			}
	} 
	printf("%lld\n",sum);
	return 0; 
}

Measured memory_bytes: 900
#include <iostream>
#include <fstream>
using namespace std;\
long long n, a[3005], F[3005][3005], S[3005];
int main()
{
    //freopen("DEQUE.INP", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) S[i] = S[i - 1] + a[i];

    for (int cnt = 0; cnt <= n - 1; cnt++)
        for (int i = 1; i <= n - cnt; i++)
        {
            int j = i + cnt;
            F[i][j] = S[j] - S[i - 1] - min(F[i + 1][j], F[i][j - 1]);
        }
    cout << 2 * F[1][n] - S[n];
    return 0;
}


Measured memory_bytes: 49788
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=8 && b<=8){
		cout<<"Yay!";
	}else{
		cout<<":(";
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

nn = 200200
mod = 10**9+7
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod

C = lambda a, b: fa[a] * fainv[b] % mod * fainv[a-b] % mod if 0 <= b <= a else 0

N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

BU = [1] * N
TD = [1] * N
SI = [1] * N
for i in R[::-1]:
    a = 1
    s = 0
    for j in X[i]:
        a = a * BU[j] * fainv[SI[j]] % mod
        s += SI[j]
    SI[i] = s + 1
    BU[i] = fa[s] * a % mod

for i in R:
    c = len(X[i])
    AL = [1] * (c + 1)
    AR = [1] * (c + 1)
    for j in range(c):
        AL[j+1] = AL[j] * BU[X[i][j]] % mod * fainv[SI[X[i][j]]] % mod
    for j in range(c)[::-1]:
        AR[j] = AR[j+1] * BU[X[i][j]] % mod * fainv[SI[X[i][j]]] % mod
    for j in range(c):
        TD[X[i][j]] = TD[i] * fainv[N - SI[i]] % mod * AL[j] % mod * AR[j+1] % mod * fa[N - 1 - SI[X[i][j]]] % mod

for i in range(N):
    print(BU[i] * TD[i] % mod * C(N-1, SI[i] - 1) % mod)

Measured memory_bytes: 125872
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

struct SegmentTree {
    int n;
    vector<int> node;
    
    SegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2*n - 1, numeric_limits<int>::min());
        for(int i = 0; i < sz; i++) {
            node[i+n-1] = v[i];
        }
        for(int i = n-2; i >= 0; i--) {
            node[i] = max(node[2*i+1], node[2*i+2]);
        }
    }
    
    int getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if (r < 0) {
            r = n;
        }
        if (r <= a || b <= l) {
            return numeric_limits<int>::min();
        }
        if (a <= l && r <= b) {
            return node[k];
        }
        int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};

int main() {
    int N;
    cin >> N;
    vector<int> Ais;
    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        Ais.push_back(ai);
    }
    SegmentTree tree(Ais);
    for (int i = 0; i < N; i++) {
        int left = tree.getmax(0, i);
        int right = tree.getmax(i+1, (int)Ais.size());
        int ans = max(left, right);
        cout << ans << endl;
    }
}


Measured memory_bytes: 6372
def main():
    import sys
    input = sys.stdin.readline
    H, W = map(int, input().split())
    grid = [list(map(int, input().split())) for _ in range(H)]
    cnt = 0
    ans_list = []
    for y in range(H):
        for x in range(W):
            if grid[y][x] % 2 == 0:
                continue
            if  x + 1 < W:
                cnt += 1
                ans_list.append((y+1, x+1, y+1, x+2))
                grid[y][x+1] += 1
                grid[y][x] -= 1
                continue
            elif y + 1 < H:
                cnt += 1
                ans_list.append((y+1, x+1, y+2, x+1))
                grid[y+1][x] += 1
                grid[y][x] -= 1
                continue

    print(cnt)
    for ans in ans_list:
        print(ans[0], ans[1], ans[2], ans[3])

if __name__ == '__main__':
    main()

Measured memory_bytes: 26732
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <numeric>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mod = 998244353;

#define bs(n) (1ll<<(ll)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define rrep(i, n) for(ll (i) = 1;(i) <= (n);(i)++)

int main() {
    int n, m;
    map<int, set<int>> p;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        p[a].insert(b);
        p[b].insert(a);
    }
    int c[100010],d[100010];
    for(int i = 1;i <= n;i++ ){
        c[i] = -1;
        d[i] = 1000000000;
    }
    d[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty()) {
        int x = q.front();
        q.pop();
        for(auto&e:p[x]) {
            if(d[e] > d[x]+1) {
                q.push(e);
                d[e] = d[x]+1;
                c[e] = x;
            }
        }
    }
    cout << "Yes\n";
    for(int i = 2;i <= n;i++) {
        cout << c[i] << "\n";
    }
}


Measured memory_bytes: 32640
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int x = scan.nextInt();
			int y = scan.nextInt();
			while(x != 0 && y != 0){
				int t = y;
				y = x;
				x = t % x;
			}
			System.out.println((x == 0)?y:x);
		}
	}
}

Measured memory_bytes: 17220