akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int dot(vs32& a, vs32& b)
{
    int ret = 0;
    rep (i, a.size())
    {
        ret += a[i] * b[i];
    }
    return ret;
}

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

    int n, m, c;
    cin >> n >> m >> c;

    vs32 b(m);
    rep (i, m) cin >> b[i];


    vs32 a(m);
    int ans = 0;
    rep (i, n)
    {
        rep (j, m)
        {
            cin >> a[j];
        }
        if (dot(a, b) + c > 0) ++ans;
    }

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



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

int main() {

  string O, E;
  cin >> O >> E;

  if (O.size() == E.size()) {

    for (int i = 0; i < O.size(); i++) {
      cout << O[i] << E[i];
    }
    cout << endl;
  
  } else {
  
    for (int i = 0; i < O.size() - 1; i++) {
      cout << O[i] << E[i];
    }
    cout << O[O.size() - 1] << endl;
  
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1005;
int n,a[N];
bool vis[N];
queue<int>s;
void solve(int n)
{
    if(n==1) return;
    if(!vis[1])
    {
        s.push(1);
        for(int i=1;i<n;i++)
            vis[i]=vis[i+1];
        solve(n-1);
        return;
    }
    if(!vis[n])
    {
        s.push(n);
        solve(n-1);
        return;
    }
    for(int i=2;i<n;i++)
        if(!vis[i]&&!vis[i-1]&&!vis[i+1])
    {
        s.push(i);
        for(int j=i;j<=n-2;j++)
            vis[j]=vis[j+2];
        solve(n-2);
        return;
    }
    for(int i=2;i<n;i++)
        if(!vis[i])
    {
        s.push(i);
        for(int j=i;j<=n-2;j++)
            vis[j]=vis[j+2];
        solve(n-2);
        return;
    }
}
int main()
{
    scanf("%d",&n);
    ll ans=-1e9;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),ans=max(ans,(ll)a[i]);
    if(ans<=0)
    {
        printf("%lld\n",ans);
        printf("%d\n",n-1);
        int x=1;
        for(int i=1;i<=n;i++)
            if(x==1)
        {
            if(a[i]!=ans) printf("%d\n",x);
            else x=n-i+1;
        }
        else printf("%d\n",x--);
        return 0;
    }
    ans=0;
    ll res=0;
    for(int i=1;i<=n;i++)
        if(i&1) ans=max(ans,ans+a[i]);
    else res=max(res,res+a[i]);
    if(ans>res)
    {
        printf("%lld\n",ans);
        for(int i=1;i<=n;i++)
            if((i&1)&&a[i]>=0)
                vis[i]=true;
        solve(n);
    }
    else
    {
        printf("%lld\n",res);
        for(int i=1;i<=n;i++)
            if(!(i&1)&&a[i]>=0)
                vis[i]=true;
        solve(n);
    }
    printf("%d\n",s.size());
    while(!s.empty())
    {
        printf("%d\n",s.front());s.pop();
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	int h, a;
	cin >> h >> a;
	int num;
	num = h % a;
	if (num != 0)num = 1;
	else num = 0;
	cout << h / a + num << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input1 = Console.ReadLine().Split(' ');
        int A = int.Parse(input1[0]);
        int B = int.Parse(input1[1]);
        int C = int.Parse(input1[2]);

        if (A * C > B)
            Console.WriteLine(B / A);
        else
            Console.WriteLine(C);
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
int main()
{
  int a,b,c;
  int d=0,e=0;
  scanf("%d %d",&a,&b);
  for(c=1;c<=a;c++) d+=(c-1);
  for(c=1;c<=b;c++) e+=(c-1);
  printf("%d",d+e);
}

Measured memory_bytes: 128
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//
// ?????¢
// XCode??§???EOF??\??????Ctrl+D
// ?\???Alt+\
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////
//ALDS1_5_C:   Koch Curve
//
//?????????????????¨??????????????????????????????
////////////////////////////////////////

#include <iostream>
#include <algorithm> // next_permutation
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate
//#include <unordered_map> //???????????\??¢??°

using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
#define TEST //*******************************************************************************************************************************************

//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
//??????????????????????????????????????????????????????????§?CPU???????£??????????????????§???TLE?????????????????????????????????????????§????????¨???
#ifdef TEST
#define dout cout
#else
stringstream dummy; //???????????°??????dout?????????????????????????????????
#define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
//???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif


#define disp(A) dout << #A << " = " << (A) << endl
#define disP(A) dout << (A) << " "
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)

#define dispAll(A,n) dout << #A << " = "; rep(j, 0, (n)) {disP(A[j]);} dout << endl

#define pdd pair<double, double>
#define x first
#define y second

const int INF = 2147483647;

void kochCurve(int n, pdd p1, pdd p2) {
    
    if(n==0) {
        
        cout << fixed << setprecision(8) << p1.x << " " << p1.y << endl;
//        cout << fixed << setprecision(8) << p2.x << " " << p2.y << endl;
        
    } else {
        
        pdd s, t, u;
        
        //calc.
        s.x = (2*p1.x + p2.x)/3;
        s.y = (2*p1.y + p2.y)/3;
        
        t.x = (p1.x + 2*p2.x)/3;
        t.y = (p1.y + 2*p2.y)/3;
        
        u.x = (t.x-s.x)/2 - (t.y-s.y)*sqrt(3)/2 + s.x;
        u.y = (t.y-s.y)/2 + (t.x-s.x)*sqrt(3)/2 + s.y;
        
        kochCurve(n-1, p1, s);
        kochCurve(n-1, s, u);
        kochCurve(n-1, u, t);
        kochCurve(n-1, t, p2);
        
    }
    
    return;
}

int main(void) {
    int N = 2;
    cin >> N;
    
//    disp(N);
    
    pdd p1, p2;
    
    p1 = {0,0};
    p2 = {100, 0};
    
    
    kochCurve(N, p1, p2);
    cout << fixed << setprecision(8) << p2.x << " " << p2.y << endl;

    

    
    
    
    return 0;
}

Measured memory_bytes: 3256
def maxHeapify i
  l = i*2
  r = l+1
  l = i unless $a[l-1]
  r = i unless $a[r-1]
  max = [i,l,r].max_by {|i| $a[i-1]}
  unless max == i
    $a[i-1],$a[max-1] = $a[max-1],$a[i-1]
    maxHeapify max
  end
end
$H=gets.to_i
$a=gets.split.map &:to_i
($H/2).downto(1) {|i| maxHeapify i}
print ' ',$a.join(' ')
puts

Measured memory_bytes: 159488
#include <stdio.h>

int main(){
  int N,i,ct=0;

  scanf("%d",&N);
  int A[N];
  int B[N];
  int C[N-1];

  for(i=0;i<N;i++)scanf("%d",&A[i]);
  for(i=0;i<N;i++)scanf("%d",&B[i]);
  for(i=0;i<N-1;i++)scanf("%d",&C[i]);

  for(i=0;i<N;i++)ct+=B[A[i]-1];
  for(i=0;i<N-1;i++)if(A[i+1]-A[i]==1)ct+=C[A[i]-1];

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

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}
using Color = int;
int main() {
    fastio;
    ll N;
    cin >> N;
    vector<set<int>> g(N);
    vector<pair<int,int>> e;
    rep(i,N-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].insert(b);
        g[b].insert(a);
        e.push_back({a,b});
    }

    auto getcolor = [](int x, int y) -> Color& {
        static map<pair<int,int>,Color> mc;
        if (x > y)
            swap(x,y);
        return mc[{x,y}];
    };

    queue<pair<int,int>> q;
    q.emplace(0,0);
    while (!q.empty()) {
        auto [vc, vp] = q.front(); q.pop();
        Color cp = getcolor(vp, vc);
        Color cn=1;
        auto issue_color = [&] {
            if (cn == cp) ++cn;
            return cn++;
        };
        for (int vn : g.at(vc)) {
            Color& cc = getcolor(vc, vn);
            if (cc != 0) continue;
            cc = issue_color();
            q.emplace(vn, vc);
        }
    }

    size_t k = 0;
    for (auto& vs : g) {
        updmax(k, vs.size());
    }
    cout << k << endl;
    for (auto p : e) {
        cout << getcolor(p.first, p.second) << endl;
    }
}


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

map<string, int> d;

int main(){
  int max_n=0, max_len=0;
  string s, n_s, len_s;
  while(cin>>s){
    if(max_len<s.length()){
      len_s=s;
      max_len=s.length();
    }
    d[s]++;
    if(max_n<d[s]){
      n_s=s;
      max_n=d[s];
    }
  }
  cout<<n_s<<' '<<len_s<<endl;
  return 0;
}

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

using namespace std;

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

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

char a[12000], b[12000], t[12000];

int main(){
  while(~scanf("%s", a)){
    scanf("%s", b);

    strcpy(t, b);
    memset(b, '\0', sizeof(b));
    strcpy(&b[3999], t);

    int res = 0;
    rep(i, 8001){
      int count = 0, k = 0;
      REP(j, i, i + 4001){
	//	if(k == 0 && j == 3999) printf("%d %d\n", k, j);
	if(a[k] != '\0' && b[j] != '\0' && a[k] == b[j]){
	  count++;
	  //	  printf("%d\n", count);
	}else{
	  res = max(res, count);
	  count = 0;
	}
	k++;
      }
      res = max(res, count);
    }
    //    printf("%c %c\n", a[0], b[3999]);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 998244353;

//Prime_Factorization
vector<prl> prime_fact(ll n){
    vector<prl> p;
    ll nc = n;
    for(ll i = 2; i * i <= n; i++){
        if(nc % i !=0) continue;
        ll c = 0;
        while(nc % i == 0) c++, nc /= i;
        p.push_back({i, c});
    }
    if(nc > 1) p.push_back({nc, 1});
    return p;
}

int main() {
    // your code goes here
    ll n,ans=0,mm[100]={0},hr[]={0,1,3,6,10,15,21,28,36,45,55,66};
    rep(i,1,10){
    	rep(j,hr[i],hr[i+1]-1) mm[j]=i;
    }
    cin >> n;
    vector<prl> v;
    v=prime_fact(n);
    for(auto to:v){
    	ans+=mm[to.second];
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long

auto main() -> signed {
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0; i<n; ++i) {
        int s;
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(), v.end());
    int ans = accumulate(v.begin(), v.end(), 0);
    int i = 0;
    while(true) {
        if(ans%10!=0) break;
        if(i==v.size()) break;
        if(i!=0) ans += v[i-1];
        ans -= v[i];
        i++;
    }
    if(ans%10==0) ans = 0;
    cout << ans << endl;
    return 0;
}



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
		ll N, K;
	cin >> N >> K;
	if (N%K==0) {
		ce(0)
	}
	else if(N<K) {
		ce(min(N,K-N))
	}
	else {
		ll k = N / K * K;
		ce(min(N-k,K-N+k))
	}


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

char s[100005];
int animal[4][100005];

int main() {

	int N;

	scanf("%d", &N);

	scanf("%s", s);

	int i, j;

	if (s[0] == 'o') {
		animal[0][N - 1] = 0;
		animal[0][0] = 0;
		animal[0][1] = 0;

		animal[1][N - 1] = 1;
		animal[1][0] = 0;
		animal[1][1] = 1;

		animal[2][N - 1] = 0;
		animal[2][0] = 1;
		animal[2][1] = 1;

		animal[3][N - 1] = 1;
		animal[3][0] = 1;
		animal[3][1] = 0;
	}
	else {
		animal[0][N - 1] = 0;
		animal[0][0] = 0;
		animal[0][1] = 1;

		animal[1][N - 1] = 1;
		animal[1][0] = 0;
		animal[1][1] = 0;

		animal[2][N - 1] = 1;
		animal[2][0] = 1;
		animal[2][1] = 1;

		animal[3][N - 1] = 0;
		animal[3][0] = 1;
		animal[3][1] = 0;
	}

	for (j = 0; j < 4; j++) {


		for (i = 1; i < N - 1; i++) {
			if (animal[j][i] == 0) {
				if (animal[j][i - 1] == 0) {
					if (s[i] == 'o') { animal[j][i + 1] = 0; }
					else { animal[j][i + 1] = 1; }
				}
				else {
					if (s[i] == 'o') { animal[j][i + 1] = 1; }
					else { animal[j][i + 1] = 0; }
				}
			}
			else {
				if (animal[j][i - 1] == 0) {
					if (s[i] == 'o') { animal[j][i + 1] = 1; }
					else { animal[j][i + 1] = 0; }
				}
				else {
					if (s[i] == 'o') { animal[j][i + 1] = 0; }
					else { animal[j][i + 1] = 1; }
				}
			}
		}

		int a;

		int b;

		if (animal[j][N - 1] == 0) {
			if (animal[j][N - 2] == 0) {
				if (s[N - 1] != 'o') {
					a = 1;
				}
				else {
					a = 0;
				}
			}
			else {
				if (s[N - 1] != 'o') {
					a = 0;
				}
				else {
					a = 1;
				}
			}
		}
		else {
			if (animal[j][N - 2] == 0) {
				if (s[N - 1] != 'o') {
					a = 0;
				}
				else {
					a = 1;
				}
			}
			else {
				if (s[N - 1] != 'o') {
					a = 1;
				}
				else {
					a = 0;
				}
			}
		}
		if (animal[j][0] == 0) {
			if (animal[j][N - 1] == 0) {
				if (s[0] != 'o') {
					b = 1;
				}
				else {
					b = 0;
				}
			}
			else {
				if (s[0] != 'o') {
					b = 0;
				}
				else {
					b = 1;
				}
			}
		}
		else {
			if (animal[j][N - 1] == 0) {
				if (s[0] != 'o') {
					b = 0;
				}
				else {
					b = 1;
				}
			}
			else {
				if (s[0] != 'o') {
					b = 1;
				}
				else {
					b = 0;
				}
			}
		}


		if (animal[j][0] == a && animal[j][1] == b) {
			for (i = 0; i < N; i++) {
				if (animal[j][i] == 0) {
					printf("S");
				}
				else {
					printf("W");
				}
			}
			printf("\n");
			return 0;
		}
	}

	printf("-1\n");

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    string s;
    bool flg=true;
    cin >> s;
    int n = s.size();
    rep(i,n/2){
        if(s[i]!=s[n-i-1]){
            flg=false;
        }
    }
    n = (s.size()-1)/2;
    rep(i,n){
        if(s[i]!=s[n-i-1]){
            flg=false;
        }
    }
    int i = (s.size()+3)/2;
    for(;i<n;i++){
        if(s[i]!=s[n-i-1]){
            flg=false;
        }
    }
    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define Mod 1000000007

int main()
{
	int i, N, C[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(C[i]));
	
	int recent[200001] = {};
	long long dp[200001];
	for (i = 1, dp[0] = 1; i <= N; i++) {
		if (recent[C[i]] != 0 && recent[C[i]] < i - 1) dp[i] = (dp[i-1] + dp[recent[C[i]]]) % Mod;
		else dp[i] = dp[i-1];
		recent[C[i]] = i;
	}
	
	printf("%lld\n", dp[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4860
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int D[1000];
int n;
void insertion_sort(int D[],int n){
	for (int k = 0; k < n; k++) {
		if (k == n - 1) {
			cout << D[k] << endl;
		}
		else {
			cout << D[k] << " ";
		}
	}
	for (int i = 1; i < n; i++) {
		int tmp = D[i];
		int j = i-1;
		while (j >= 0 && D[j] > tmp) {
			D[j+1] = D[j];
			j--;
		}
		D[j+1] = tmp;
		for (int k = 0; k < n; k++) {
			if (k == n - 1) {
				cout << D[k] << endl;
			}
			else {
				cout << D[k] << " ";
			}
		}
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> D[i];
	}
	insertion_sort(D, n);
}

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

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

	bool ok = false;
	for (auto& c : s) {
		if (c == '7') {
			ok = true;
		}
	}
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int ans[200][200];
int main(){
	int x,y;
	int dir=1;
	cin>>y>>x;
	int n;
	cin>>n;
	int posx=1,posy=1;
	for(int a=1;a<=n;++a){
	int xc;
	cin>>xc;
	for(int x1=1;x1<=xc;++x1){
	ans[posy][posx]=a;
	posx+=dir; 
	if(posx>x||posx==0){posy++;dir=-dir;if(posx==0)posx=1;else posx=x;}
	}
	
	}
	for(int a1=1;a1<=y;++a1){
	for(int a2=1;a2<=x;++a2){
	cout<<ans[a1][a2];
	if(a2==x)cout<<endl;else cout<<" ";
	}}
	
	
	
	
	return 0;} 

Measured memory_bytes: 764
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var list = new List<Res>();
        for(int i=0; i<n; i++) {
            var spl   = input.ReadLine().Split(' ');
            var a     = spl[0];
            var b     = int.Parse(spl[1]);

            var r = new Res();
            r.i = i+1;
            r.s = a;
            r.p = b;
            list.Add(r);
        }

        list.Sort((x, y) => {
            var c = x.s.CompareTo(y.s);
            if (c == 0) {
                c = y.p - x.p;
            }
            return c;
        });

        var buil = new StringBuilder();
        foreach (var i in list) {
            buil.AppendLine(i.i.ToString());
        }

        return buil;
    }

    class Res
    {
        public int i;
        public string s;
        public int p;
    }
}

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

int main(){
    int n;
    cin >> n;
    long long int res = 0;
    for(int i = 1; i <= n; i++){
        if(!(i % 3 == 0 || i % 5 == 0)) res += i;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3632
S = input()
t = len(S)
L = [("dream", 5), ("dreamer", 7), ("erase", 5), ("eraser", 6)]
while t > 0:
    for w, l in L:
        if S.rfind(w, 0, t) == t - l:
            t -= l
            break
    else:
        print("NO")
        break
else:
    print("YES")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int K,N;
  cin>>K>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int r,l;
  int MIN=INF;
  for(int i=0;i<N;i++){
    if(i==0){l=A[0]+(K-A[N-1]);}
    else {l=A[i]-A[i-1];}
    if(i==N-1){r=K-A[N-1]+A[0];}
    else{r=A[i+1]-A[i];}
    int m=min(K-r,K-l);
    chmin(MIN,m);
  }
  cout<<MIN<<endl;
  return 0;  
}

Measured memory_bytes: 4028
#include <iostream>
#include <vector>

using namespace std;

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

    vector<string> date = {
        "SUN",
        "MON",
        "TUE",
        "WED",
        "THU",
        "FRI",
        "SAT",
        "SUN"
    };

    int n = 0;
    bool flag = false;
    for(string d : date){
        if (flag) n++;
        if(d == s) flag = true;
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
import copy
h,w,K=map(int,input().split())
maze=[]
for i in range(h):
    line=list(input())
    maze.append(line)
ans=0
for i in range(2**(w+h)):
    g=[]
    r=[]
    for j in range(w+h):
        if i&(1<<j) and j<h:
            g.append(j)
        if i&(1<<j) and j>=h:
            r.append(j-h)
    tmp=copy.deepcopy(maze)
    cnt=0
    for k in range(h):
        for l in range(w):
            if k in g or l in r:
                continue
            if tmp[k][l]=="#":
                cnt+=1
    if cnt==K:
        ans+=1
print(ans)



Measured memory_bytes: 70660
#include <bits/stdc++.h>
#include <atcoder/dsu>
#include <cstdio>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define lwb lower_bound
#define upb upper_bound
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    int N, M;
    cin>>N>>M;
    dsu d(N);
    int a, b;
    rep(i, M){
        cin>>a>>b;
        d.merge(a-1,b-1);
    }
    cout<<d.groups().size()-1<<endl;
 
  
}

Measured memory_bytes: 8976
import java.util.*;
class Main{
    public static void main(String[] args)
    {
	Scanner in = new Scanner(System.in);
	String s,s2;
	int n,de=0;
	s = in.next();
	n = in.nextInt();
	for(int i=0;i<n;i++)
	    {
		s2 = in.next();
		int ln = s2.length();
s2 = s2 + s2;
		while(ln-- > 0)
		    {

			if(s2.contains(s))
			    {
				de++;
				break;
			    }
			
		    }
	    }
	System.out.println(de);
    }
} //Res***2Dツつウツづアツづ個づーツ参ツ考

Measured memory_bytes: 12000
local h, w, n = io.read("*n", "*n", "*n", "*l")
local sr, sc = io.read("*n", "*n", "*l")
local s = io.read()
local t = io.read()
local safe_l, safe_r, safe_t, safe_b = 1, w, 1, h
local isok = true
local mma, mmi = math.max, math.min
for i = n, 1, -1 do
  local tt = t:sub(i, i)
  if tt == "L" then
    safe_r = mmi(safe_r + 1, w)
  elseif tt == "R" then
    safe_l = mma(safe_l - 1, 1)
  elseif tt == "U" then
    safe_b = mmi(safe_b + 1, h)
  else
    safe_t = mma(safe_t - 1, 1)
  end
  local ss = s:sub(i, i)
  if ss == "L" then
    safe_l = safe_l + 1
    if safe_r < safe_l then isok = false break end
  elseif ss == "R" then
    safe_r = safe_r - 1
    if safe_r < safe_l then isok = false break end
  elseif ss == "U" then
    safe_t = safe_t + 1
    if safe_b < safe_t then isok = false break end
  else
    safe_b = safe_b - 1
    if safe_b < safe_t then isok = false break end
  end
  if not isok then break end
end
if isok then
  isok = safe_t <= sr and sr <= safe_b and safe_l <= sc and sc <= safe_r
end
print(isok and "YES" or "NO")


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

int flag(int f){
  if(f == 1) return 1;
  if(f == 2) return -1;
}

int main(){
  string s;
  cin >> s;
  int q;
  cin >>q;
  int d= 1; //前後順が反転してる(-1)かしてないか
  string st1 = ""; //頭(本来)につけるやつ
  string st2 = ""; //お尻（だったところ）につける
  for(int i =0; i < q; i++){
    int t;
    cin >> t;
    if(t == 1){
      d = -d;
    }
    else{
      int f;
      char c;
      cin >> f >> c;
      if(flag(f)*d > 0) st1 = c + st1;
      else st2 = st2 + c;
    }
  }
    s = st1 + s;
    s = s + st2;
    if(d == -1) reverse(s.begin(), s.end());
    cout << s << endl;
}

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

using namespace std;

int n[1000]={};
long long a[1000][1000]={};
long long ans = 10000000000;

int main(){
    int s=0;
    while(1){
        scanf("%d",&n[s]);
        if(n[s] == 0){
            break;
        }
        for(int i=0;i<n[s];i++){
           scanf("%lld",&a[s][i]); 
        }
        s++;
    }

    int times =s;
    int sub;
    for(int i=0;i<s;i++){
        sort(a[i],a[i]+n[i]);
        for(int j=0;j<n[i]-1;j++){
            sub = abs(a[i][j] - a[i][j+1]);
            if(ans >= sub){
                ans = sub;
            }
        }
        cout << ans << endl;
        ans = 1000000000;
    }
    

    return 0;
}


Measured memory_bytes: 4144
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc064.contest.atcoder.jp/tasks/arc064_a>
問題文============================================================
 N 個の箱が横一列に並んでいます。 最初、左から i 番目の箱には ai 個のキャンディが入っています。
 
 すぬけ君は次の操作を好きな回数だけ行うことができます。
 
 キャンディが 1 個以上入っている箱をひとつ選び、その箱のキャンディを 1 個食べる。
 すぬけ君の目標は次の通りです。
 
 どの隣り合う 2 つの箱を見ても、それらの箱に入っているキャンディの個数の総和が x 以下である。
 目標を達成するために必要な操作回数の最小値を求めてください。
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,x; cin >> N >> x;
    vector<ll> a(N);
    for(auto& in:a) cin >> in;
    ll ans = 0;
    for(int i = 1;i <N;i++){
        if(a[i] > x){
            ans += a[i]-x;
            a[i] = x;
        }
        if(a[i-1] > x){
            ans += a[i-1] - x;
            a[i-1] = x;
        }
        ll tmp = a[i] + a[i-1];
        if(tmp > x){
            ans += tmp - x;
            a[i] -= min(tmp-x,a[i]);
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <map>
using namespace std;

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

long long myMax(long long a, long long b) {
	return a > b ? a : b;
}


int main() {
	int n; cin >> n;
	long long T = 0, A = 0;
	for (int i = 0; i < n; i++) {
		int t, a; cin >> t >> a;
		long long dt, da;
		dt = T - t > 0 ? T - t : 0;
		da = A - a > 0 ? A - a : 0;
		long long m = myMax((dt + t - 1) / t, (da + a - 1) / a) + 1;
		T = m * t;
		A = m * a;
	}
	cout << A + T << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	string S, T;
	int total;
	total = 0;
	cin >> S >> T;
	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) != T.at(i)) {
			total += 1;
		}
		else if (S.at(i) == T.at(i)) {
			continue;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 3848
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
int main()
{
    int a, b, c, d;
    read(a), read(b), read(c), read(d);
    while (a > 0 && c > 0)
    {
        c -= b;
        if (c <= 0)
        {
            puts("Yes");
            break;
        }
        a -= d;
        if (a <= 0)
        {
            puts("No");
            break;
        }
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

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

    int ac_num=0,wa_num=0;
    vector<int> judge(n);
    vector<int> wa(n);
    

    for (int i = 0; i < m; i++)
    {
        int p;
        string s;

        cin >> p >> s;
        
        if (judge.at(p-1)==1)
        {
            continue;
        }
        else if (s=="AC")
        {
            ac_num++;
            judge.at(p-1)++;
            wa_num+=wa.at(p-1);
        }
        else if (s=="WA")
        {
            wa.at(p-1)++;
        }
    }
    cout << ac_num << " "<< wa_num << endl;
}


Measured memory_bytes: 4060
#include <iostream>
#include <vector>

using namespace std;

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

    vector<vector<int>> s(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            s[i][j] = c - '0';
        }
    }

    vector<vector<int>> vertex(n + 1, vector<int>(m + 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            vertex[i + 1][j + 1] = vertex[i + 1][j] + vertex[i][j + 1]
                                   - vertex[i][j] + s[i][j];
        }
    }

    vector<vector<int>> edgeX(n + 1, vector<int>(m + 1));
    vector<vector<int>> edgeY(n + 1, vector<int>(m + 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i > 0 && s[i][j] == 1 && s[i - 1][j] == 1) edgeX[i + 1][j + 1]++;
            if (j > 0 && s[i][j] == 1 && s[i][j - 1] == 1) edgeY[i + 1][j + 1]++;
            edgeX[i + 1][j + 1] += edgeX[i + 1][j] + edgeX[i][j + 1] - edgeX[i][j];
            edgeY[i + 1][j + 1] += edgeY[i + 1][j] + edgeY[i][j + 1] - edgeY[i][j];
        }
    }

    for (int i = 0; i < q; i++) {
        int sx, sy, ex, ey;
        cin >> sx >> sy >> ex >> ey, sx--, sy--;

        int nowVertex = vertex[ex][ey] - vertex[ex][sy] - vertex[sx][ey] + vertex[sx][sy];
        int nowEdgeX = edgeX[ex][ey] - edgeX[ex][sy] - edgeX[sx + 1][ey] + edgeX[sx + 1][sy];
        int nowEdgeY = edgeY[ex][ey] - edgeY[ex][sy + 1] - edgeY[sx][ey] + edgeY[sx][sy + 1];

        cout << nowVertex - nowEdgeX - nowEdgeY << "\n";
    }
    cout << flush;
    return 0;
}

Measured memory_bytes: 66072
import java.util.Scanner;

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 ans = a + b + c - Math.max(a, Math.max(b, c));

        System.out.println (ans);

    }
}





Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <cmath>
#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()
{
    int n;
    cin >> n;
    vector<int> x(n);
    int sum = 0;
    rep(i, n){
        cin >> x[i];
        sum += x[i];
    }
    int ave = 0;
    ave = round((double)sum / n);
    //sort(x.begin(), x.end());
    int ans = 0;
    rep(i, n){
        ans += pow(abs(x[i] - ave),2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main() {
  // A君の回答を受け取る
  char b;
      cin >> b;
  char ret;

    if(b=='A')ret='T';
    else if(b=='C')ret='G';
    else if(b=='G')ret='C';
    else if(b=='T')ret='A';

  cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i,N) cin >> H.at(i);
    sort(begin(H), end(H));
    int mi = INT32_MAX;
    for (int i = 0; i < (N - K + 1); i++) {
        int low = H[i];
        int high = H[i + K - 1];
        mi = min(mi, abs(high - low));
    }
    cout << mi << endl;
}

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

long long INF = 1e18;

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

    long long a, b, q;
    cin >> a >> b >> q;
    vector<long long> s(a);
    vector<long long> t(b);
    for(int i = 0; i < a; i++){
        cin >> s[i];
    }
    for(int i = 0; i < b; i++){
        cin >> t[i];
    }
    s.push_back(INF);
    s.push_back(-INF);
    t.push_back(INF);
    t.push_back(-INF);
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    for(int i = 0; i < q; i++){
        long long x;
        cin >> x;
        long long ans = INF;

        for(int j = 0; j < 2; j++){
            long long first;
            if(j % 2 == 0) first = lower_bound(s.begin(), s.end(), x) - s.begin();
            else first = upper_bound(s.begin(), s.end(), x) - s.begin() - 1;

            for(int k = 0; k < 2; k++){
                long long second;
                if(k % 2 == 0) second = lower_bound(t.begin(), t.end(), s[first]) - t.begin();
                else second = upper_bound(t.begin(), t.end(), s[first]) - t.begin() - 1;

                ans = min(ans, abs(x - s[first]) + abs(s[first] - t[second]));
            }
        }

        for(int j = 0; j < 2; j++){
            long long first;
            if(j % 2 == 0) first = lower_bound(t.begin(), t.end(), x) - t.begin();
            else first = upper_bound(t.begin(), t.end(), x) - t.begin() - 1;

            for(int k = 0; k < 2; k++){
                long long second;
                if(k % 2 == 0) second = lower_bound(s.begin(), s.end(), t[first]) - s.begin();
                else second = upper_bound(s.begin(), s.end(), t[first]) - s.begin() - 1;

                ans = min(ans, abs(x - t[first]) + abs(t[first] - s[second]));
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2912
#include <iostream>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <climits>
#include <math.h>
#include <map>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair<int, int>

int main(){

	int n, a, b;
	cin >> n >> a >> b;
	int x = b-a;
	if(x >= n-1){
		cout << "OK" << endl;
		return 0;
	}
	x = b/n;
	int y = a/n;
	if(x-y > 0){
		cout << "OK" << endl;
		return 0;
	}
	if(a%n == 0 || b%n == 0){
		cout << "OK" << endl;
		return 0;
	}
	cout << "NG" << endl;
		return 0;

}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[20], x[20][20], y[20][20];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 0; j < a[i]; j++){
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	
	int ans = 0;
	for(int i = 0; i < (1 << n); i++){
		int cnt = 0;
		bool ok = 1;
		for(int j = 0; j < n; j++){
			if((i >> j) & 1){
				cnt++;
				for(int k = 0; k < a[j]; k++){
					if(y[j][k] == 1 && !((i >> x[j][k])&1))
						ok = 0;
					if(y[j][k] == 0 && (i >> x[j][k]) & 1)
						ok = 0;
					if(!ok) break;
				}
			}
			if(!ok) break;
		}
		if(ok) chmax(ans, cnt);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char n[3+1]; //数字を入力するとしても、その数字を文字列として認識させたいならcharで定義する

    scanf("%s", n);//文字列入力の時は、&いらない

    if(n[0] == '7' || n[1] == '7' || n[2] == '7')//文字列として受け取るのだから''がいる
        puts("Yes");
    else 
        puts( "No");
    
    return 0;
}


Measured memory_bytes: 1660
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};

int main(){
  intl H,W;
  cin >> H>>W;
  vvi chizu(H,vi(W,0));
  vvi mindp(H,vi(W,0));
  Rep(i,H){
    Rep(j,W){
      char WB;
      cin >> WB;
      chizu[i][j]=(WB=='.')?1:0;
    }
  }
  
  mindp[0][0]=0;
  Rep1(j,W-1){
    mindp[0][j]=(chizu[0][j-1] - chizu[0][j]>0)?
      mindp[0][j-1]+1 : mindp[0][j-1];
  }
  Rep1(i,H-1){
    mindp[i][0]=(chizu[i-1][0]-chizu[i][0]>0)?
      mindp[i-1][0]+1 : mindp[i-1][0];
  }
  
  Rep1(i,H-1){
    Rep1(j,W-1){
      mindp[i][j]=min(
        (chizu[i][j-1] - chizu[i][j]>0)?
        mindp[i][j-1]+1 : mindp[i][j-1],
        (chizu[i-1][j]-chizu[i][j]>0)?
        mindp[i-1][j]+1 : mindp[i-1][j]
        );
    }
  }
  cout<<( (chizu[0][0]==0)?mindp[H-1][W-1]+1:mindp[H-1][W-1] ) ;
}

Measured memory_bytes: 512
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
ans =0
if n%2==0:
    ans = 2*(sum(a[n//2:])-sum(a[:n//2]))-a[n//2]+a[n//2-1]
else:
    ans = (sum(a[n//2:])-sum(a[:n//2]))*2 - a[n//2] - a[n//2+1]
    ans = max(ans,(sum(a[n//2+1:])-sum(a[:n//2+1]))*2 + a[n//2] + a[n//2-1])
print(ans)

Measured memory_bytes: 7492
import bisect

n = int(input())
ls = list(map(int, input().split()))
ls.sort()

total = 0
for i in range(len(ls)-1):
    for j in range(i+1, len(ls)):
        # k < i+j & k > j-i
        maxindex = bisect.bisect_left(ls, ls[i]+ ls[j], j+1)
        minindex = bisect.bisect_right(ls, ls[j]- ls[i], j+1)
        total += maxindex - minindex
            

print(total)

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

int main()
{
    int n;
    cin >> n;
    int res = 0;
    rep(i, n)
    {
        int left, right;
        cin >> left >> right;
        res += (right - left + 1);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

from collections import Counter, defaultdict

alpha = set([chr(c) for c in range(ord("a"), ord("z") + 1)])

for s in S:
    alpha &= set(list(s))

if not alpha:
    print()
else:
    alpha = sorted(list(alpha))
    cnt = defaultdict(int)
    for s in S:
        for k,c in Counter(s).items():
            if k in alpha:
                if cnt[k] == 0:
                    cnt[k] = c
                cnt[k] = min(cnt[k], c)
    cnt_sorted = sorted(cnt.items(), key=lambda x:x[0])

    ans = ""
    for a,c in cnt_sorted:
        ans += a * c
    
    print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int a, b, c;
ll k;

int main() {
    cin >> a >> b >> c >> k;
    if (k%2) cout << b-a << endl;
    else cout << a-b << endl;
}

Measured memory_bytes: 256
N = int(input())
S1 = input()
S2 = input()
ans = 0
i = 0
if S1[0] == S2[0]:
    ans = 3
    i = 1
else:
    ans = 6
    i = 2
while(i < len(S1)):
    if S1[i] == S2[i]:
        if S1[i - 1] == S2[i - 1]:
            ans *= 2
            ans %= (10 ** 9 + 7)
        i += 1
    else:
        if S1[i - 1] != S2[i - 1]:
            ans *= 3
            ans %= (10 ** 9 + 7)
        else:
            ans *= 2
            ans %= (10 ** 9 + 7)
        i += 2
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    if(S == "abc")cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int s[3][31];
int main(){
    int n,cc;cin>>n>>cc;
    int d[31][31];
    for(int i=1;i<=cc;i++){
        for(int j=1;j<=cc;j++){
            cin>>d[i][j];
        }
    }
    int c[510][510];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>c[i][j];
            for(int k=1;k<=cc;k++){
                s[(i+j)%3][k]+=d[c[i][j]][k];
            }
        }
    }
    int ans=INF;
    for(int i=1;i<=cc;i++){
        for(int j=1;j<=cc;j++){
            if(i==j)continue;
            for(int k=1;k<=cc;k++){
                if(i==k||j==k)continue;
                ans=min(ans,s[0][i]+s[1][j]+s[2][k]);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod= 1e9+7;

int main(){
  int N,K;
  cin>>N>>K;
  int ans(1);
  for (int i(0);i<N;i++){
    if (ans<K)ans*=2;
    else ans+=K;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>=13)
  {cout<<b;
  }else if(a<13 && a>=6)
  {cout<<b/2;
  }
  else if(a<6 && a>=0)
  {cout<<0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 101;
const int MAX_M = 101;

struct edge{
	int to;
	int cost;
};

int d[MAX_N*MAX_N];
vector<edge> G[MAX_N*MAX_N];
int zip[MAX_N][MAX_M];
int flag[MAX_N];
vector<edge> E[MAX_N];

void dijkstra(int s)
{
	priority_queue<P,vector<P>,greater<P> > que;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		vector<edge>::iterator it = G[v].begin();
		rep(i,G[v].size()){
			if(d[G[v][i].to] > d[v] + G[v][i].cost){
				d[G[v][i].to] = d[v] + G[v][i].cost;
				que.push(P(d[G[v][i].to],G[v][i].to));
			}
		}
	}
}

int main()
{
    while(1){
        int n,m,L,K,a,h;
        cin >> n >> m >> L >> K >> a >> h;
        if(n == 0){
            break;
        }
        rep(i,n){
            flag[i] = 0;
        }
        rep(i,n){
            E[i].clear();
        }
        flag[a] = 1;
        flag[h] = 1;
        rep(i,L){
            int bf;
            cin >> bf;
            flag[bf] = 1;
        }
        rep(i,K){
            int p,q,r;
            cin >> p >> q >> r;
            E[p].pb((edge){q,r});
            E[q].pb((edge){p,r});
        }
        int cnt = 0;
        rep(i,n){
            rep(j,m+1){
                G[cnt].clear();
                zip[i][j] = cnt++;
            }
        }
        rep(i,n){
            rep(j,m+1){
                if(flag[i] == 1){
                    rep(k,E[i].size()){
                        rep(l,m+1-j){
                            if(E[i][k].cost <= j+l){
                                G[zip[i][j]].pb((edge){zip[E[i][k].to][j+l-E[i][k].cost],E[i][k].cost+l});
                            }
                        }
                    }
                }else{
                    rep(k,E[i].size()){
                        if(E[i][k].cost <= j){
                            G[zip[i][j]].pb((edge){zip[E[i][k].to][j-E[i][k].cost],E[i][k].cost});
                        }
                    }
                }
            }
        }
        rep(i,cnt){
            d[i] = INF;
        }
        dijkstra(zip[a][m]);
        int mn = INF;
        rep(i,m+1){
            mn = min(mn,d[zip[h][i]]);
        }
        if(mn >= INF){
            cout << "Help!\n";
        }else{
            cout << mn << "\n";
        }

    }
}

Measured memory_bytes: 56756