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

#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
#define clr(x) memset(x,0,sizeof x)

using std :: max;
using std :: min;
using std :: map;

typedef long long LL;

static const int INF = 1 << 30;
static const LL oo = 1LL << 62;
static const int maxm = 1e6 + 10;

template <class T> inline bool chkmax(T &x,T y){
    return x < y ? x = y,true : false;
}

template <class T> inline bool chkmin(T &x,T y){
    return x > y ? x = y,true : false;
}

template <class T> inline void read (T &in){
    in = 0; char ch = getchar(); T f = 1;
    for (;ch > '9' || ch < '0';ch = getchar()) if(ch == '-') f = -1;
    for (;ch >= '0' && ch <= '9';ch = getchar()) in = in * 10 + ch - '0';
    in = in * f;
}

map<int,int> f,vis;
int A[maxm];
int N,ans;

int main(){
	read(N);
	for(int i = 1;i <= N;i++) read(A[i]),f[A[i]]++;
	for(int i = 1;i <= N;i++){
		if(A[i] == f[A[i]] || vis[A[i]]) continue;
		if(f[A[i]] < A[i]) ans += f[A[i]],vis[A[i]] = 1;
		if(f[A[i]] > A[i]) ans += f[A[i]] - A[i],vis[A[i]] = 1;
	}

	printf("%d\n",ans);
	
	return 0;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int res = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) res++;
    }
    cout << res;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1000000007;

// auto mod int
// ref. https://github.com/atcoder-live/library/blob/master/mint.cpp
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

vector<ll> S;
vector<ll> T;

// dp[i][j] means the number of patterns for S[0..(i-1)] and T[0..(j-1)]
mint dp[2005][2005];

// ref. solution1 of http://drken1215.hatenablog.com/entry/2019/06/21/230200
int main(void) {
    ll N, M;
    cin >> N >> M;

    S.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    T.resize(M + 1, 0);
    for (int i = 0; i < M; i++) {
        cin >> T[i];
    }

    for (int i = 0; i <= N; i++) dp[i][0] = 1;
    for (int i = 0; i <= M; i++) dp[0][i] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
            if (S[i - 1] == T[j - 1]) {
                dp[i][j] += dp[i - 1][j - 1];
            }
        }
    }

    // for (int i = 0; i < N + 1; i++) {
    //     for (int j = 0; j < M + 1; j++) {
    //         printf("%lld ", dp[i][j].x);
    //     }
    //     printf("\n");
    // }

    cout << dp[N][M].x << endl;

    return 0;
}


Measured memory_bytes: 31744
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    int i;
    char str[10], *a[10], *b[10], *c[10];
    while(cin >> str){           //行数指定がある場合はif文でも可
        a[i] = strtok(str, ",");  //","で分解
        b[i] = strtok(NULL, ",");
        c[i] = strtok(NULL, ",");
        cout << a[i] << " " << b[i] << " " << c[i]  <<"\n";
        i++;
    }
    return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,now=0; cin>>n;
    string ans="Yes";
    vector<pair<ll,ll>> t(n);
    rep(i,n){
        ll a,b; cin>>a>>b;
        t[i]=mk(b,a);
    }
    sort(al(t));
    rep(i,n){
        now+=t[i].second;
        if(now>t[i].first) ans="No";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
S = list(input())
N = len(S)
S.append('R')
ans = [0]*N

#cnt for RL
cnt = [0,0]
l = 'R'
for i in range(N):
  if S[i] == l:
    cnt[0] += 1
  elif S[i] == S[i+1]:
    cnt[1] += 1
  else:
    cnt[1] += 1
    r1 = cnt[0]//2
    r2 = cnt[1]//2
    ans[i-cnt[1]] = cnt[0] - r1 + r2
    ans[i-cnt[1]+1] = cnt[1] - r2 + r1
    cnt=[0,0]
print(' '.join(str(n) for n in ans))

Measured memory_bytes: 17836
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int x = stdIn.nextInt();
        //int d1 = stdIn.nextInt();
        //int x = stdIn.nextInt();
        //int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        boolean flag = false;
        //for(int i = 0; i < s.length(); i++){
        //}
        
        int minko = x / 105;
        int maxko = x / 100 + 1;
        
        for(int i = minko; i <= maxko; i++){
        	int amari = x - (i * 100);
        	
        	if(amari >= 0 && amari <= 5 * i){
        		flag = true;
        		break;
        	}
        }
        
        if(flag){
        	System.out.println(1);
        }else{
        	System.out.println(0);
        }
        
        
        //System.out.println();
        //System.out.print();
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const double pi=acos(-1);

set<int>st;
const int maxn=1e6+5;
ll isp[maxn],p[maxn];
int main ()
{

    ll n;
    while(~sll(n))
    {
        for(ll i=ll(sqrt(n+1)); i>=1; i--)
            if(n%i==0)
            {
                printf("%lld\n",i+n/i-2);
                break;
            }
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep_one(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;


int main(){
    int l, r, d;
    int ans=0;
    cin >> l >> r >> d;
    for(int i=l; i<r+1; i++){
        if(i%d == 0) ans++;
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vi a;
    vector<bool>b;
    char m=s[0];
    int cnt=0;
    rep(i,s.size()){
        if(s[i]==m){
            cnt++;
        }
        else{
            if(m=='1')b.PB(true);
            else b.PB(false);
            a.PB(cnt);
            cnt=1;
            m=s[i];
        }
    }
    a.PB(cnt);
    if(m=='1')b.PB(true);
    else b.PB(false);
    int l=0,c=0,d=0;
    vi ans;
    rep(i,a.size()){
        l+=a[i];
        if(!b[i])c++;
        if(c==k+1){
            ans.PB(l-a[i]);
            while(c>k){
                l-=a[d];
                if(!b[d])c--;
                d++;
            }
        }
    }
    ans.PB(l);
    sort(all(ans));
    reverse(all(ans));
    cout<<ans[0]<<endl;
}

Measured memory_bytes: 1272
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  cin >> S;
  int price = 700;
  if( S[0] == 'o'){ price = price + 100;}
  if( S[1] == 'o'){ price = price + 100;}
  if( S[2] == 'o'){ price = price + 100;} 
  cout << price << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

int board[8][8];
// int tempBoard[8][8];
int h, w, c;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
int ans;

class preBoard {
public:
  int tempBoard[8][8];
};
preBoard tBoard[5];

bool is_in(int x, int y) {
  return x >= 0 && y >= 0 && x < w && y < h;
}

int countS() {
  bool vis[8][8];
  memset(vis, false, sizeof(vis));

  int ret = 1;
  vis[0][0] = true;
  stack <int> st;
  st.push(0);
  st.push(0);
  while(!st.empty()) {
    int x = st.top(); st.pop();
    int y = st.top(); st.pop();

    for (int i = 0; i < 4; i++) {
      int nx = x+dx[i];
      int ny = y+dy[i];

      if (!is_in(nx, ny) ||
	  vis[nx][ny] || board[nx][ny] != c) continue;
      vis[nx][ny] = true;
      st.push(ny);
      st.push(nx);
      ret++;
    }
  }

  return ret;
}

// 左上角のパネルを色ncに変える
void changeC(int nc) {
  bool vis[8][8];
  memset(vis, false, sizeof(vis));

  int pc = board[0][0];
  board[0][0] = nc;
  vis[0][0] = true;
  stack <int> st;
  st.push(0);
  st.push(0);
  while(!st.empty()) {
    int x = st.top(); st.pop();
    int y = st.top(); st.pop();

    for (int i = 0; i < 4; i++) {
      int nx = x+dx[i];
      int ny = y+dy[i];

      if (!is_in(nx, ny) ||
	  board[nx][ny] != pc ||
	  vis[nx][ny]) {
	continue;
      }
      vis[nx][ny] = true;
      st.push(ny);
      st.push(nx);
      board[nx][ny] = nc;
    }
  }
}

void rec(int n) {
  int pc = board[0][0];
  if (n == 5) {
    changeC(c);

    ans = max(ans, countS());
    memcpy(board, tBoard[n-1].tempBoard, sizeof(board));
  }else if (n == 4) {
    for (int i = 1; i <= 6; i++) {
      if (i == c || i == pc) continue;
      memcpy(tBoard[n-1].tempBoard, board, sizeof(board));
      changeC(i);
      rec(n+1);
      memcpy(board, tBoard[n-1].tempBoard, sizeof(board));
    }
  }else {
    for (int i = 1; i <= 6; i++) {
      if (i == pc) continue;
      memcpy(tBoard[n-1].tempBoard, board, sizeof(board));
      changeC(i);

      rec(n+1);
      memcpy(board, tBoard[n-1].tempBoard, sizeof(board));
    }
  } 
}

int main() {
  while(true) {
    cin >> h >> w >> c;
    if (h == 0 && w == 0 && c == 0) break;

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	cin >> board[j][i];
      }
    }

    // changeC(1);
    // changeC(2);
    // changeC(3);
    // changeC(4);
    // changeC(6);
    // for (int i = 0; i < h; i++) {
    //   for (int j = 0; j < w; j++) {
    // 	std::cout << board[j][i] << " ";
    //   }
    //   std::cout << "" << std::endl;
    // }
    // std::cout << countS() << std::endl;
    // int resetBoard[8][8];
    ans = 0;
    rec(1);

    std::cout << ans << std::endl;
  }
}

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

int main(){
  int n,key;
  int a[1001],i;

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
   for(int k=0;k<n-1;k++) cout<<a[k]<<" ";
 cout<<a[n-1]<<endl;
  for(int j=1;j<n;j++){
    key=a[j];
    i=j-1;
    while(i>=0 && a[i]>key){
      a[i+1]=a[i];
      i=i-1;
      a[i+1]=key;
    } for(int k=0;k<n-1;k++) cout<<a[k]<<" ";
 cout<<a[n-1]<<endl;
   }
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(int argc, char const *argv[])
{
    vector<vector<int>> a(3, vector<int>(3));

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
        }
    }

    /*
    cout << "--------------" << endl;

    for(int i =0;i<3;i++){
        for(int j =0; j<3;j++){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
    */

    int n = 0;
    cin >> n;
    vector<int> b(n);

    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }

    /*
    cout << "---------b--------" << endl;

    for (int i = 0; i < n; i++)
    {
        cout << b[i] << endl;;
    }
    */

    vector<vector<int>> score(3, vector<int>(3, 0));

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

    /*
    cout << "---------score-------" << endl;

    for(int i =0;i<3;i++){
        for(int j =0; j<3;j++){
            cout << score[i][j] << endl;
        }
    }
    */

    int flag = 0;
    for (int i = 0; i < 3; i++)
    {
        if (score[i][0] == 1 && score[i][1] == 1 && score[i][2] == 1)
            flag = 1;
    }

    for (int i = 0; i < 3; i++)
    {
        if (score[0][i] == 1 && score[1][i] == 1 && score[2][i] == 1)
            flag = 1;
    }

    if (score[0][0] == 1 && score[1][1] == 1 && score[2][2] == 1)
        flag = 1;

    if (score[0][2] == 1 && score[1][1] == 1 && score[2][0] == 1)
        flag = 1;

    if (flag == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

long long int ar[100009], cr[100009];
int main()
{
    long long int n, k, tem;
    
    cin>>n>>k;
    
    for (int i=1;i<=n;i++) {
        cin>>cr[i];
    }
    ar[1]=0;
    ar[2]=abs(cr[1]-cr[2]);
    
    if(n==2){
        cout<<abs(cr[1]-cr[2])<<endl;
        return 0;
    }
    
    for (int i=3;i<=n;i++) {
        ar[i]=1e18;
        for(int j=1; j<=k; j++){
            if(i-j>=1){
                tem = abs(cr[i] - cr[i-j])+ar[i-j];
                ar[i] = min(ar[i],tem);
            }
            else{
                break;
            }
        }
    }
    cout<<ar[n]<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    vector<double>a(N);
    long double count = 0;
    rep(i, N) {
        cin >> a[i];
        count += a[i];
    }
    vector<long double>b(N);
    rep(i, N)b[i] = abs(a[i] - count/N);
    sort(b.begin(), b.end());
    double ans1 = abs(b[0] - count / N);
    double ans2 = b[0] + count / N;
    rep(i, N) {
        if (a[i]==ans1 || a[i]==ans2) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define ll long long

int n,m;
bool matrica[1010][1010];
ll dp[1010][1010];
ll modulo=1000000007;

using namespace std;
int main()
{
	ios::sync_with_stdio(false);	
	cin.tie(0);
	
	cin>>n>>m;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		for(int j=0;j<m;j++)
			if(s[j]=='.')
				matrica[i][j]=true;
	}
	bool ok=true;
	for(int i=0;i<n;i++)
		if(ok && matrica[i][0])
			dp[i][0]=1;
		else
			ok=false;
	ok=true;
	for(int j=0;j<m;j++)
		if(ok && matrica[0][j])
			dp[0][j]=1;
		else
			ok=false;
	
	for(int i=1;i<n;i++)
		for(int j=1;j<m;j++)
			if(matrica[i][j])
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%modulo;
	
	cout<<dp[n-1][m-1];
	
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < 4; i++){
        cout << s.at(i);
    }
    cout << ' ';
    for(int i = 4; i < 12; i++){
        cout << s.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int R;
    cin >> R;
    cout << (double)(2 * M_PI * R) << endl;
    return 0;
}


Measured memory_bytes: 3812
//
//AtCoder Beginner Contest 157
//D
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main()
{
    int n,m,k;
    cin >> n >> m >> k;

    UnionFind frd(n);
    vector<int> frdCnt(n, 0);
    vector<vector<int>> brkList(n);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        frd.unite(a,b);
        frdCnt[a]++;
        frdCnt[b]++;
    }
    REP(i, k) {
        int c, d;
        cin >> c >> d;
        c--;d--;
        brkList[c].push_back(d);
        brkList[d].push_back(c);
    }

    REP(i,n){
        int ans = frd.size(i) - 1 - frdCnt[i];
        REP(j, brkList[i].size()){
            if (frd.same(i, brkList[i][j])) ans--;
        }
        cout << ans << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 8976
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long ;
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector <int> A(N);
  for( int i=0;i<N;i++ )
    cin >> A[i];

  ll ans = 0;
  sort(A.begin(), A.end());
  vector <int> out;
  out.push_back(A[0]);

  A.erase(A.begin());
  while(!A.empty())
    {
      int c1 = abs(*(out.end()-1)-*(A.end()-1));
      int c2 = abs(out[0]-*(A.end()-1));
      int c3 = abs(out[0]-A[0]);
      int c4 = abs(*(out.end()-1)-A[0]);

      int m = max(c1, max(c2, max(c3, c4)));
      if( m == c1 )
	{
	  out.push_back(*(A.end()-1));
	  A.pop_back();
	  continue;
	}
      else if ( m == c2 )
	{
	  out.insert(out.begin(), *(A.end()-1));
	  A.pop_back();
	  continue;	  
	}
      else if ( m == c3 )
	{
	  out.insert(out.begin(), A[0]);
	  A.erase(A.begin());
	  continue;	  
	}
      else
	{
	  out.push_back(A[0]);
	  A.erase(A.begin());
	  continue;	  
	}
    }

  for( int i=0;i<N-1;i++)
    ans += abs(out[i+1]-out[i]);

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


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

int main(){
    string s; cin >> s;
    char now = s[0];
    for(int i=1; i<s.size(); i++){
        if(s[i]==now){
            cout << "Bad" << endl;
            return 0;
        }else{
            now = s[i];
        }
    }
    cout << "Good" << endl;
}

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

int main(){
  int n,ans=0;cin>>n;
  vector<int> x(n,0);
  REP(i,n) cin>>x.at(i);
  sort(x.begin(),x.end());
  if(!(n%2)) ans=x.at(n/2)-x.at(n/2-1);
  cout<<ans;
}

Measured memory_bytes: 768
#include<stdio.h>

int main()
{
	int a, b;
	scanf("%d %d",&a,&b);
	
	int x = 0;
	for(int i = 1; i < a; i++){
		x += i;
	}
	
	int y = 0;
	for(int j = 1; j < b; j++){
		y += j;
	}
	
	printf("%d",y+x);
	
	
	
	return 0;
}

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

int main() {
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if((r <= x)&&(x <= w-r)&&(r <= y)&&(y <= h-r)) {
    cout << "Yes" << endl;
    return 0;
  }else
  {
    cout << "No" << endl;
    return 0;
  }
}


Measured memory_bytes: 3116
s = input()
l = len(s)
if s[0] == 'A':
    s = s[1:]
    if 'C' in s[1:-1]:
        s = s.replace('C', '')
        if s.islower():
            if len(s) == l - 2:
                print('AC')
                exit()
print('WA')


Measured memory_bytes: 2940
#include <stdio.h>
int main(void) {
    int n, x, a, b, c, ab, abc, cnt;
 
    while (1) {
        scanf("%d %d", &n, &x);
        if (n == 0 && x == 0)
            break;
        n += 1;
        cnt = 0;
        for (a = 1; a < n; a++) {
            if (a >= x)
                break;
            for (b = a+1; b < n; b++) {
                ab = a + b;
                if (ab >= x)
                    break;
                for (c = b+1; c < n; c++) {
                    abc = ab + c;
                    if (abc == x) {
                        cnt += 1;
                        break;
                    }
                    if (abc > x)
                        break;
                }
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}


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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

const int mod = 1000000007;

long long dp[100500];
long long p[100500];
int a[105];

long long get(int l, int r) {
    l = max(l, 0);
    return p[r + 1] - p[l];
}

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n >> k;
    forn(i, n) cin >> a[i];

    dp[0] = 1;

    forn(i, n) {
        p[0] = 0;
        forn(j, k + 1)
            p[j + 1] = p[j] + dp[j];

        forn(j, k + 1)
            dp[j] = get(j - a[i], j) % mod;
    }

    cout << dp[k];

    return 0;
}

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

using namespace std;
int n,k,a[505];
int tcnt[505];
int main()
{
    scanf("%d%d",&n,&k);
    int sums = 0;
    for(int i=0;i<n;++i){scanf("%d",a+i);sums+=a[i];}
    int sq = ceil(sqrt(sums));
    int ans = 0;

    for(int i=1;i<=sq;++i)
    {
        if(sums%i==0){
            int mod=i,tk=k;
            for(int t=0;t<2;++t)
            {
            for(int j=0;j<n;++j)tcnt[j] = a[j]%mod;
            sort(tcnt,tcnt+n);
            int j=0,je=n-1;

            while(j<je){
                int u=tcnt[j];
                tk-=tcnt[j];
                if(tk<0) break;
                while(u&&je>j){
                    if(u>=mod-tcnt[je]){u-=mod-tcnt[je];--je;}
                    else {tcnt[je]+=u;u=0;}
                }
                ++j;
            }
            if(j>=je) ans = max(ans,mod);
            mod = sums/i;tk=k;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	if (N == 1)
	{
		cout << "Hello World";
	}
	else if (N == 2)
	{
		int A, B;
		cin >> A >> B;

		cout << A + B;
	}

	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int main()
{
    int N, K, T, U, V, L;
    cin >> N >> K >> T >> U >> V >> L;
    int d[N + 1];
    rep(i, N)
    {
        cin >> d[i];
    }
    d[N] = L;
    int hav = 0;
    int nextDist = 0;
    double m = 0;
    rep(c, N + 1)
    {
        // cerr << nextDist << “,” << c << “,” << m << endl;
        if (nextDist <= d[c])
        {
            if (hav >= 1)
            {
                nextDist = nextDist + V * T;
                c--;
                hav--;
            }
            else
            {
                if (c != N)
                    nextDist = d[c] + V * T;
            }
        }
        else
        {
            if (hav + 1 <= K)
            {
                if (c != N)
                    hav++;
                else
                    m += nextDist - d[c];
            }
            else
            {
                m += nextDist - d[c];
                if (c != N)
                    nextDist = d[c] + V * T;
            }
        }
        // cout << m << endl;
        // cout << (double)(N * V * T - m) / (double)V + (double)(L - (N * V * T - m)) / (double)U << endl;
    }

    m += hav * V * T;
    // cout << 1 << “+” << (double)(N * V * T - m) / (double)V + (double)(L - (N * V * T - m)) / (double)U << endl;
    // cout << 1 << “+” << (double)(N * V * T - m) / (double)V + (double)(L - (N * V * T - m)) / (double)U << endl;
    double ans = (double)(N * V * T - m) / (double)V + (double)(L - (N * V * T - m)) / (double)U;
    printf("% 0.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ll n,m,x,y,z;
    cin>>n>>m;
    x=(n*(n-1))/2;
    y=(m*(m-1))/2;
    cout<<x+y<<endl;
    return 0;
}


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long LL;
#define REP(i,s,N) for (int i=s; i<N; i++)

int main() {
	int N, K;
	LL ans;
	cin >> N >> K;
	ans = K;
	REP(i,0,N-1){
		ans = ans*(K-1);
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n; cin >> n;
    vector<ll> W(n); cin >> W;
    vector<ll> s(n+1, 0);
    REP(i, n) s[i+1] = s[i] + W[i];
    vector< vector<ll> > dp(n, vector<ll>(n+1, linf));
    vector< vector<ll> > K(n, vector<ll>(n+1, linf));
    REP(i, n) dp[i][i+1] = 0;
    REP(i, n) K[i][i+1] = i;
    FOR(w, 2, n+1) REP(l, n-w+1) {
        ll r = l + w;
        FOR(m, K[l][r-1], K[l+1][r]+1) {
            ll c = dp[l][m] + dp[m][r] + s[r]-s[l];
            if (c < dp[l][r]) {
                dp[l][r] = c;
                K[l][r] = m;
            }
        }
    }
    cout << dp[0][n] << endl;
}

Measured memory_bytes: 253408
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]


p = Counter()
q = Counter()

for i in range(n):
    p[i-a[i]] += 1
    q[i+a[i]] += 1
    
ans = 0

for x in p.keys():
    ans += p[x]*q[x]

print(ans)

Measured memory_bytes: 141808
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2000;
int a[maxn+5],n,now;
int num[maxn*maxn+5],T;
bitset<maxn*maxn+maxn> S;
int main(){
	scanf("%d",&n),S[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&now);
		S|=S<<now;
	}
	for(int i=1;i<=maxn*maxn;i++) if(S[i]) num[++T]=i;
	printf("%d\n",num[(T+1)>>1]);
	return 0;
}

Measured memory_bytes: 13088
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll N, K; cin >> N >> K;
    cout << min(N%K, K-(N%K)) << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll d,k;
string s;
ll dp[150][10050];

ll adderer(ll ind,ll rem)
{
    ll ans = 0;
    ll fst = s[ind]-'0';
    // trace(fst)

    if(ind==k-1)
    {
        REP(i,fst+1)
        {
            if(i%d==rem)
                ans = add(ans,1);
        }
        return ans;
    }

    REP(j,fst)
    {
        // if(ind==0 && j==0)    continue;
        ans = add(ans,dp[(rem-j+10*d)%d][k-ind-2]);
        // trace((rem-j+10*d)%d)
        // trace(k-ind-2)
        // trace(ans)
    }
    
    ans = add(ans,adderer(ind+1,(rem-fst+10*d)%d));
    return ans;
}

int main()
{
    IOS
    cin>>s;
    cin>>d;
    k = sz(s);

    REP(i,d)
    {
        dp[i][0]=0;
    }
    REP(i,10)
    {
        dp[i%d][0] = add(dp[i%d][0],1);
    }
    REP(j,k+1)
    {
        REP(i,d)
        {
            if(j==0)
            {
                continue;
            }
            else
            {
                ll sum=0;
                REP(x,10)
                {
                    sum = add(sum,dp[(i-x+10*d)%d][j-1]);
                }
                dp[i][j] = sum;
            }
        }
    }

    ll ans = MOD-1;  
    
    ans = add(ans,adderer(0,0));
    cout<<ans<<endl;
}

Measured memory_bytes: 8960
_, m = gets.chomp.split(" ").map(&:to_i);
a_arr = gets.chomp.split(" ").map(&:to_i);

a_arr.sort!.reverse!

sum = 0
a_arr.each do |e|
  sum = sum + e
end

if a_arr[m - 1] < sum.to_f / (4 * m)
  puts 'No'
else
  puts 'Yes'
end


Measured memory_bytes: 1788
def main():
    W, H, x, y = map(int, input().split())
    S_small = W*H/2
    x_symme = W - x
    y_symme = H - y
    if (x == x_symme) and (y == y_symme): ans2 = 1
    else: ans2 = 0
    print(S_small, ans2)
    
main()

Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if(abs(x - a) < abs(x - b)) cout << "A" << endl;
	else cout << "B" << endl;
}

Measured memory_bytes: 256
exec("def nWord(): nWord.cache = raw_input() if not hasattr(nWord, 'cache') or nWord.cache=='' else nWord.cache ; pos = nWord.cache.find(nWord.sep) ; ret, nWord.cache = (nWord.cache, '') if pos==-1 else (nWord.cache[:pos], nWord.cache[pos+1:].lstrip(nWord.sep)) ; return ret") ; exec("nWord.sep = ' '") ; exec("def ___nLine2(): ret, nWord.cache = (raw_input(), nWord.cache if hasattr(nWord, 'cache') else '') if not hasattr(nWord, 'cache') or nWord.cache=='' else (nWord.cache, '') ; return ret") ; exec('def nInt(): return int(nWord())') ; exec('def nFloat(): return float(nWord())') ; exec("def ___nAuto2():\n ret = nWord()\n try: return int(ret)\n except: pass\n try: return float(ret)\n except: return ret") ; exec("def nAuto(n=None): return ___nAuto2() if n is None else [___nAuto2() for i in range(n)]") ; exec("def nLine(n=None): return ___nLine2() if n is None else [___nLine2() for i in range(n)]")

nAuto()
A = [int(i) for i in raw_input().split(' ')]

A.reverse()
A.append(0)
A.reverse()

for i in range(1, len(A)):
    A[i] = A[i] + A[i-1]

dic = {}

cnt = 0
for i in A:
    if i not in dic:
        dic[i] = 1
    else:
        cnt += dic[i]
        dic[i] += 1
print(cnt)


Measured memory_bytes: 33788
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=[int(s) for s in ST()[::-1]]
    T=S.copy()
    ans = 0
    flag = False
    for i,s in enumerate(S):
        t=S[i]
        if t>=10:
            try:
                S[i+1]+=1
            except:
                flag = True
            t-=10
        if t>5:
            ans += 10-t
            try:
                S[i+1]=(S[i+1]+1)
            except:
                flag = True
        elif t!=5:
            ans += t
        else: #5
            ans += t
            try:
                if S[i+1]>=5:
                    S[i+1] += 1
            except:
                pass
    print(ans+int(flag))


if __name__ == '__main__':
    main()



Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int x,k,d;
   cin>>x>>k>>d;
   if(x<0)
    x=-1*x;
   long long int n=x/d;
   //no .of moves to get the minimum pos. coordinate;
  // cout<<k*d<<"\n";
   if(k>n)
   {
    long long int mn=x-n*d;
   if(mn>abs(mn-d))
    {mn=abs(mn-d);
   if((k-n-1)%2==0)
    cout<<mn;
   else
    cout<<d-mn;
    }
    else
    {
        if((k-n)%2==0)
            cout<<mn;
        else
            cout<<d-mn;
    }
   }
   else
   cout<<x-k*d;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 文字列の入力
		int d = (a-b) % c;
		System.out.println(d);
	}
}


Measured memory_bytes: 21844
using System;

namespace Dice
{
    class Program
    {
        private static bool Eql(string[] x, string[]y)
        {
            bool g = true;
            for (int o = 0; o < x.Length; o++)
              if (x[o] != y[o]) g = false;
            return g;
        }

        private static string Check(string[] x, string[] y)
        {
            if (Eql(x, y)) return "Yes";
            for (int p = 0; p < 2; p++)
            {
                for(int q = 0; q < 4; q++)
                {
                    var a = x[0]; var b = x[1]; var c = x[2];
                    var d = x[3]; var e = x[4]; var f = x[5];
                    x = p == 0 ? new string[] { e, a, c, d, f, b } :
                                 new string[] { d, b, a, f, e, c };
                    if (Eql(x, y)) return "Yes";
                    var h = x;
                    for(int r = 0; r < 4; r++)
                    {
                        var i = h[0]; var j = h[1]; var k = h[2];
                        var l = h[3]; var m = h[4]; var n = h[5];
                        h = new string[] { i, k, m, j, l, n };
                        if (Eql(h, y)) return "Yes";
                    }
                }
            }
            return "No";
        }

        static void Main()
        {
            var s = Console.ReadLine().Split(' ');
            var t = Console.ReadLine().Split(' ');
            Console.WriteLine(Check(s, t));
        }
    }
}

Measured memory_bytes: 8936
import sys

with sys.stdin as f:
    s_input = f.read()

    s_args = s_input.splitlines()
    a = int(s_args[0])
    b = int(s_args[1])
    c = int(s_args[2])
    d = int(s_args[3])

    s = min(a, b) + min(c, d)
    print(s)
        
sys.exit(0)


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N;
  cin >> N;
  if (N % 2 == 0) {
    long M = N * (N - 1) / 2 - N / 2;
    cout << M << endl;
    for (long i = 1; i <= N; i++) {
      for (long j = i + 1; j <= N; j++) {
        if (i + j == N + 1) continue;
        cout << i << " " << j << endl;
      }
    }
  } else {
    long M = N * (N - 1) / 2 - N / 2;
    cout << M << endl;
    for (long i = 1; i <= N; i++) {
      for (long j = i + 1; j <= N; j++) {
        if (i + j == N) continue;
        cout << i << " " << j << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main(void)
{
    int a[100], b[100], c[100],A,B,C,D,P,PP,s1,s2,s3;
    A = 0;
    B = 0;
    C = 0;
    D = 0;
    P = 0; 
    PP = 0;
    s1 = 0;
    s2 = 0;
    s3 = 0; 

    for (int i = 0; i < 100; i++)
    {
        cin >> a[i];
        s1 = a[i];
        cin >> b[i];
        if (b[i] >= s1)
        {
            s1 = 0;
            s1 = b[i];
            s2 = 0;
            s2 = a[i];
        }
        else
        {
            s2 = b[i];
        }
        cin >> c[i];
        if (c[i] >= s1)
        {
            s3 = 0;
            s3 = s2;
            s2 = 0;
            s2 = s1;
            s1 = 0;
            s1 = c[i];
           
        }
        else if (c[i] >= s2)
        {
            s3 = 0;
            s3 = s2;
            s2 = 0;
            s2 = c[i];
        }
        else
        {
            s3 = c[i];
        }

        P = (s2 * s2) + (s3 * s3);
        PP = s1 * s1;

        if (a[i] + b[i] > c[i] && b[i] + c[i] > a[i])
        {
            if (c[i] + a[i] > b[i])
            {
                A += 1;
                if (P == PP)
                {
                    B += 1;

                }
                else if (P > PP)
                {
                    C += 1;
                }
                else if (P < PP)
                {
                    D += 1;
                }

            }
            else
            {
                cout << A << " " << B << " " << C << " " << D << endl;
                break;
            }
        }
        else
        {
            cout << A << " " << B << " " << C << " " << D << endl;
            break;
        }
    }

}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int n,q,b,e,k;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
        cin >> vec[i];
    cin >> q;
    while (q--) {
        cin >> b >> e >> k;
        vector<int>::iterator itbe = vec.begin(), iten = vec.begin();
        while (b--)
            itbe++;
        while (e--)
            iten++;
        cout << count(itbe, iten, k) << endl;
    }
}


Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			string s1 = cin.Next();
			string s2 = cin.Next();

			long ans = 0;
			int count = 0;
			int color = 0;
			while (count < n) {
				if (s1[count] == s2[count]) {
					if (color == 0) {
						ans = 3;
					} else if (color == 1) {
						ans = (ans * 2) % MOD;
					} else {
					}

					count++;
					color = 1;
				} else {
					if (color == 0) {
						ans = 6;
					} else if (color == 1) {
						ans = (ans * 2) % MOD;
					} else {
						ans = (ans * 3) % MOD;
					}

					count += 2;
					color = 2;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int n,s[105],ans,m=100000;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>s[i];
		ans+=s[i];
		if (s[i]%10!=0 && s[i]<m) m=s[i];
	}
	if (ans%10==0){
		if (m==100000){
			cout<<0;
		}else{
			cout<<ans-m;
		}
	}else{
		cout<<ans;
	}
	return 0;
}

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

using ll = long long;
#define rep(n, i) for(ll i = 1; i <= n; ++i)

void solve(void){
  ll n, a, b; cin >> n >> a >> b;

  ll res = 0;
  rep(n, i) {
    ll tmp = i;
    ll cnt = 0;

    while (tmp != 0) {
      cnt += tmp % 10;
      tmp /= 10;
    }

    if (a <= cnt && cnt <= b) res += i;
  }
  cout << res << endl;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256