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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

typedef long long ll;

int main() {
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long int n,x[2000001],t,ans;
int main() {
	cin>>n;
	for(int i=0; i<n; i++)
		cin>>x[i];
	for(int i=0; i<n; i++) {
			if(t<x[i])
				t=x[i];
		if(x[i]<t) {
			ans+=t-x[i];
			x[i]+=t-x[i];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5148
import sys
from collections import deque
K = int(input())
if K <= 9:
	print(K)
	sys.exit()
q = deque(['1', '2','3','4','5','6','7','8','9'])
cnt = 0
while True:
	cp = q.popleft()
	cnt += 1
	if cnt == K:
		ans = int(cp)
		break
	r = int(cp[-1])
	for d in [-1,0,1]:
		dd = r + d
		if 0 <= dd < 10:
			q.append(cp + str(dd))

print(ans)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_S 8000
#define MAX_X 2 * 8000
bool dpX[MAX_S + 1][MAX_X + 1];
bool dpY[MAX_S + 1][MAX_X + 1];

int main() {
    string S; cin >> S;
    i64 gx, gy; cin >> gx >> gy;
    const i64 xlim = S.length() * 2;
    const i64 ylim = S.length() * 2;
    gx += S.length();
    gy += S.length();

    vector<i64> seq;
    seq.pb(0);
    REP(i, S.length()) {
        if (S[i] == 'T') seq.pb(0);
        else seq[seq.size() - 1]++;
    }

    i64 NX = (seq.size() + 1) / 2;
    i64 NY = seq.size() / 2;
    dpX[0][S.length()] = true;
    dpY[0][S.length()] = true;

    REP(i, seq.size()) {
        i64 d = seq[i];
        if (i == 0) {
            dpX[i + 1][S.length() + d] = true;
            continue;
        }

        i64 opi = (i % 2 == 0) ? i / 2 : (i - 1) / 2;
        auto &dp = (i % 2 == 0) ? dpX : dpY;

        REP(x, xlim + 1) {
            if (!dp[opi][x]) continue;
            if (x + d <= xlim) dp[opi + 1][x + d] = true;
            if (x - d >= 0) dp[opi + 1][x - d] = true;
        }
    }

    if (dpX[NX][gx] && dpY[NY][gy]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 125824
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    a--;b--;c--;d--;
    string s;cin>>s;
    bool rock=false;
    bool ok=true;
    for(int i=a;i<=b;i++){
        if(s[i]=='#'){
            if(rock){
               ok=false;
               break; 
            }
            rock=true;
        }else{
            rock=false;
        }
    }
    for(int i=c;i<=d;i++){
        if(s[i]=='#'){
            if(rock){
               ok=false;
               break; 
            }
            rock=true;
        }else{
            rock=false;
        }
    }
    if(a<b&&c>d){
        for(int i=b;i<=d;i++){
            if(s.substr(i-1,3)=="..."){
                break;
            }
            if(i==d){ok=false;}
        }
    }
    if(a>b&&c<d){
        for(int i=a;i<=c;i++){
            if(s.substr(i-1,3)=="..."){
                break;
            }
            if(i==d){ok=false;}
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n;

int main(){
  cin >> n;
  int sum = 0;
  vector<P> task(n+1);
  for(int i = 1; i < n + 1; i++){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    task[i] = P(tmp2, tmp1);
  }
  sort(all(task));
  for(int i = 1; i < n+1; i++){
    // cout << task[i].first << " " << task[i].second << endl;
  }
  int time = 0;
  string ans = "Yes";
  for(int i = 1; i < n+1; i++){
    // cout << time << endl;
    time += task[i].second;
    if(time > task[i].first)ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<vector>
#define For(i,A,B) for(i=(A);i<=(B);++i)
using namespace std;
const int N=200050;
int G[N],to[N<<1],nxt[N<<1],sz,dep[N],cnt[2],p=-1,tot[3],n,s[N];
inline int newnum(int x){
    if(tot[x]){
        --tot[x];
        return x?tot[x]*3+x:tot[x]*3+3;
    }else return tot[0]--*3;
}
inline int newnum(){
    if(tot[1])return newnum(1);
    else return newnum(2);
}
inline void adde(int u,int v){
    to[++sz]=v;nxt[sz]=G[u];G[u]=sz;
    to[++sz]=u;nxt[sz]=G[v];G[v]=sz;
}
void dfs(int u,int fa,int d){
    int i,v;
    ++cnt[dep[u]=d];
    for(i=G[u];i;i=nxt[i])if((v=to[i])!=fa)dfs(v,u,d^1);
}
void Dfs(int u,int fa){
    int i,v;
    //printf("%d:%d:%d %d %d\n",u,dep[u],tot[0],tot[1],tot[2]);
    if(dep[u]==p)s[u]=newnum(0);
    else if(p==-1)s[u]=newnum(dep[u]+1);
    else s[u]=newnum();
    for(i=G[u];i;i=nxt[i])if((v=to[i])!=fa)Dfs(v,u);
}
int main(){
    int i,u,v;
    scanf("%d",&n);
    For(i,2,n){
        scanf("%d%d",&u,&v);
        adde(u,v);
    }
    dfs(1,0,0);
    tot[0]=n/3;tot[1]=(n+2)/3;tot[2]=(n+1)/3;
    if(cnt[0]<=n/3)p=0;
    else if(cnt[1]<=n/3)p=1;
    Dfs(1,0);
    For(i,1,n)printf("%d ",s[i]);
    puts("");
    return 0;
}

Measured memory_bytes: 12800
def solve():
    N = int(input())
    result_yen = 0.0
    for _ in range(N):
        x,u = [s for s in input().split() if s]
        coeff = 380000.0 if u == 'BTC' else 1.0
        result_yen += float(x)*coeff
    
    print(result_yen)
    
solve()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct xstruct {
    int64_t val;
};
bool operator<=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val <= rhs.val;
}
bool operator<(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val < rhs.val;
}
bool operator>=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val >= rhs.val;
}
bool operator>(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val > rhs.val;
}
bool operator==(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val == rhs.val;
}
bool operator!=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val != rhs.val;
}
ostream& operator<<(ostream& os, xstruct const& xst) {
    return os << xst.val;
}

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            if (res.count(i) == 0) {
                res[i] = 0;
            }
            res[i]++;
            n = n / i;
        }
    }
    if (n != 1) {
        res[n] = 1;  // n自身が素数
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    auto pf = prime_factor(N);
    ll result = 0;
    ll right_first = int(sqrt(N) + 1);
    for (auto p : pf) {
        ll prime_num = p.second;

        ll maxused = 0;
        ll right = right_first;
        ll left = 1;
        while (right >= left) {
            ll mid = (right + left) / 2;
            ll total = mid * (mid + 1) / 2;
            if (total <= prime_num) {
                // print(p.first, p.second, total, mid, "middd");
                maxused = max(maxused, mid);
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        // print(p.first, maxused);
        result += maxused;
    }
    cout << result << endl;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  vector<Int> sm(n+1,0);
  for(Int i=0;i<n;i++) sm[i+1]=sm[i]+as[i];

  Int ans=sm[n];
  for(Int i=1;i<n;i++){
    Int x=sm[i]-sm[0];
    Int y=sm[n]-sm[i];
    chmin(ans,abs(x-y));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	string s;
	cin>>n>>s;
	reverse(all(s));

	vector<int> white(n+1,0),black(n+1,0);
	for(int i = 0; i < n; i++){
		white[i+1] = white[i] + (s[i]=='.'?1:0);
		black[i+1] = black[i] + (s[i]=='#'?1:0);
	}

	int ans = n+1;
	if(black[n] == 0) ans = 0;
	for(int i = 0; i < n; i++){
		ans = min(ans,white[i] + (black[n]-black[i+1]) + (s[i]=='#'?0:1));
		ans = min(ans,white[i] + (black[n]-black[i+1]) + (s[i]=='.'?0:1));
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 2180
// AOJ 2051: Rotation Estimation
// 2017.11.21 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define EPS 1e-8
#define PI 3.1415926535897932384626433832795

typedef struct { double x, y; } T;
T a[1001], b[1001]; int n;

typedef struct { double r, a; } S;
S aa[1001], bb[1001];

int cmp(S *a, S *b)
{
	if (fabs(a->r - b->r) <= EPS) {
		if (fabs(a->a - b->a) <= EPS) return 0;
		if (a->a <= b->a) return -1;
		return 1;
	}
	if (a->r <= b->r) return -1;
	return 1;
}

double calc()
{
	double ans, x;
	ans = fabs(aa[0].a - bb[0].a);
	if (ans > 2*PI - ans) ans = 2*PI - ans;
	if (n > 1) {
		x = fabs(aa[0].a - bb[1].a);
		if (x > 2*PI - x) x = 2*PI - x;
		if (x < ans) ans = x;
	}
	return ans;
}

int main()
{
	int i;
	double ax0, ay0, bx0, by0, x0, ans;

	while (scanf("%d", &n) && n > 0) {
		ax0 = ay0 = bx0 = by0 = 0;
		for (i = 0; i < n; i++) {
			scanf("%lf%lf", &a[i].x, &a[i].y);
			ax0 += a[i].x, ay0 += a[i].y;
		}
		ax0 /= n, ay0 /= n;
		for (i = 0; i < n; i++) {
			scanf("%lf%lf", &b[i].x, &b[i].y);
			bx0 += b[i].x, by0 += b[i].y;
		}
		bx0 /= n, by0 /= n;
		for (i = 0; i < n; i++) {
			aa[i].r = hypot(a[i].x - ax0, a[i].y - ay0);
			aa[i].a = atan2(a[i].y - ay0, a[i].x - ax0);
		}
		qsort(aa, n, sizeof(S), cmp);

		for (i = 0; i < n; i++) {
			bb[i].r = hypot(b[i].x - bx0, b[i].y - by0);
			bb[i].a = atan2(b[i].y - by0, b[i].x - bx0);
		}
		qsort(bb, n, sizeof(S), cmp);

#if 0
for (i = 0; i < n; i++) {
	printf("(%.6lf,%.6lf) - (%.6lf,%.6lf)\n", aa[i].r,aa[i].a, bb[i].r,bb[i].a);
}
#endif

		x0 = aa[0].r;
		for (i = 1; i < n; i++) if (fabs(x0 - aa[i].r) > EPS) break;
		if (i == n) ans = calc();
		else {
			ans = fabs(aa[0].a - bb[0].a);
			if (ans > 2*PI - ans) ans = 2*PI - ans;
		}
		printf("%.10lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2160
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    long sum=0;
    boolean res=true;
    Map<Long,Long> map=new TreeMap<>();
    for(int i=0;i<n;i++) {
    	long a=sc.nextLong(),b=sc.nextLong();
    	if(map.containsKey(b)) {
    		map.put(b, map.get(b)+a);
    	}else {
    		map.put(b, a);
    	}
    }
    for(Long key : map.keySet()){
    	sum+=map.get(key);
    	if(key<sum) {
    		res=false;
    		break;
    	}
    	//System.out.println(sum);
    }
    if(res) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");
    }
  }
}


Measured memory_bytes: 127880
data = []
tmp = []
for x in range(0,1000000):
    a,b = map(int, input().split())
    if a==0:
        if b==0:
            break
        pass
    data.append((a,b))
for x in range(0,len(data)):
    tmp = list(data.pop(0))
    for y in range(0,tmp[0]):
        for z in range(0,tmp[1]):
            if z==0:
                print("#",end='')
            elif y==0:
                print("#",end='')
            elif z==tmp[1]-1:
                print("#",end='')
            elif y==tmp[0]-1:
                print("#",end='')
            else:
                print(".",end='')
        print("")
    tmp.clear()
    print("")


Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int res, n;

int main(){
  scanf("%d", &res);
  char op[2];
  while(scanf("%s", op) && op[0] != '='){
    scanf("%d", &n);
    switch(op[0]){
    case '+': res += n; break;
    case '-': res -= n; break;
    case '/': res /= n; break;
    case '*': res *= n; break;
    default: break;
    }
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 1188
n = int(input())
h = list(map(int, input().split()))
cost = [0]*n
cost[0] = 0
cost[1] = abs(h[0] - h[1])
for i in range(2, n):
    cost[i] = min(cost[i-2]+abs(h[i-2]-h[i]), cost[i-1]+abs(h[i-1]-h[i]))
print(cost[-1])


Measured memory_bytes: 13980
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  vector<ll> from(n + 1, -1);
  vector<ll> f(n + 1, -1);
  for (ll i = 2; i <= n; ++i) {
    if (from[i] != -1) continue;
    for (ll j = 2 * i; j <= n; j += i) from[j] = i;
  }
  ll result = 1;
  f[1] = 1;
  for (ll i = 2; i <= n; ++i) {
    if (from[i] == -1) {
      f[i] = 2;
      result += 2 * i;
      continue;
    }
    ll x = i;
    ll p = from[i];
    ll m = 0;
    while (x % p == 0) {
      m++;
      x /= p;
    }
    f[i] = (m + 1) * f[x];
    result += f[i] * i;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 159560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	a := getNextInt(scanner)
	s := getNextString(scanner)

	if a < 3200 {
		fmt.Fprintln(writer, "red")
	} else {
		fmt.Fprintln(writer, s)

	}

	writer.Flush()
}


Measured memory_bytes: 640
import java.util.Scanner;

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

        int l1 = (s.length()-1)/2;
        int l2 = (s.length()+3)/2;
        String a = s.substring(0, l1);
        String b = s.substring(l2-1);

        if(palindorme(s) && palindorme(a) && palindorme(b)){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }

    private static boolean palindorme(String s) {
        int l = 0;
        int h = s.length()-1;

        while(l < h)
        {
            if(s.charAt(l) == s.charAt(h))
            {
                l++;
                h--;
            }
            else
            {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    int m = N % 10;
    if(m == 2 || m == 4 || m == 5 || m == 7 || m == 9 )cout << "hon" << endl;
    else if(m == 0 || m == 1 || m == 6 || m == 8)cout << "pon" << endl;
    else cout << "bon" << endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {

            var vals = Console.ReadLine().Split(' ')
                .Select(x => long.Parse(x)).ToList();
            var N = vals[0];
            var K = vals[1];
            long pattern = 0;

            //var A = Console.ReadLine().Split(' ')
            //    .Select(x => int.Parse(x)).ToList();
            long waru = (long)1e9 + 7;
            //0toi-1(i*(i-1)/2),N-i+1 to N(i*(2N-i+1)/2)
            for (int i = (int)K ; i <= (int)N+1; i++)
            {
                pattern =( pattern+ (i) * (2 * N - 2*i +2) / 2  +1 )% waru;
            }
            Console.WriteLine(pattern);
            

        }

    }
}


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


int main() {
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i< n; i++){
		cin >> arr[i];
	}
	int sum = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i < j){
				sum += arr[i] * arr[j];
			}
	}
	
}
cout << sum << endl;
}


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

int main() {
  char A;
  cin>>A;
  if(A=='a'){
    cout<<'b'<<endl;
  }
  if(A=='b'){
    cout<<'c'<<endl;
  }
  if(A=='c'){
    cout<<'d'<<endl;
  }
  if(A=='d'){
    cout<<'e'<<endl;
  }
  if(A=='e'){
    cout<<'f'<<endl;
  }
  if(A=='f'){
    cout<<'g'<<endl;
  }
  if(A=='g'){
    cout<<'h'<<endl;
  }
  if(A=='h'){
    cout<<'i'<<endl;
  }
  if(A=='i'){
    cout<<'j'<<endl;
  }
  if(A=='j'){
    cout<<'k'<<endl;
  }
  if(A=='k'){
    cout<<'l'<<endl;
  }
  if(A=='l'){
    cout<<'m'<<endl;
  }
  if(A=='m'){
    cout<<'n'<<endl;
  }
  if(A=='n'){
    cout<<'o'<<endl;
  }
  if(A=='o'){
    cout<<'p'<<endl;
  }
  if(A=='p'){
    cout<<'q'<<endl;
  }
  if(A=='q'){
    cout<<'r'<<endl;
  }
  if(A=='r'){
    cout<<'s'<<endl;
  }
  if(A=='s'){
    cout<<'t'<<endl;
  }
  if(A=='t'){
    cout<<'u'<<endl;
  }
  if(A=='u'){
    cout<<'v'<<endl;
  }
  if(A=='v'){
    cout<<'w'<<endl;
  }
  if(A=='w'){
    cout<<'x'<<endl;
  }
  if(A=='x'){
    cout<<'y'<<endl;
  }
  if(A=='y'){
    cout<<'z'<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b[1005];
	cin>>a;
	long long sum=0;
	for(int i=0;i<a;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<a-1;i++)
	{
		for(int j=i+1;j<a;j++)
		sum+=b[i]*b[j];
	}
	cout<<sum;
} 

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<cstdio>
using namespace std;
string s;
stack <int> st;
int main(){
	getline(cin, s);
	int len = s.size(), num = 0, x, y;
	for(int i = 0; i < len; i++){
		if(s[i] == ' '){
			if(num != 0)
			st.push(num);
			num = 0;
			continue;
		}
		if(s[i] >= '0' && s[i] <= '9'){
			num = num * 10 + (s[i] - '0');
		}
		if(s[i] == '+'){
		 x = st.top(); st.pop();
		 y = st.top(); st.pop();
		 st.push(x + y);
		}else if(s[i] == '-'){
		 x = st.top(); st.pop();
		 y = st.top(); st.pop();
		 st.push(y - x);
		}else if(s[i] == '*'){
		 x = st.top(); st.pop();
		 y = st.top(); st.pop();
		 st.push(x * y);
		}
	}
	printf("%d\n", st.top());
	return 0;
} 


Measured memory_bytes: 3344
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(m)]
b=sorted(a)
id={}
t=1
for ind,i in enumerate(b):
    if ind!=0 and b[ind][0]!=b[ind-1][0]:
        t=1
    x=str(i[0]).zfill(6)
    y=str(t).zfill(6)
    t=int(t)
    t+=1
    idd=x+y
    id[str(i[0])+str(i[1])]=idd
for i in a:
    ii=str(i[0])+str(i[1])
    print(id[ii])

Measured memory_bytes: 42408
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int m, f, r;
    while(1) {
        cin >> m >> f >> r;
        if(m < 0 && f < 0 && r < 0)
            break;
        if(m < 0 || f < 0)
            cout << "F" << endl;
        else if(m + f > 79)
            cout << "A" << endl;
        else if(m + f > 64)
            cout << "B" << endl;
        else if(m + f < 30)
            cout << "F" << endl;
        else if(m + f > 49 || r > 49)
            cout << "C" << endl;
        else
            cout << "D" << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n), c(m), d(m);
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for (int i = 0; i < m; i++)
		cin >> c[i] >> d[i];
	int keep;
	for (int i = 0; i < n; i++) {
		int mind = 1000000000;
		for (int j = 0; j < m; j++) {
			if (mind > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				mind = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				keep = j;
			}
		}
		cout << keep + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
if n%2==1:
    ans = "No"
elif s[:n//2]==s[n//2:]:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Measured memory_bytes: 61776
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N, K;
int V[100];

int main() {

	scanf("%d%d", &N, &K);
	rep(i, N) scanf("%d", &V[i]);

	int ans = 0;
	rep(i, K + 1) {
		rep(j, K - i + 1) {
			if (i + j > N) break;
			int k = K - i - j;
			vector<int> h;
			rep(t, i) h.push_back(V[t]);
			rep(t, j) h.push_back(V[N - t - 1]);
			sort(h.begin(), h.end());
			int e = 0;
			rep(t, k) {
				if (t >= h.size()) break;
				if (h[t] < 0) e = t + 1;
			}
			int sub = 0;
			rep(t, h.size() - e) {
				sub += h[e + t];
			}
			ans = max(ans, sub);
		}
	}


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

	return 0;
}


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

int main( void ){
    int k,s,cnt=0;
    int S1,S2;
    cin >> k >> s;
    
    for(int i = 0;i<=k;i++){
        S1 = s - i;
        for(int j=0;j<=k;j++){
            S2 = S1 - j;
            //cout << S2 << " ";
            if(S2 > -1 && S2 < k + 1 ) cnt++;
        }
    }
    
    cout << cnt <<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}



public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		StringBuffer sb;
		String S = fs.next();
		sb = new StringBuffer(S);
		if(!S.equals(sb.reverse().toString())) {
			System.out.println("No");
			return;
		}


		int N = S.length();

		String s1 = S.substring(0, (N-1)/2);
		sb = new StringBuffer(s1);
		if(!s1.equals(sb.reverse().toString())) {
			System.out.println("No");
			return;
		}
		s1 = S.substring((N+3)/2 -1, N);
		sb = new StringBuffer(s1);
		if(!s1.equals(sb.reverse().toString())) {
			System.out.println("No");
			return;
		}

		System.out.println("Yes");




	}

}


Measured memory_bytes: 23124
#include<stdio.h>
 
int main(void){
   int x,y,i,j;
   for(;;){
      scanf("%d %d",&y,&x);
      if(x+y==0) break;
      for(i=0;i<y;i++){
         for(j=0;j<x;j++)
            if(i*j==0 || i+1==y || j+1==x)
               printf("#");
            else
               printf(".");
         printf("\n");
      }
   printf("\n");
   }
   return 0;
}


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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const ll inf = 1e9,
mod = 1e9 + 7,
N = 3e5 + 11;

int n, m, bit[N];
vector <ii> ds[N];
void update(int p, int val) {
    for (; p <= m; p += (p & -p))
        bit[p] += val;
}
int get(int p) {
    int ans = 0;
    for (; p > 0; p -= (p & -p))
        ans += bit[p];
    return ans;
}
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    read(n);
    read(m);
    for (int i = 1; i <= n; i++) {
        int l, r;
        read(l);
        read(r);
        ds[r - l + 1].push_back(ii(l, r));
    }
    for (int i = 1; i <= m; i++) {
        int ans = n;
        for (int j = i; j <= m; j += i)
            ans += get(j);
        writeln(ans);
        for (auto p: ds[i]) {
            update(p.fi, 1);
            update(p.se + 1, -1);
            n--;
        }
    }

}


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


int main()
{
    int n,a,b,x,y;
    double k;


    cin>>a>>b;
    if(a!=b)
    {
        k=(a+b)*0.5;
        if(k==(int)k)
        {
            x=abs(a-k);
            y=abs(b-k);
            if(x==y)
            {
                cout<<fixed<<setprecision(0)<<k<<endl;
            }
            else {
                cout<<"IMPOSSIBLE"<<endl;
            }

        }
        else{
            cout<<"IMPOSSIBLE"<<endl;}
    }

    return 0;
}

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

SX = [[i, X[i]] for i in range(len(X))]
SX = sorted(SX, key=lambda x:x[1])

lm = SX[N//2-1][1]
rm = SX[N//2][1]

res = [0] * N
for i in range(len(SX)):
    if i < N // 2:
        res[SX[i][0]] = rm
    else:
        res[SX[i][0]] = lm


for r in res:
    print(r)

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

int main(){
    int n,m;
    cin >> n;
    vector<string> blue(n);
    for(int i = 0; i < n; i++) cin >> blue[i];
    cin >> m;
    vector<string> red(m);
    for(int i = 0; i < m; i++) cin >> red[i];
    int max = 0;
    auto calc = [&](string s){
        int buf = 0;
        for(string t: blue){
            if(t == s) buf++;
        }
        for(string t: red){
            if(t == s) buf--;
        }
        return  buf;
    };
    for(string t: blue){
        max = std::max(max,calc(t));
    }
    cout << max << endl; 
    return 0;
}

Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

struct edge {
    ll to, cost;
};

int V;
vector<edge> G[1000000];
ll d[1000000];
bool used[1000000];

void addedge(int st, int ed, ll co) {
    edge e;
    e.to = ed;
    e.cost = co;
    G[st].push_back(e);
}

int main() {
    ll N, M;
    cin >> N >> M;
    ll a[N];
    plglg b[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        b[i] = plglg(a[i], (ll)i);
    }
    for (int i = 0; i < M; i++) {
        ll x, y;
        cin >> x >> y;
        addedge(x, y, 1);
        addedge(y, x, 1);
    }
    if (M == N - 1) {
        cout << 0 << endl;
        return 0;
    }
    ll p = N - M;
    if ((p - 1) * 2 > N) {
        cout << "Impossible" << endl;
        return 0;
    }
    fill(used, used + N, false);
    bool minused[N];
    fill(minused, minused + N, false);
    ll ans = 0;
    ll mark = 0;
    for (int i = 0; i < p; i++) {
        queue<int> que;
        que.push(mark);
        ll minnum = mark;
        used[mark] = true;
        while (!que.empty()) {
            int q = que.front();
            que.pop();
            for (int j = 0; j < (int)G[q].size(); j++) {
                edge e = G[q][j];
                if (!used[e.to]) {
                    used[e.to] = true;
                    if (a[e.to] < a[minnum]) {
                        minnum = e.to;
                    }
                    que.push(e.to);
                }
            }
        }
        ans += a[minnum];
        minused[minnum] = true;
        for (int j = mark + 1; j < N; j++) {
            if (!used[j]) {
                mark = j;
                break;
            }
        }
    }
    sort(b, b + N);
    ll mk = 0;
    for (int i = 0; i < N; i++) {
        if (mk == p - 2) {
            break;
        }
        if (!minused[b[i].second]) {
            mk++;
            ans += b[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 31872
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	long long n, i, j, k, ans, b, c, x, a, d, e;
	cin >> s >> k;
	n = s.length();
	vector<vector<vector<long long>>> dp(n, vector<vector<long long>>(26, vector<long long>(26, 1LL << 30)));

	if (n == 1) ans = k / 2;
	else {
		// dp[position][start char][curr char];
		for (i = 0; i < 26; i++) {
			if (i == s[0] - 'a') dp[0][i][i] = 0;
			else dp[0][i][i] = 1;
		}

		for (i = 1; i < n; i++) {
			for (b = 0; b < 26; b++) {			// start char
				for (j = 0; j < 26; j++) {		// curr char
					for (c = 0; c < 26; c++) {	// last char
						if (j == c) continue;
						if (s[i] - 'a' == j) x = 0;
						else x = 1;
						dp[i][b][j] = min(dp[i][b][j], dp[i - 1][b][c] + x);
					}
				}
			}
		}

		ans = 1LL << 60;
		if (k == 1) {
			for (a = 0; a < 26; a++) {
				for (b = 0; b < 26; b++) {
					ans = min(ans, dp[n - 1][a][b]);
				}
			}
		}
		else {
			for (a = 0; a < 26; a++) {
				for (b = 0; b < 26; b++) {
					for (c = 0; c < 26; c++) {
						for (d = 0; d < 26; d++) {
							for (e = 0; e < 26; e++) {
								if ((b != c) && (d != b)) {
									ans = min(ans, dp[n - 1][a][b] + (k - 2) * dp[n - 1][c][b] + dp[n - 1][d][e]);
								}
								if ((b != c) && (d != a)) {
									ans = min(ans, (k + 1) / 2 * dp[n - 1][a][b] + k / 2 * dp[n - 1][c][d]);
								}
							}
						}
					}
				}
			}
		}

	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, x, y, z;
struct uni_find {
	vector<int> r, par;
	uni_find(int n) {
		r.resize(n+1);
		par.resize(n+1);
		for(int i = 1; i <= n; i++){
			par[i] = i;
			r[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x)
    return x;
		return par[x] = find(par[x]);
	}
 
	void uni(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)
    return;
		if (r[x] < r[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (r[x] == r[y])
      r[x]++;
		}
	}
 
};
 
int main(){
	cin >> n >> m;
 
	uni_find u(n);
	for(ll i = 0; i < m; i++){
		cin >> x >> y >> z;
		u.uni(x, y);
	}
 
	ll ans = n; 
	for(ll j = 1; j <= n; j++){
		if(j != u.find(j)){
      ans--;
      }
	}
 
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <set>
#include <vector>
#include <queue>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)

int main(){
    
    int n,a,b;
    string s;
    cin>>n>>a>>b>>s;
    
    int p=a+b;
    int q=b;
    
    loop(i,n){
        if(s[i]=='a'){
            if(p){
                p--;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(s[i]=='b'){
            if(p && q){
                p--; q--;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }
    
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
typedef long long int64;
const int64 mod = 1e9 + 7;
int64 mpow(int64 x, int64 n)
{
    int64 res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
int64 Cnm(int64 a, int64 b)
{
    int64 i, ans = 1, c = 1;
    for (i = a; i >= a - b + 1; i--)
        ans = ans * i % mod;
    for (i = b; i >= 1; i--)
        c = c * i % mod;
    return ans * mpow(c, mod - 2) % mod;
}
int main()
{
    int64 n, a, b;
    cin >> n >> a >> b;
    int64 ans = mpow(2, n) - 1 - Cnm(n, a) - Cnm(n, b);
    cout << (ans % mod + mod) % mod << endl;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
ans = []
for i in range(K):
  if A + i <= B:
    ans.append(A + i)
  if B - i >= A:
    ans.append(B - i)
ANS = list(set(ans))
ANS.sort()
[print(j) for j in ANS]

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var X int
	var prime int = (X + 10000000)
	fmt.Scanf("%d", &X)

	flag := make([]bool, prime+1)
	flag[0] = true
	flag[1] = true

	for n := 2; n*n <= prime; n++ {
		if !flag[n] {
			for m := 2; n*m <= prime; m++ {
				flag[n*m] = true
			}
		}
	}

	for n := 2; n <= prime; n++ {
		if !flag[n] && X <= n {
			fmt.Println(n)
			break
		}
	}

}


Measured memory_bytes: 11992
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    double a,b;
    cin>>n;
    a=(double(n)/2.0)/double(n);
    b=((double(n)+1.0)/2.0)/double(n);
    if(n%2==0){
        cout<<a<<endl;
    }
    
    else if(n%2!=0){
        cout<<b<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define _LL long long
#define rep(i, n) for(_LL i = 0; i < (_LL)(n); i++)
// 二次元配列

template <class T> class MultiArray2
{
    public:
        T* _a;
        int _w;
        int _h;
        MultiArray2(int w, int h, bool clr = false)
        {
            _w = w; _h = h;
            _a = new T[_w * _h];
            if(clr) memzero();
        }

        void memzero()
        {
            memset(_a, 0, _w * _h * sizeof(T));
        }

        ~MultiArray2()
        {
            delete _a;
        }

        T* operator[](int i)
        {
            return _a + (i * _h);
        }
};

int main()
{
    int n, t;
    cin >> n >> t;
    pair<int,int> *f = new pair<int,int>[n];
    rep(i, n)
    {
        cin >> f[i].first >> f[i].second;
        f[i].first *= -1;
    }
    sort(f, f + n);
    MultiArray2<int> dp(n, t, true);
    rep(i, n)
    {
        if( i == 0 )
        {
            rep(k, t) dp[i][k] = f[i].second;
            continue;
        }
        // 注文にかかる時間を降順にならべて、i番目までから選んだ時
        rep(k, t)
        {
            if( k == 0 )
            {
                dp[i][k] = max(f[i].second, dp[i-1][k]);
            }
            else if( k >= -f[i].first )
            {
                dp[i][k] = max(max(dp[i-1][k], dp[i-1][k + f[i].first] + f[i].second), dp[i][k-1]);
            }
            else
            {
                dp[i][k] = max(dp[i-1][k], dp[i][k-1]);
            }
        }
    }
//    rep(i, n)
//        rep(k, t) cout << "(" << i << "," << k << ") = " << dp[i][k] << endl;
    cout << dp[n-1][t-1] << endl;
}

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <set>

using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vector<int> x[100001], y[100001];
set<int> st[100001];
bool used[100001];

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++) {
        int x_, y_;
        cin >> x_ >> y_;
        x[x_].push_back(y_);
        y[y_].push_back(x_);
    }
    UnionFind uf(100001);
    for(int i = 1; i <= 100000; i++){
        for(int j = 1; j < x[i].size(); j++){
            uf.unionSet(x[i][0], x[i][j]);
        }
    }
    
    for(int i = 1; i <= 100000; i++){
        if(uf.size(i) > 0){
            int r = uf.root(i);
            for(int j = 0; j < y[i].size(); j++){
                st[r].insert(y[i][j]);
            }
        }
    }

    long ans = 0;
    for(int i = 1; i <= 100000; i++){
        int r = uf.root(i);
        if(uf.size(i) > 0){
            if(used[r]) continue;
            long s = uf.size(i);
            long t = st[r].size();
            ans += s*t;
            used[r] = true;
        }
    }

    cout << ans-N << endl;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==5&&b==5&&c==7){cout<<"YES"<<endl;}
  else if(a==5&&b==7&&c==5){cout<<"YES"<<endl;}
  else if(a==7&&b==5&&c==5){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include<utility>
#include <new>
#include <string>
#include<cmath>
#include<unordered_set>
#include<iomanip>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define forloop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second<b.second;
}
int main()
{ll w,n,a,b;
	cin >> n >> w;
	vector<pair<ll,ll>>A(n);
	forloop(i, 0, n){
	     cin >>a>>b;
	     A[i]={a,b};
	}
	sort(A.begin(),A.end(),cmp);
	ll dp[w+1][n+1];
	forloop(i,0,w+1) dp[i][0]=0;
    forloop(i,0,n+1) dp[0][i]=0;
	forloop(i, 1, n + 1)
	{
		forloop(j, 1, w+1)
		{dp[j][i]=dp[j][i-1];
		if(A[i-1].first<=j){
			dp[j][i] = max(dp[j -A[i-1].first][i-1]+A[i-1].second, dp[j][i]);
		}
		}
	}
	cout<<dp[w][n];
}


Measured memory_bytes: 82376
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
vi lunlunN={1,2,3,4,5,6,7,8,9};
void lunlun(ll k){
    ll cnt=10;
    REP(i,k){
        if(cnt>=k)return;
        ll p=lunlunN[i]%10;
        if(p>=1)lunlunN.push_back(lunlunN[i]*10+p-1);
        lunlunN.push_back(lunlunN[i]*10+p);
        if(p<=8)lunlunN.push_back(lunlunN[i]*10+p+1);
        cnt++;
    }
}
int main(void){
    ll K;cin>>K;
    lunlun(K);
    sort(ALLv(lunlunN));
    cout<<lunlunN[K-1]<<"\n";
}

Measured memory_bytes: 2676
#include <iostream>
#include <cmath>
#include <utility>
#include <map>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

map<ll,ll> mapa;

ll arr[200003];

int main () {
	int n;
	cin>>n;
	for(ll i=1ll;i<=n;i++){
		cin>>arr[i];
		mapa[arr[i]+i]=0ll;
		mapa[i-arr[i]]=0ll;
	}
	ll s=0ll;
	for(ll i=1ll;i<=n;i++){
		s+=mapa[i-arr[i]];
		mapa[arr[i]+i]++;
	}
	cout<<s;
	



return 0;
}



Measured memory_bytes: 27892
# -*- coding: utf-8 -*-


def isKaibun(S):
    rtn = True
    for i in range(len(S)):
        if S[i] != S[-(1+i)]:
            rtn = False
    return rtn

S = input()
N = len(S)
if isKaibun(S) and isKaibun(S[0:(N-1)//2]) and isKaibun(S[(N+3)//2-1:N]):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    ll n;
    cin >> n;
    
    ll made = n;
    ll ans = made * (made - 1 ) /2;
    ll kara =0;

    pri(ans);



    return 0;
}



Measured memory_bytes: 256