akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int main() {
    string s;
    cin >> s;
    set<char> ns = {'N', 'S'};
    set<char> ew = {'E', 'W'};
    set<char> nsew = {'N', 'S', 'E', 'W'};
    set<char> g;
    rep (i, (int)s.length()) {
        g.insert(s[i]);
    }
    if ( g == ns || g == ew || g == nsew ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>

int main(void)
{
  char weather[3][7] = {"Sunny","Cloudy","Rainy"};
  char today[7];
  int i;

  scanf("%s",today);

  for(i=0;i<3;i++){
    if(strcmp(today,weather[i])==0){
      i = (i+1)%3;
      break;
    }
  }
  printf("%s\n",weather[i]);

  return 0;
}



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

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

int N;

void dfs(string s, char mx)
{
	if (s.size() == N) {
		cout << s << endl;
		return;
	}

	for (char c = 'a'; c <= mx + 1; ++c) {
		dfs(s + c, c > mx ? c : mx);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;

	dfs("", 'a'-1);
}


Measured memory_bytes: 1536
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

X = int(input())

if X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
else:
    print(1)

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

int main(){
	int a,b,c;
	cin >> a;
 	cin >> b;
 	if((a+b)%2==0){
	c = ( a + b ) / 2;
	cout << c << endl;
    }else{
    	cout << "IMPOSSIBLE" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

ll n;
vector<vector<ll>> dp(n, vector<ll>(n, INF));  //dp[i][j] i to j min cost
vector<pair<ll,ll>> vec(n);

ll calc_mult(pair<ll,ll> a, pair<ll,ll> b){
    return a.first * a.second * b.second;
}

ll calc_sec(ll a, ll b){
    if(dp[a][b] != -1){
        return dp[a][b];
    }
    if(b == a){
        return 0;
    }
    if(b - a == 1){
        dp[a][b] = vec[a].first * vec[a].second * vec[b].second;
        return vec[a].first * vec[a].second * vec[b].second;
        //return 0;
    }


    ll res = INF;
    for(ll i = a; i < b; i++){
        res = min(res, calc_sec(a, i) + calc_sec(i+1, b) + vec[a].first * vec[i].second * vec[b].second);
    }

    dp[a][b] = res;
    return res;
}


int main() {
    std::cout << std::fixed << std::setprecision(15);
    cin >> n;

    vec.resize(n);
    rep(i, n) cin >> vec[i].first >> vec[i].second;

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    
    dp.resize(n, vector<ll>(n));
    dp.assign(n, vector<ll>(n, -1));
    rep(i,n){
        dp[i][i] = 0;
    }

    /*
    cout << calc_sec(0, 1) << endl;
    cout << calc_sec(0, 2) << endl;
    cout << calc_sec(0, 5) << endl;
    */
    /*
    rep(i,n){
        rep(j,n){
            cout << dp[i][j] << " ";
        }
        br;
    }
    */

    cout << calc_sec(0, n-1) << endl;







}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n;
ll a[100010];
ll d[100010][2];
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	d[0][0]=a[0];
	d[0][1]=-a[0];
	for (int i=1;i<n-1;i++)
	{
		d[i][0]=max(d[i-1][0]+a[i],d[i-1][1]-a[i]);
		d[i][1]=max(d[i-1][0]-a[i],d[i-1][1]+a[i]);
	}
	cout <<max(d[n-2][0]+a[n-1],d[n-2][1]-a[n-1]);
	return 0;
}

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

using namespace std;

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

    int N, Q; cin>>N>>Q;
    struct Event {
        int t, x;
        bool in;
        int b() const {return t-x;}
    };
    vector<Event> events;
    while (N-- > 0) {
        int s,t,x; cin>>s>>t>>x;
        events.push_back({s,x,true});
        events.push_back({t,x,false});
    }
    sort(events.begin(), events.end(), [](auto l, auto r) {
        return l.b() != r.b() ? l.b() > r.b() : l.in;
    });
    set<int> seps;
    while (Q-- > 0) {
        int d; cin>>d;
        while (not events.empty() and events.back().b() <= d) {
            auto& e = events.back();
            if (e.in) {
                seps.insert(e.x);
            } else {
                seps.erase(e.x);
            }
            events.erase(events.end()-1);
        }
        auto ans = not seps.empty() ? *seps.begin() : -1;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 15340
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    while(1){
        int q1, b, c1, c2, q2;
        cin >> q1;
        if(q1 == 0) break;
        cin >> b >> c1 >> c2 >> q2;

        int n1 = min(b/c1,q2);
        int n2 = max((b-n1*c1)/c2,0);
        while(1){
            if(n1 <= 0) {
                cout << "NA" << endl;
                break;
            }
            if( q1 <= n1 + n2 ) {
                cout << n1 << ' ' << n2 << endl;
                break;
            }
            n1--;
            n2 = (b-n1*c1)/c2;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

ll n, m, q;
ll a[55], b[55], c[55], d[55];
ll ans = 0;

void saiki(ll nu, ll now , Vl A){ // 前の数字　長さ　配列
  if(now == n){ // 配列の末尾に達したら
    ll sum = 0;
    rep(i, 0, q){
      if(A[b[i]] - A[a[i]] == c[i]) sum += d[i];
    }
    ans = max(ans, sum);
  }else{
    Rep(i, nu, m){
      A[now] = i;
      saiki(i, now+1, A);
    }
  }
}

int main() { 
  cin >> n >> m >> q;
  rep(i, 0, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  Vl v(n, -1);
  v[0] = 1;

  saiki(1, 1, v);

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3628
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
if n==1:
    print(a[0]+b[0])
    quit()
for i in range(1,n):
    if ans<sum(a[:i])+sum(b[i:])+b[i-1]:
        ans=sum(a[:i])+sum(b[i:])+b[i-1]
print(ans)


Measured memory_bytes: 3064
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
a = map(int, raw_input().split())

L = max(a)
m = defaultdict(int)
for num in a:
    if num < (L + 1) / 2:
        print "Impossible"
        exit()
    m[num] += 1
for num in range(L / 2 + 1, L + 1):
    if not num in m or m[num] < 2:
        print "Impossible"
        exit()
if L % 2 == 0 and (not L / 2 in m or m[L / 2] >= 2):
    print "Impossible"
    exit()
if L % 2 == 1 and m[L / 2 + 1] > 2:
    print "Impossible"
    exit()
print "Possible"

Measured memory_bytes: 2812
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=8005;
int r1,r2,n,sum,que1[N],que2[N],flag;
char ch[N];
bool zs[N<<1],dp1[16005],dp2[16005];
int main(){
	scanf("%s",&ch);
	n=strlen(ch); int x=read(),y=read(); int i; ch[n++]='T';
	for(i=0;ch[i]!='T';i++)x--;
	for(i++;i<n;i++)if(ch[i]=='T'){
		if(flag){
			que1[++r1]=sum; sum=0;
		}else{
			que2[++r2]=sum; sum=0;
		}
		flag^=1;
	}else sum++;
	dp1[8000]=dp2[8000]=1;
	for(int i=1;i<=r1;i++){
		for(int j=0;j<=16000;j++)if(j>=que1[i]&&dp1[j-que1[i]])zs[j]=1; else zs[j]=0;
		for(int j=0;j<=16000;j++){if(j+que1[i]<=16000&&dp1[j+que1[i]])zs[j]=1; dp1[j]=zs[j];}
	}
	for(int i=1;i<=r2;i++){
		for(int j=0;j<=16000;j++)if(j>=que2[i]&&dp2[j-que2[i]])zs[j]=1; else zs[j]=0;
		for(int j=0;j<=16000;j++){if(j+que2[i]<=16000&&dp2[j+que2[i]])zs[j]=1; dp2[j]=zs[j];}
	}//cout<<x<<" "<<y<<endl;
	if(dp1[x+8000]&&dp2[y+8000]){
		puts("Yes");
	} else puts("No");
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <string_view>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

void solve()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (k and a >= b)
    {
        k--;
        b *= 2LL;
    }
    while (k and b >= c)
    {
        k--;
        c *= 2LL;
    }
    if (a < b and b < c)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int32_t main()
{
    AB_BHI_NI_DEGI
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cout.precision(20);
    //cout << fixed;
    int T = 1;
    //cin >> T;
    int cnt = 1;
    while (T--)
    {
        //cout << "Case #" << cnt++ << ":\n";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(){
  int N,a,b,c,d,count=0;
  scanf("%d",&N);
  a=N/1000; b=(N-(a*1000))/100; c=(N-(a*1000)-(b*100))/10; 
  d=N-(a*1000)-(b*100)-(c*10);
  if(a==2)count+=1;
  if(b==2)count+=1;
  if(c==2)count+=1;
  if(d==2)count+=1;
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    
int x, y;
for(int i=1; i<=3000; i++){
cin>>x>>y;
if(x==0 && y==0){
break;
}

else if(x>y){
    swap(x,y);
}

cout<<x<<" "<<y<<endl;

}    
return 0;


}



Measured memory_bytes: 3108
#include<stdio.h>

void InsertionSort(int A[], int n);

int main()
{
  int i;
  int n;
  int A[101];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  
  InsertionSort(A, n);

  return 0;
}

void InsertionSort(int A[], int n)
{
  int i=0,j=0;
  int key;

  for(i = 0;i < n;i++){
    key = A[i];
    j = i-1;
    while(j >= 0 && A[j] >= key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    
    for(j = 0;j < n;j++){
      if(j) printf(" ");
      printf("%d",A[j]);
    }
    printf("\n");
  }
}



Measured memory_bytes: 2084
# ABC119C - Synthetic Kadomatsu
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

INF = float('inf')

def dfs(cursor=0, a=0, b=0, c=0):  # cursor:カーソル a,b,c:現在の竹の長さ
    if cursor == N:  # cursorが最後まで行ったら終了する。
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    # abs(a - A) + abs(b - B) + abs(c - C) - 30でなぜ 30を減じているのかというと、
    # dfs(0,0,0,0)で始まる以上、最初に選ばれるa,b,cを決定する際にもコストが 10増加してしまうからである。
    # また、全探索を行う中で、a,b,cの初期値が 0,0,0である以上、a,b,cのどれかが 0のまま終了する場合が存在する。
    # この場合はa,b,cに竹が対応してないと言えるため、解にはならない。
    # そこで三項演算子を利用して、その場合についてコストをINFとしている

    # 以下は4^Nで展開される再起処理となる。
    # カーソルの当たっている竹に対して、(A or B or Cに合成する) or (合成しない)の場合に分ける
    no_compound_pattern = dfs(cursor + 1, a, b, c)
    compound_a_pattern = dfs(cursor + 1, a + L[cursor], b, c) + 10
    compound_b_pattern = dfs(cursor + 1, a, b + L[cursor], c) + 10
    compound_c_pattern = dfs(cursor + 1, a, b, c + L[cursor]) + 10

    # 結果的に以下の値が返るのはそれぞれのパターンのコストが決定されてからなので
    # 以下のコードは最終的なコストの最小値
    return min(
        no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern
    )


print(dfs())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //
 
int main(void)
{
    int W, a, b;
    cin >> W >> a >> b;
 
    int ans;
 
    // 緑の長方形が赤に触れているとき
    // b点
    if (a <= b && b <= a + W)
    {
        ans = 0;
    }
    // b + W 点
    else if (a <= b + W && b + W <= a + W)
    {
        ans = 0;
    }
    else if (a + W < b)
    {
        ans = abs(b - (a + W));
    }
    else if (b + W < a)
    {
        ans = abs(a - (b + W));
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
N = int(input())

if N >= 400 and N <= 599:
    print(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9184
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

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

#define INF INT_MAX / 2 - 1
#define PI 2*acos(0.0)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

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

ull pos(ull x, ull n) {
	if (n == 0)
		return 1;
	ull res = pos(x, n / 2);
	res = (res * res) % MOD;
	if (n % 2 == 1)
		res = (res * x) % MOD;
	return res;
}

int main() {
	int m, n;
	cin >> m >> n;
	cout << pos(m, n) << endl;
	return 0;
}

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

void print_state(int* A, int N) {
    for (int i=0; i<N-1; i++) {
        std::cout << A[i] << " ";
    }
    std::cout << A[N-1] << std::endl;
};

void swap(int* a, int* b) {
    int tmp = *b;
    *b = *a;
    *a = tmp;
};

int main() {
    int N, count=0;
    int A[110];
    std::cin >> N;
    for (int i=0; i<N; i++) {
        std::cin >> A[i];
    }

    if (N > 1) {
        bool flag = true;
        while (flag) {
            flag = false;
            for (int i=N-1; i>0; i--) {
                if (A[i] < A[i-1]) {
                    swap(&A[i], &A[i-1]);
                    count++;
                    flag = true;
                }
            }
        }
    }
    print_state(A,N);
    std::cout  << count << std::endl;

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    ll n;
    cin >> n;
    string ans = "";
    ll num;
    while(n>0){
        n--;
        num = n % 26;
        ans += 'a' + num;          //１桁目の文字
        n = n/26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
    return 0;
}


Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)

	ans := func() int {
		if H == 1 || W == 1 {
			return 1
		}
		return (H*W + 1) / 2

	}()

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int> > A(h,vector<int>(w));
  cin>>A;

  auto calcScore=[&](int y,int x){
    int res = 0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) res += A[i][j] * min(abs(y - i),abs(x - j));
    return res;
  };

  int ans = INF;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      Min(ans,calcScore(i,j));
    }

  cout<<ans<<endl;

  
  
  return 0;
}



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

typedef long long ll;

int main() {
    int H, W, K, ans = 0;
    cin >> H >> W >> K;
    vector<string>c(H);
    rep(i, H) cin >> c[i];
    rep(k, 1 << (H + W)) {
        int b = 0;
        rep(i, H) {
            if ((k >> i) & 1) continue;
            rep(j, W) {
                if ((k >> (H + j)) & 1) continue;
                if (c[i][j] == '#') b++;
            }
        }
        //cout << k << " " << b << "\n";
        if (b == K) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    val t = readInputLine().toCharArray()
    
    var ans = "UNRESTORABLE"
    
    for (i in s.size - t.size downTo 0) {
        var ok = true
        for (j in t.size - 1 downTo 0) {
            if (s[i + j] == '?') {
                continue
            }
            if (s[i + j] != t[j]) {
                ok = false
                break
            }
        }
        
        if (ok) {
            for (j in 0 until t.size) {
                s[i + j] = t[j]
            }
            ans = s.joinToString("").replace('?', 'a')
            break
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

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

  	int jj = 0;  
  	for (int ii=2; ii < n; ii++){
      if (s.at(ii-2) == 'A' && s.at(ii-1) == 'B' && s.at(ii) == 'C') {
        jj++;
      }
    }
  	cout << jj << endl;
  
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x /gcd(x, y) * y );
}

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}


ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll dp[101010][20];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	ll res = h[n - 1];
	for (ll i = n - 1;i >= 0;--i) {
		if (res < h[i] - 1) {
			puts("No");
			return 0;
		}
		else if (res > h[i])res = h[i];
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define frst first
#define sec second
#define fast cin.tie(0) , ios_base :: sync_with_stdio(0)
#define db double
#define mod 1000000007
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}

vector<ll> pyr;
void cal()
{
	for (ll h = 1; h < 100001; ++h)
	{
		ll val = (3 * h * h + h) / 2;
		pyr.pb((val));
	}
}

ll dp[4001][4001][2];
ll go_(ll a[] , ll be , ll en , ll player)
{
	if (be > en)return 0;
	ll ans = 0;
	if (dp[be][en][player] != -1e12)return dp[be][en][player];
	if (player == 0)
	{
		ans = max(go_(a , be + 1 , en , 1) + a[be] , go_(a , be , en - 1 , 1) + a[en]);
	}
	else {
		ans = min(go_(a , be + 1 , en , 0) - a[be] , - a[en] + go_(a , be , en - 1 , 0));
	}
	return dp[be][en][player] = ans;
}

void go() {
	fast;
	ll n;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; ++i)cin >> a[i];
	for (int i = 0; i < 4001; ++i)for (int j = 0; j < 4001; ++j)dp[i][j][0] = dp[i][j][1] = -1e12;
	cout << go_(a , 0 , n - 1 , 0);
}


int main() {
	fast;
	//online_judge();
	//cout << 2332;
	go();
}

Measured memory_bytes: 250496
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

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

void solve()
{
	ll n,cnt=0;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			for(ll k=j+1;k<n;k++)
			{
				if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
				{
					if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i]) cnt++;
				}
			}
		}
	}
	cout<<cnt;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3648
N = int(input())
countK = 0
for i in range(1,N+1):
    countY = 0
    if i%2 == 1:
        for j in range(1,i+1):
            if i%j == 0:
                countY += 1
        if countY==8:
            countK += 1        
    else:
        continue
print(countK)
        
        

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  vector<i64> ans(1e5 + 10);
  rep(i,0,N) {
    i64 a;
    cin >> a;
    ans[a]++;
    ans[a + 1]++;
    ans[a + 2]++;
  }
  cout << *max_element(begin(ans), end(ans)) << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>

#define ll long long

using namespace std;

const ll mod = 1e9 + 7;

int N, K;
vector<int> adj[100005];
ll ans;

void dfs(int here, int parent, int depth)
{
	int st = K-1;

	if (depth == 1) st = K;
	for (int i=0;i<adj[here].size();++i)
	{
		int next = adj[here][i];
		if (next == parent) continue;
		ans = (ans * (--st)) % mod;
		dfs(next, here, depth + 1);
	}
}

int main()
{
	scanf("%d %d", &N, &K);
	ans = K;

	for (int i = 0; i < N - 1; ++i)
	{
		int a, b;

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

		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	dfs(1, 0, 1);

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

	return 0;
}

Measured memory_bytes: 11520
import java.util.Scanner;
class Main {
 public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   int a = sc.nextInt();
   int b = sc.nextInt();
   int com = a*b;
  if(com%2==0) {
    System.out.println("Even");
  }else{
    System.out.println("Odd");
  }
 }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll total=0;
    rep(i,n) total^=a[i];
    rep(i,n){
        ll ans=total^a[i];
        cout << ans << endl;
    }

    return 0;
}











Measured memory_bytes: 4836
<?php
$n = int();
$q = ints();
for($i = 0; $i < $n; $i++){
  for($j = 0; $j <= $i; $j++){
    $p = $q;
    $tmp = $p[$i];
    $p[$i] = $p[$j];
    $p[$j] = $tmp;
    for($k = 0; $k < $n-1; $k++){
      if($p[$k] > $p[$k+1]){
        break;
      }
      if($k == $n-2){
        echo "YES";
        exit;
      }
    }
  }
}
echo "NO";
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4728
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int f(int x, int a, int b, int W) {
	if (x < a)return 1;
	if (b < x)return 1;
	if (b == W)return -1;
	return b + 2 - x;
}

int ff(string S, string T) {

	//答えansを仮置きする。
	//これが十分に大きくないと不正解となるので、
	//この値なら絶対に正しい答えが出る、という値を仮置きすること
	int ans = T.size();

	//Sの何文字目から調べるかを全探索する
	for (int start = 0; start <= S.size() - T.size(); start++)
	{
		int diff = 0;
		for (int i = 0; i < T.size(); i++)
		{
			if (T[i] != S[start + i]) {
				diff++;
			}
		}
		ans = min(ans, diff);
	}

	return ans;
}

int f(string s, string t) {
	int ans = 10000;
	for (int i = 0; i <= s.size() - t.size(); ++i) {
		int c = 0;
		for (int j = 0; j < t.size(); ++j) {
			if (s[i + j] != t[j]) ++c;
		}
		ans = min(ans, c);
	}
	return ans;
}
int main() {
	string s, t;
	cin >> s >> t;
	PRI(f(s, t));
	return 0;
}




Measured memory_bytes: 3592
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		String[] S = s.split("");
		String[] T = t.split("");
		String newStr = null;
		
		for(int i = 0; i < S.length; i++){
			if(i == 0){
				newStr = S[i] + T[i];
			}
			else if(i > 0){
				newStr += S[i];
				newStr += T[i];
			}
		}
		
		System.out.println(newStr);
	}
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main() {
	int n, k,d;
	cin >> n >> k;
	int a[101] = {0};
	for (int i = 0;i < k;i++) {
		int d;
		cin >> d;
		for (int j = 0;j < d;j++) {
			int x;
			cin >> x;
			a[x]++;
		}
	}
	int cnt = 0;
	for (int i = 1;i <= n;i++) {
		if (a[i] == 0) cnt++;
	}
	
	cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main()
{
    long long n, a, b, ans, rem;
    cin >> n >> a >> b;
    ans = n / (a + b) * a;
    rem = n % (a + b);
    ans += min(rem, a);
    cout << ans << " ";
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int mxN = 3005;
int dp1[3005][3005], dp2[3005][3005];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int N, T;
	cin>>N>>T;
	vector<int> A(N + 1), B(N + 1);
	for(int i = 1; i <= N; i++){
		cin>>A[i]>>B[i];
	}
	memset(dp1, 0, sizeof(dp1));
	memset(dp2, 0, sizeof(dp2));
	for(int i = 1; i <= N; i++){
		for(int sum = 0; sum < T; sum++){
			dp1[i][sum] = dp1[i - 1][sum];
			if(sum >= A[i])dp1[i][sum] = max(dp1[i][sum], dp1[i - 1][sum - A[i]] + B[i]);
		}
	}
	for(int i = N; i >= 1; i--){
		for(int sum = 0; sum < T; sum++){
			dp2[i][sum] = dp2[i + 1][sum];
			if(sum >= A[i])dp2[i][sum] = max(dp2[i][sum], dp2[i + 1][sum - A[i]] + B[i]);
		}
	}
	int ans = 0;
	for(int i = 1; i <= N; i++){
		for(int sum = 0; sum < T; sum++){
			ans = max(ans, dp1[i - 1][sum] + dp2[i + 1][T - 1 - sum] + B[i]);
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> num(100000, 0);
    rep(i, n) {
        cin >> a.at(i) >> b.at(i);
        num.at(a.at(i) - 1) += b.at(i);
    }
    rep(i, 100000) {
        if (k - num.at(i) <= 0) {
            cout << i + 1 << endl;
            return 0;
        }
        k -= num.at(i);
    }
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)


typedef long long ll;
//const int MOD = pow(10,9)+7;
//const int MAX = 100001;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int main() {
    
    ll N = lin();
   
    ll overlaps[100000+5]; //aiを全て一様に1シフトしていると考えれば、ai-1も収まる。
    
    for(auto i = 0; i< 100000+5; i++){
        overlaps[i]  = 0;
    }
    
    ll inp;
    for(auto j = 0; j<N; j++){
        
        inp = lin();
        
        overlaps[inp] ++;
        overlaps[inp+1] ++;
        overlaps[inp+2] ++;
        
    }
    
    ll max = -1;
    
    for(auto i = 0; i <100000+5; i++ ){
        
        if (max < overlaps[i]) max = overlaps[i];
    }
    
    cout << max << endl;
    
    return 0;
    
    
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		H[0] = sc.nextInt();
		boolean jud = true;
		
		for(int i=1;i<N;i++) {
			H[i] = sc.nextInt();
			if(H[i] > H[i-1]) {
				H[i] -= 1;
			}else if(H[i]<H[i-1]) {
				jud = false;
				break;
			}
		}
		
		if(jud) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 48220
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int sum = 0;
    int tmp = n;
    while(tmp>0){sum += tmp%10; tmp/=10;}
    Yn(n%sum==0);

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }
        Scanner cin;

        int K, N;
        int[] L;
        void solve() {
            cin = new Scanner();

            N = cin.nextInt();
            K = cin.nextInt();
            L = new int[N];
            for(int i = 0; i < N; i++) {

                L[i] = cin.nextInt();
            }

            Array.Sort(L);
            Array.Reverse(L);
            int ans = 0;
            for(int i = 0; i < K; i++) {
                ans += L[i];
            }

            Console.WriteLine(ans);



        }
    }

    class Scanner {
        string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
        public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
        public string next() {
            if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            BufferCnt = 0;
            return nextBuffer[BufferCnt++];
        }
        public int nextInt() { return int.Parse(next()); }
        public long nextLong() { return long.Parse(next()); }
        public double nextDouble() { return double.Parse(next()); }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

int main(void){
  long i,j;

  long n;
  scanf("%ld",&n);

  long a;
  if(n%3){
    for(i = 0; i < n; i++){
      scanf("%ld", &a);
      if(a){
        printf("No\n");
        return 0;
      }
    }
    printf("Yes\n");
    return 0;
  }

  long index_no[3]={-1,-1,-1},index[3]={0,0,0};
  for(i=0;i<n;i++){
    scanf("%ld",&a);
    if(index_no[0]==-1){
      index_no[0]=a;
      index[0]++;
    }else if(a==index_no[0]){
      index[0]++;
    }else if(index_no[1]==-1){
      index_no[1]=a;
      index[1]++;
    }else if(a==index_no[1]){
      index[1]++;
    }else if(index_no[2]==-1){
      index_no[2]=a;
      index[2]++;
    }else if(a==index_no[2]){
      index[2]++;
    }else{
      printf("No\n");
      return 0;
    }
  }

  if(((index_no[0]==0&&index[0]*2==index[1])||(index_no[1]==0&&index[1]*2==index[0]))&&index_no[2]==-1){
    printf("Yes\n");
  }else if(index_no[0]==0&&index[0]==n){
    printf("Yes\n");
  }else if(index[0]!=index[1]||index[1]!=index[2]){
    printf("No\n");
  }else if(index_no[0]!=(index_no[1]^index_no[2])){
    printf("No\n");
  }else{
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define max(a,b) a>b?a:b
int main(){
    long long m,n,ans;
    scanf("%lld %lld",&n,&m);
    if(n==1&&m==1){ans=1;}
    else if((n==1&&m>1)||(n>1&&m==1)){
        ans=max(m,n);
        ans-=2;
    }else{
        ans=(n-2)*(m-2);
    }
    printf("%lld",ans);
    return 0;
}

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

using namespace std;

int main()
{
    int N, K;
    int A = 0;
    cin >> N >> K;
    int P[N];
    for (int i = 0; i < N; i++){
        cin >> P[i];
    }
    sort(P, P+N);
    for(int i = 0; i < K; i++){
        A += P[i];
    }
    cout << A;
}

Measured memory_bytes: 3628
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		for(int i = 0 ; i < n ; i++) {
			if(map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], 1);
			}
		}
		int ans = 0;
		for(int key : map.keySet()) {
			if(map.get(key) < key) ans += map.get(key);
			else ans += map.get(key) - key;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 55144
#include <stdio.h>

int main(void){
    
    long int x,i,sum,ans;
    
    scanf( "%ld",&x );
    
    for( i = 1; i < 1000000000; i++ ){
        sum += i;
        if( sum >= x ){
            ans = i;
            break;
        }
    }
    
    printf( "%ld\n",ans );
    
    return 0;
}

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

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<int> d;
    for (int i = 0; i < N; i++) {
        int di;
        cin >> di;
        d.insert(di);
    }
    cout << d.size() << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	if(a>b) cout << "a > b" <<endl;
	else if(a<b) cout << "a < b" <<endl;
	else cout << "a == b" << endl;
	return 0;
	}

Measured memory_bytes: 1156
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
  string s;
  cin>>s;
  int l,r;
  int n=s.size();
  for(int i=0;i<n;i++)if(s[i]=='A'){l=i;break;}
  for(int i=n-1;i>=0;i--)if(s[i]=='Z'){r=i;break;}
  cout<<r-l+1<<endl;
}
  


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

struct Node
{
    int key;
    Node *parent;
    Node *left;
    Node *right;
};

Node *root;
Node *nil;

void InsertNode(int key)
{
    Node *x = root;
    Node *y = nil;
    Node *z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->parent = nil;
    z->left = nil;
    z->right = nil;

    while (x != nil)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    z->parent = y;

    if (y == nil)
    {
        root = z;
    }
    else if (z->key < y->key)
    {
        y->left = z;
    }
    else
    {
        y->right = z;
    }

    return;
}

void FindNode(int key, Node *x)
{
    if (x == nil)
    {
        cout << "no" << endl;
        return;
    }

    if (key == x->key)
    {
        cout << "yes" << endl;
        return;
    }
    else if (key < x->key)
    {
        FindNode(key, x->left);
    }
    else
    {
        FindNode(key, x->right);
    }

    return;
}

void PrintInOrder(Node *x)
{
    if (x == nil)
    {
        return;
    }

    PrintInOrder(x->left);
    cout << " " << x->key;
    PrintInOrder(x->right);

    return;
}

void PrintPreOrder(Node *x)
{
    if (x == nil)
    {
        return;
    }

    cout << " " << x->key;
    PrintPreOrder(x->left);
    PrintPreOrder(x->right);

    return;
}

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

    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;

        if (s == "insert")
        {
            int key;
            cin >> key;
            InsertNode(key);
        }
        else if (s == "find")
        {
            int key;
            cin >> key;
            FindNode(key, root);
        }
        else
        {
            PrintInOrder(root);
            cout << endl;
            PrintPreOrder(root);
            cout << endl;
        }
    }

    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    
    for (int i=0; i<n; i++) {
        ans = min(ans * 2, ans + k);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
long long const mod = 1e9+7;
long long g(int a, int b){
    return (long long)(b-a+1)*(a+b)/2;
}
long long f(int n, int k){
    return g(n-k+1, n) - g(0, k-1) + 1;
}
int main(void){
    int n, k;
    cin >> n >> k;
    long long ans = 0;
    while(k <= n+1){
        ans += f(n, k);
        k++;
    }
    cout << ans%mod << endl;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b, c;cin >> a >> b >> c;
    string ans = "NO";
    if(b-a == c-b) ans = "YES";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

delta_x21 = x2 - x1
delta_y21 = y2 - y1
delta_x32 = -delta_y21
delta_y32 = delta_x21
x3 = x2 + delta_x32
y3 = y2 + delta_y32
x4 = x3 - delta_x21
y4 = y3 - delta_y21

print(x3, y3, x4, y4)

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

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

    int n;
    cin >> n;

    vector<pair<double, double>> xy(n);
    rep(i, n){
        double x, y;
        cin >> x >> y;
        xy[i] = make_pair(x, y);
    }
    sort(xy.begin(), xy.end());

    int n_fact = 1;
    rep1(i, n+1) n_fact *= i;
    
    double sum = 0.0;
     
    do{
        pair<double, double> current = xy[0];
        double dist = 0.0;
        rep1(i, n){
            pair<double, double> nxt = xy[i];
            dist += pow((nxt.first - current.first) * (nxt.first - current.first) + (nxt.second - current.second) * (nxt.second - current.second), 0.5);
            current = xy[i];
        }

        sum += dist;

    } while(next_permutation(xy.begin(), xy.end()));

    printf("%.19f\n", sum / n_fact);


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  string s;
  
  cin >> n >> k >>s;
  
  if (s[k-1] == 'A'){
    s[k-1] = 'a';
  }
  else if (s[k-1] =='B'){
    s[k-1] = 'b';
  }
  else{
    s[k-1] = 'c';
  }
  cout << s << endl;
}

Measured memory_bytes: 256