akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>

int h, w, c;
long long dp[105][10];
constexpr long long mod = 1000000007;
int main()
{
	std::cin >> h >> w >> c;

	dp[0][0] = 1;
	for (int i = 0; i < h; ++i)
		for (int j = 0, end = 1 << (w - 1); j < end; ++j) {
			bool check = false;
			for (int k = 0; k < w - 1; ++k)
				if (((j >> k) & 1) == 1 && ((j >> (k + 1)) & 1) == 1) {
					check = true;
					break;
				}
			if (check)
				continue;

			int next[10];
			for (int k = 0; k < w; ++k)
				next[k] = k;
			for (int k = 0; k < w - 1; ++k)
				if (((j >> k) & 1) == 1)
					std::swap(next[k], next[k + 1]);
			for (int k = 0; k < w; ++k)
				dp[i + 1][next[k]] = (dp[i + 1][next[k]] + dp[i][k]) % mod;
		}

	std::cout << dp[h][c - 1] << std::endl;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m,x,c[15],a[15][15];
	cin >> n >> m >> x;
	int ans = INF;
	for(int i = 0;i < n;i++){
		cin >> c[i];
		for(int j = 0;j < m;j++) cin >> a[i][j];
	}
	for(int i = 0;i < (1 << n);i++){
		int sum[15] = {},csum = 0;
		for(int j = 0;j < n;j++){
			if(!(i >> j & 1)) continue;
			csum += c[j];
			for(int k = 0;k < m;k++) sum[k] += a[j][k];
		}
		bool isOK = true;
		for(int i = 0;i < m;i++){
			if(sum[i] < x) isOK = false;
		}
		if(isOK) chmin(ans,csum);
	}
	cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  REP(i, n)
  {
    REP(j, d)
        cin >> x[i][j];
  }

  int ans = 0;
  REP(i, n)
  {
    FOR(j, i + 1, n)
    {
      int norm = 0;
      REP(k, d)
      {
        int diff = abs(x[i][k] - x[j][k]);
        norm += diff * diff;
      }
      bool flag = false;
      REP(k, norm + 1)
      {
        if (k * k == norm)
          flag = true;
      }
      if (flag)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  ll h;
  cin >> h;
  int m=0;
  while(h>1){
    h/=2;
    m++;
  }
  ll k = pow(2,m+1);
  cout << k-1 << endl;
 
  return 0;

}



Measured memory_bytes: 4028
#include<iostream>
using namespace std;
typedef long long ll;

int r,g,b,N;
ll ans;

int main() { 
	cin >> r>>g>>b>>N;

	ans = 0;
	for (int i = 0; i*r <= N; i++) {
		for (int j = 0; j*g <= N - i * r; j++) {
			if ((N - (i*r + j * g)) % b == 0) {
				ans++;
			}
		}
	}


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

Measured memory_bytes: 256
n = int(input())
c = list(input())
w, r = [0] * (n + 1), [0] * (n + 1)
for i in range(n):
    if c[i] == "W":
        w[i + 1] = w[i] + 1
        r[i + 1] = r[i]
    else:
        w[i + 1] = w[i]
        r[i + 1] = r[i] + 1
ans = min(w[n], r[n])
for i in range(1, n):
    x = w[i] - w[0]
    y = r[n] - r[i]
    ans = min(ans, x + abs(x - y))
print(ans)

Measured memory_bytes: 20112
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto M = readln.split.sort().uniq.count;
    if (M % 2 == 0) M--;
    writeln(M);
}


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

using namespace std;
int freq[100005];
int main()
{
    int n;
    scanf("%d",&n);
    int ans =0,num;
    for(int i=0;i<n;i++){
        scanf("%d",&num);
        freq[num]++;
        if(freq[num]==1)ans++;
    }
    if(ans%2==0){
        printf("%d",ans-1);
    }else{
        printf("%d",ans);
    }
    return 0;
}


Measured memory_bytes: 640
/*
 * AOJ 2249: Road Construction
 * ?????????????????\??????????????????????????????????????±?´?????????????0?????°??¶?????????????????????????????????????????\??????????±??????????????????±?´?????°???????
 * ?±????????????????
 * ???????????????????????????????????????????????§??????????????§???????????\???????????\???????????°??´?°???????????????????????????????????????±?´???´?°????
 */

#include <cstdio>
#include <queue>
#include <iostream>
#include <cstring>

using namespace std;

typedef pair<int ,int> pii;

priority_queue<pii, vector<pii>, greater<pii> > pq;

int d[10010];

struct E{
  E() {}
  E(int vv, int cc, int ww): v(vv), c(cc), w(ww) {}
  int v, c, w;
};

vector<E> e[10010];
int pre[10010];

void Dijkstra(int n, int s, int d[], vector<E> e[]) {
  memset(d + 1, 0x3f, sizeof(int) * n);
  pq.push(make_pair(d[s]=0, s));
  while(!pq.empty()) {
    int u, v, c, m;
    m = pq.top().first;
    u = pq.top().second;
    pq.pop();
    if(m > d[u]) {
      continue;
    }
    for(vector<E>::iterator it = e[u].begin(); it != e[u].end(); ++it){
      const E &edge = *it;
      v = edge.v;
      c = edge.c;
      int t = d[u] + c;
      if(t < d[v]) {
        pq.push(make_pair(d[v]=t, v));
        pre[v] = edge.w;
      } else if(t == d[v]) {
        pre[v] = min(pre[v], edge.w);
      }
    }
  }
}

int main() {
  int n, m, u, v, c, w;

  while(scanf("%d%d", &n, &m) != EOF && n) {
    for(u = 1; u <= n; ++u) {
      e[u].clear();
    }
    while (m--) {
      scanf("%d%d%d%d", &u, &v, &c, &w);
      e[u].push_back(E(v, c, w));
      e[v].push_back(E(u, c, w));
    }
    Dijkstra(n, 1, d, e);

    int ans = 0;
    for (u = 2; u <= n; ++u) {
      ans += pre[u];
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

// template<class T> void chmin(T& a, T b) {
//     if (a > b) {
//         a = b;
//     }
// }

// template<class T> void chmax(T& a, T b) {
//     if (a < b) {
//         a = b;
//     }
// }

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

    string s;
    cin >> s;

    ll r=0, g=0, b=0;
    for(ll in=0;in<n;in++) {
        if(s.at(in)=='R') r++;
        if(s.at(in)=='G') g++;
        if(s.at(in)=='B') b++;
    }

    ll ans=r*g*b;
    for(ll in=0;in<n;in++) {
        for(ll jn=in+1;jn<n;jn++) {
            ll k = 2*jn-in;
            if(k>=n) continue;
            if(s.at(in)!=s.at(jn)&&s.at(jn)!=s.at(k)&&s.at(k)!=s.at(in)) ans--;
        }
    }

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


Measured memory_bytes: 3640
using System;
using System.Linq;

namespace AGC026.Task01
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = Console.ReadLine();
            var line = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var count = 0;
            var prev = 0;
            for (var i = 0; i < line.Length; i++)
            {
                if (line[i] == prev)
                {
                    count++;
                    prev = 0;
                }
                else
                {
                    prev = line[i];
                }
                
            }
            Console.WriteLine(count);
        }
    }
}


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

using System.Collections;

class Program
{
    static void Main()
    {
        int[] nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int N = nk[0];
        int K = nk[1];

        string S = Console.ReadLine();

        var ans = S.Substring(0, K - 1) + S.Substring(K - 1, 1).ToLower() + S.Substring(K, N - K);

        Console.WriteLine(ans);
    }


}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
int a[111111];

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	n=read();
	ll ans=0;
	FOR(i,0,n){
		int x=read(),y=read();
		ans+=x;
		a[i]=x+y; 
	}
	sort(a,a+n);
	FOR(i,0,n){
		if(i%2)ans-=a[n-i-1];
	}
	Tone(ans)
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

//----------------------------------------------------------------------
void solve() {

	string s;
	cin >> s;
	rep(i,s.size()) cout << 'x';

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

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 deg[100005];
vector<int> to[100005];

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a --;
    b --;
    deg[a]++;
    deg[b]++;
    uf.unite(a,b);
  }
  rep(i,k){
    int a,b;
    cin >> a >> b;
    a --;
    b --;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n){
    int ans = uf.size(i) - 1 -deg[i];
    for(int u : to[i]){
      if (uf.same(i,u)) --ans;
    }
    cout << ans;
    if(i == n-1) cout << endl;
    else cout << " ";
  }
}

Measured memory_bytes: 6784
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
    int i;
    for ( i = 1; i <= n; i++ ){
        if ( i > 1 ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}


int main(){
    int n, i, j, key;
    int A[N+1];
    scanf("%d", &n);

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

    trace(A, n);
    for ( i = 2; i <= n; i++ ) {
        j = i - 1;
        key = A[i];
        while( j >= 1 && A[j] > key ){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        trace(A, n);
    }

    return 0;
}

Measured memory_bytes: 1036
#include <cstdio>
#include <queue>
using namespace std;

typedef long long ll;

constexpr int LMAX = 21;
constexpr ll INF = 1'000'000'000'000'000'007;

bool chmin(ll &a, ll b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int length(char *s) {
	int ans = 0;
	for (; s[++ans];)
		;
	return ans;
}

struct tq {
	ll d;
	int n;
	int i;
	bool rev;
	tq(ll ind, int inn, int ini, bool inrev) {
		d = ind;
		n = inn;
		i = ini;
		rev = inrev;
	}
};

struct grtD {
	bool operator()(const tq &a, const tq &b) { return a.d > b.d; }
};

int main() {
	int N;
	scanf("%d", &N);
	char S[N][LMAX];
	int C[N];
	for (int i = 0; i < N; i++) scanf("%s %d", S[i], C + i);
	int L[N];
	for (int i = 0; i < N; i++) L[i] = length(S[i]);

	// dijkstra
	ll dist[N][LMAX][2];
	fill(dist[0][0], dist[N][0], INF);
	priority_queue<tq, vector<tq>, grtD> pq;
	for (int i = 0; i < N; i++) {
		pq.push(tq(C[i], i, 0, false));
		dist[i][0][false] = C[i];
	}
	for (; !pq.empty();) {
		tq tmp = pq.top();
		pq.pop();
		if (tmp.d > dist[tmp.n][tmp.i][tmp.rev]) continue;
		// fprintf(stderr, " %lld %d %d %d\n", tmp.d, tmp.n, tmp.i, tmp.rev);
		if (tmp.rev) {
			bool f = true;
			for (int j = 0; f && j < tmp.i - j - 1; j++) {
				if (S[tmp.n][j] != S[tmp.n][tmp.i - j - 1]) f = false;
			}
			if (f) {
				printf("%lld\n", tmp.d);
				return 0;
			}
			for (int n = 0; n < N; n++) {
				f = true;
				for (int j = 0; f && j < L[n] && j < tmp.i; j++) {
					if (S[n][j] != S[tmp.n][tmp.i - j - 1]) f = false;
				}
				if (!f) continue;
				if (L[n] > tmp.i) {
					int i = tmp.i;
					if (chmin(dist[n][i][false], tmp.d + C[n])) {
						pq.push(tq(dist[n][i][false], n, i, false));
					}
				} else {
					int i = tmp.i - L[n];
					if (chmin(dist[tmp.n][i][true], tmp.d + C[n])) {
						pq.push(tq(dist[tmp.n][i][true], tmp.n, i, true));
					}
				}
			}
		} else {
			bool f = true;
			for (int j = 0; f && j + tmp.i < L[tmp.n] - j - 1; j++) {
				if (S[tmp.n][tmp.i + j] != S[tmp.n][L[tmp.n] - j - 1]) f = false;
			}
			if (f) {
				printf("%lld\n", tmp.d);
				return 0;
			}
			for (int n = 0; n < N; n++) {
				f = true;
				for (int j = 0; f && j + tmp.i < L[tmp.n] && j < L[n]; j++) {
					if (S[n][L[n] - j - 1] != S[tmp.n][tmp.i + j]) f = false;
				}
				if (!f) continue;
				if (L[n] > L[tmp.n] - tmp.i) {
					int i = L[n] + tmp.i - L[tmp.n];
					if (chmin(dist[n][i][true], tmp.d + C[n])) {
						pq.push(tq(dist[n][i][true], n, i, true));
					}
				} else {
					int i = tmp.i + L[n];
					if (chmin(dist[tmp.n][i][false], tmp.d + C[n])) {
						pq.push(tq(dist[tmp.n][i][false], tmp.n, i, false));
					}
				}
			}
		}
	}
	printf("-1\n");
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,k;cin>>k>>n;
    vi v(n*2);
    rep(i,n)cin>>v[i];
    rep(i,n)v[i+n]=v[i]+k;
    ll ans=inf;
    rep(i,n)chmin(ans,v[i+n-1]-v[i]);
    out(ans);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll k;
  cin>>k;
  ll sum=0;
  for(int i=0;i<10000000;i++){
    sum=sum*10+7;
    sum%=k;
    if(sum==0){
      cout<<i+1<<endl;
      break;
    }
    if(i==(1000000-1))cout<<-1<<endl;
  }
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main(){
	bool b=1;
	string s;
	cin>>s;
	for(int i=0;s[i];i++){
		if(i%2&&s[i]=='R'||i%2==0&&s[i]=='L'){
			b=0;
			break;
		}
	}
	if(b)cout<<"Yes\n";
	else cout<<"No\n";
}

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

#define ll long long 
#define pb push_back
#define pu push
#define ins insert
#define f(s,e) for(i=s;i<e;i++)
#define loop(i) while(i--)
#define bg(v) v.begin()
#define ed(v) v.end()
#define sz(v) v.size()
#define len(v) v.length()
#define con continue;
#define brk break;
#define sn cout<<"\n";
#define in(n) cin>>n;
#define out(n) cout<<n;





int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll t,op,i,j,k,m,h;
    
    cin>>t>>i>>j;
    k=0;
    while(i<=j)
    {
        if(i%t==0){
            k=1;break;
        }
        i++;
    }
    if(k)cout<<"OK";
    else cout<<"NG";
	return 0; 
} 

Measured memory_bytes: 3608
#include<cstdio>

int date[2][4];


int main()
{
	while(scanf("%d%d%d%d%d%d%d%d",&date[0][0],&date[0][1],&date[0][2],&date[0][3],&date[1][0],&date[1][1],&date[1][2],&date[1][3])!=EOF)
	{
		int hit=0;
		int blow=0;
		for(int i=0;i<4;i++)
		{
			if(date[0][i]==date[1][i])hit++;
		}
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<4;j++)
			{
				if(date[0][i]==date[1][j])blow++;
			}
		}
		blow-=hit;
		printf("%d %d\n",hit,blow);
	}
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cd=0,mx=0,loop;
  vector<int> r(26,0);
  vector<int> l(26,0);
  for(loop=0;loop<N;loop++){
    l[S[loop]-97]++;
  }
  for(loop=0;loop<N;loop++){
    r[S[loop]-97]++;
    l[S[loop]-97]--;
    if(r[S[loop]-97]==1&&l[S[loop]-97]>0){
      cd++;
      if(cd>mx)
        mx=cd;
    }else if(r[S[loop]-97]>1&&l[S[loop]-97]==0){
      cd--;
    }
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
N, M = map(int, input().split())
graph = [[0]*N for _ in range(N)]
visited = [0]*N
ab = []
ans = 0

def dfs(u):
  visited[u] = 1
  for v in range(N):
    if graph[u][v] == 1 and visited[v] == 0:
      dfs(v)

for _ in range(M):
  a, b = map(lambda x:int(x)-1, input().split())
  graph[a][b] = 1
  graph[b][a] = 1
  ab += [[a, b]]

for _ in range(M):
  a, b = ab.pop(0)
  graph[a][b] = 0
  graph[b][a] = 0

  for i in range(N):
    visited[i] = 0
  
  dfs(0)
  
  if sum(visited) != N:
    ans += 1

  graph[a][b] = 1
  graph[b][a] = 1

print(ans)

Measured memory_bytes: 9264
n = int(input())
a = sorted(list(map(int, input().split())))
m = a[-1]
tmp = abs(a[0]-m/2)
ans = a[0]
for i in range(n):
    if tmp>abs(a[i]-m/2):
        tmp = abs(a[i]-m/2)
        ans = a[i]
print(m, ans)
        

Measured memory_bytes: 14052
#include <iostream>
using namespace std;
int main(void) {
	int a, b, c;

	cin >> a >> b >> c;

	if ((a == b) && (b == c) && (a == c)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
mod = 10**9+7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
 
    N = 10**6
    g1 = [1, 1] 
    g2 = [1, 1] 
    inverse = [0, 1] 

    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    return g1[n] * g2[r] * g2[n-r] % mod

if (x+y)%3 != 0:
    print(0)
else:
    n = (x+y)//3
    r = 2*n - x
    print(cmb(n, r, mod))

Measured memory_bytes: 122032
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {

        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();

        int max = b / k;

        if (k * max >= a) {
            System.out.println("OK");
          	return;
        }

        System.out.println("NG");
    }
}


Measured memory_bytes: 35816
import java.util.*;
public class Main {
    public static void main(String args[]) {
       Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[]  = new int[num];
        for (int i = 0; i < num; i++) {
            x[i]  = sc.nextInt();
        }
        for (int i = num-1; i >= 0; i--) {
            if(i==0){
                System.out.println(x[i]);
            }else {
                System.out.print(x[i] + " ");
            }
        }
    }
}


Measured memory_bytes: 26212
#include <cstdio>
#include <iostream>
#include <queue>
static const int N = 110;

using namespace std;

int main(){
    int M[N][N];
    int n;
    scanf("%d",&n); 
    for(int i =1; i<= n;i++) {
        for (int j=1; j<=n;j++) M[i][j] = 0;
    }

    for(int i=0; i<n;i++){
        int u,k;
        scanf("%d",&u);
        scanf("%d",&k);

        for(int j=0; j<k; j++){
            int l;
            scanf("%d",&l);
            M[u][l] = 1;
        }
    }

    for(int i=1; i<= n; i++){
        for(int j=1; j<= n; j++){
            if(j-1) cout << " ";
            cout << M[i][j] ;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

int gcd(int a, int b){
    while( b ){
        int m = a % b;
        a = b;
        b = m;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //xのn乗を計算するのにn乗を2進表記にして計算
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//答えに付加
        }
        x=(x*x)%mod;//2乗
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int z;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.x < riRight.x;
        
    }
};

struct XX{
    int zenbu=0;
    int kidoku=0;
};

class xxIntu {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        //第1条件
        if(riLeft.z != riRight.z){
            return riLeft.z > riRight.z;//<:昇順(小さい順)、>:降順(大きい順)
        }
        //第2条件
        return riLeft.y < riRight.y;
    }
};
bool operator< (const VV &riLeft, const VV &riRight){
    return riLeft.z < riRight.z;
};
/*bool operator> (const XX &riLeft, const XX &riRight){
    return riLeft.a > riRight.a;
};*/



int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //ここから
    
    string s;
    cin >> s;

    string ans="";
    
    for(int i=0;i<s.size();i++){
        if(s.substr(i,1)=="0"){
            ans=ans+"0";
        }else if(s.substr(i,1)=="1"){
            ans=ans+"1";
        }else{
            if(ans.size()!=0){
                ans=ans.substr(0,ans.size()-1);
            }
        }
    }

    cout << ans << endl;
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 256
/************
< 주소 >      :
*************
< 해결방안 >   :


*************
< 오답노트 >   :

*************/

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

#ifdef LOCAL_BOOKNU
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ........................macro.......................... //
#define FOR(i, f, n) for(int (i) = (f); (i) < (int)(n); ++(i))
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (int)(n); --(i))
#define pb push_back
#define emb emplace_back
#define fi first
#define se second
#define ENDL '\n'
#define sz(A) (int)(A).size()
#define ALL(A) A.begin(), A.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define next next9876
#define prev prev1234
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef long long i64;
typedef unsigned long long ui64;
// inline i64 GCD(i64 a, i64 b) { if(b == 0) return a; return GCD(b, a % b); }
inline int getidx(const vi& ar, int x) { return lower_bound(ALL(ar), x) - ar.begin(); } // 좌표 압축에 사용: 정렬된 ar에서 x의 idx를 찾음
inline i64 GCD(i64 a, i64 b) { i64 n; if(a < b) swap(a, b); while(b != 0) { n = a % b; a = b; b = n; } return a; }
inline i64 LCM(i64 a, i64 b) { if(a == 0 || b == 0) return GCD(a, b); return a / GCD(a, b) * b; }
inline i64 CEIL(i64 n, i64 d) { return n / d + (i64)(n % d != 0); } // 음수일 때 이상하게 작동할 수 있음.
inline i64 ROUND(i64 n, i64 d) { return n / d + (i64)((n % d) * 2 >= d); }
inline i64 POW(i64 a, i64 n) {
	assert(0 <= n);
	i64 ret;
	for(ret = 1; n; a = a*a, n /= 2) { if(n%2) ret *= a; }
	return ret;
}
template <class T> ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class T> ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fi << "," << p.se << ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H, debug_out(T...); }
// ....................................................... //

const int MAXN = 10;
int n, ar[MAXN];
void input() {
	cin >> n;
	FOR(i, 0, n) cin >> ar[i];
}

int solve() {
	FOR(i, 0, n) {
		int sum = 0;
		FOR(j, 0, n) {
			if(i != j) sum += ar[j];
		}
		if(sum <= ar[i]) {
			cout << "No" << ENDL;
			return 0;
		}
	}
	cout << "Yes" << ENDL;
	return 0;
}

// ................. main .................. //
void execute() {
	input(), solve();
}

int main(void) {
#ifdef LOCAL_BOOKNU
	freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	cin.tie(0), ios_base::sync_with_stdio(false);
	execute();
	return 0;
}
// ......................................... //

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, k;
vi v;

void read() {
  cin >> n >> k;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.pb(x);
  }
}

int Abs(int x) {
  return x > 0 ? x : -x;
}

void solve() {
  ll sol = LONG_LONG_MAX;
  for(int i = 0; i <= n - k; ++i) {
    ll l = Abs(v[i]) + Abs(v[i + k - 1] - v[i]);
    ll r = Abs(v[i + k - 1]) + Abs(v[i] - v[i + k - 1]);
    sol = min({sol, l, r});
  }
  cout << sol;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		Arrays.parallelSort(a);

		int mod = 1000000007;
		long[] p = new long[100001];
		long[] pi = new long[100001];
		p[0] = 1;
		pi[0] = 1;
		for (int i = 1; i < p.length; i++) {
			p[i] = p[i - 1] * i % mod;
			pi[i] = modinv(p[i], mod);
		}

		long sum1 = 0;
		long sum2 = 0;
		for (int i = 0; i < n; i++) {
			if (n - 1 - i >= k - 1) {
				long val = nCr(n - 1 - i, k - 1, mod, p, pi);
				sum1 += val * a[i];
				sum1 %= mod;
			}
			if (i >= k - 1) {
				long val = nCr(i, k - 1, mod, p, pi);
				sum2 += val * a[i];
				sum2 %= mod;
			}
		}
		if (sum1 >= mod || sum2 >= mod) {
			throw new Exception();
		}
		long ans = sum2 - sum1;
		if (ans < 0) {
			ans += mod;
		}
		ans %= mod;
		System.out.println(ans);
	}

	static long nCr(int n, int r, int m, long[] p, long[] pi) {
		return p[n] * pi[r] % m * pi[n - r] % m;
	}

	static long modinv(long a, long m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


Measured memory_bytes: 47884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,k;cin>>n>>k;
    n++;
    ll ans=0;
    vector<ll> v(n+1,0);
    for(ll i=1;i<=n;i++)v[i]=(v[i-1]+i)%mod;
    //for(ll i:v)cout<<i<<endl;
    for(int i=k;i<=n;i++){
        ll a=v[i],b=v[n]-v[n-i];
        ans+=(b-a+1);
        ans%=mod;
    }
    if(ans<0)ans+=mod;
    cout<<ans;
    
}

Measured memory_bytes: 4764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

string x;

int main(){

	cin >> x;
	REP(i,3){
		if(x[i] == x[i+1]){
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
}

Measured memory_bytes: 256
N =int(input())
W=list(map(int,input().split()))

sum=0
for i in range(0,N):
    sum=sum+W[i]

S=[0,sum]
m=sum

for i in range(0,N):
    S[0]=S[0]+W[i]
    S[1]=S[1]-W[i]
    x=abs(S[0]-S[1])
    if x<m:
        m=x

print(m)

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

using namespace std;

string LCS(const string &A, const string &B)
{
	string res = "";
	if(A.empty() || B.empty())
		return res;
	vector<vector<int>> DP(A.size() + 1, vector<int>(B.size() + 1, 0));
	for (int i = 1; i <= (int) A.size(); i++) {
		for (int j = 1; j <= (int) B.size(); j++) {
			if (A[i-1] == B[j-1])
				DP[i][j] = DP[i-1][j-1] + 1;
			else
				DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
		}
	}
	
	int i = A.size();
	int j = B.size();
	while(i > 0 && j > 0) {
		if(A[i-1] == B[j-1]) {
			res += A[i-1];
			i--;
			j--;
		}
		else if(DP[i][j] == DP[i][j-1])
			j--;
		else
			i--;
	}
	return string(res.rbegin(),res.rend());
}

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	cout << LCS(s1, s2) << endl;
	return 0;
}

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

int gcd(long long a,long long b){
    if(b == 0) return a;
    return gcd( b , a % b);
}

int find(string str, const string& word) {
  int count = 0;
  for (string::size_type pos = 0; (pos = str.find(word, pos)) != string::npos; pos += word.size()) {
    ++count;
  }
  return count;
}

int main(){
    string s;
    char * ans;
    cin >> s;
    int num;
    num = atoi(s.c_str());
    if((num/ 100) > 12){
        if((num%100) > 12 || (num%100) == 0){
            ans = "NA";
        }
        else{
            ans = "YYMM";
        }
    }
    else{
        if((num%100) > 12){
            if(num/100 == 0){
                ans = "NA";
            }
            else{
                ans = "MMYY";
            }
        }
        else{
            if(num/100 == 0 && num % 100 == 0){
                ans = "NA";
            }
            else if(num / 100 == 0){
                ans = "YYMM";
            }
            else if(num %100 == 0){
                ans = "MMYY";
            }
            else{
                ans = "AMBIGUOUS";
            }
        }
    }
    cout << ans << endl;

}

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

int main(){
  int N;cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int m=1000000;
  int ans=0;
  for(int i=0;i<N;i++){
    m=min(m,A[i]);
    if(m==A[i]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int h[N];
long long f[N];

int main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> h[i];
	for(int i = 0; i < n; i++) f[i] = 10000000000;
	f[0] = 0;
	f[1] = abs(h[0] - h[1]);
	for(int i = 2; i < n; i++){
      	for(int j = max(0,i-k); j < i; j++) {
        	f[i] = min(f[i], f[j]+abs(h[j]-h[i]));
        }
    }
	cout << f[n-1];
}

Measured memory_bytes: 4764
X = gets.to_i
K = gets.to_i
rs = [0] + gets.split.map(&:to_i) + [10**10]

sat_ub = [X]
sat_lb = [0]
val_lb = [0]
(1..K).each do |k|
    rd = rs[k] - rs[k-1]
    if k % 2 == 1   # パーツA減少
        if val_lb[k-1] - rd < 0
            val_lb[k] = 0
            sat_lb[k] = sat_lb[k-1] + (rd - val_lb[k-1])
        else
            val_lb[k] = val_lb[k-1] - rd
            sat_lb[k] = sat_lb[k-1]
        end
        sat_ub[k] = sat_ub[k-1]
        sat_lb[k] = sat_ub[k] if sat_lb[k] > sat_ub[k]
    else
        val_ub = val_lb[k-1] + sat_ub[k-1] - sat_lb[k-1]
        if val_ub + rd > X
            sat_ub[k] = sat_ub[k-1] - (val_ub + rd - X)
        else
            sat_ub[k] = sat_ub[k-1]
        end
        val_lb[k] = val_lb[k-1] + rd
        val_lb[k] = X if val_lb[k] > X
        sat_lb[k] = sat_lb[k-1]
        sat_ub[k] = sat_lb[k] if sat_ub[k] < sat_lb[k]
    end
end

Q = gets.to_i
ARRAY = (K+1).times.to_a
Q.times do
    t, a = gets.split.map(&:to_i)
    i = ARRAY.bsearch{|k| rs[k+1] > t}
    if a <= sat_lb[i]
        start = val_lb[i]
    elsif a <= sat_ub[i]
        start = val_lb[i] + a - sat_lb[i]
    else
        start = val_lb[i] + sat_ub[i] - sat_lb[i]
    end
    if i % 2 == 0 # パーツA減少
        result = start - (t - rs[i])
        result = 0 if result < 0
    else
        result = start + (t - rs[i])
        result = X if result > X
    end
    puts result
end

Measured memory_bytes: 16828
#include<iostream>

int main(){
 int a, b, c, f = 0;
 std::cin >> a >> b >> c;
 
 for(int x = a; x <= b; x++ ){
  if(c % x == 0) f++;
  }
 
 std::cout<< f <<"\n";

 return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    string str;
    cin >> str;
    bool ans = true;
    for(int i=0;i<str.length();i++){
        if(str.compare(i,1,str,str.length()-1-i,1)!=0){
            ans = false;
        }
    }
    for(int i=0;i<(str.length()-3)/2;i++){
        if(str.compare(i,1,str,(str.length()-3)/2-i,1)!=0){
            ans = false;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $count);  
  $array = explode(' ', fgets(STDIN));
 
  $nums = array();
  for($i=0 ; $i < $count; $i++){
    $value = (int)$array[$i];
    $nums[] = $value;
    $nums[] = $value - 1;
    $nums[] = $value + 1;
  }
 
$tmpArray = array_count_values($nums);
 
echo max($tmpArray);

Measured memory_bytes: 31216
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
ll n, m;
vector<int> a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<"\n";
}


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

int main(void){
  int N, sum = 0; cin>>N;
  vector<int> v;
  v.resize(N);
  for(int i = 0;i < N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  int a = v[N-1] / 2;
  for(int t = 0;t < N-1;t++)sum += v[t];
  cout<<sum + a;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int N = Integer.parseInt(s[0]);
    int K = Integer.parseInt(s[1]);
    
    String[] t = sc.nextLine().split(" ");
    int[] cost = new int[N];
    for(int i = 0; i < N; i++){
      cost[i] = Integer.parseInt(t[i]);
    }
    
    int[] result = new int[N];
    Arrays.fill(result, Integer.MAX_VALUE);
    result[0] = 0;
    
    for(int i = 0; i < N; i++){
      for(int j = i; j <= i + K && j < N; j++){
        if(j == 0){
          continue;
        }
        
        int a = Math.abs(cost[i] - cost[j]) + result[i];
        if(result[j] > a){  
 		  result[j] = a;
        }
      }
    }
    System.out.println(result[N-1]);
  }
}

Measured memory_bytes: 46212
#
# agc013 a
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6
1 2 3 2 2 1"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """9
1 2 1 2 1 2 1 2 1"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """7
1 2 3 2 1 999999999 1000000000"""
        output = """3"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 1
    flag = 0
    for i in range(1, N):
        if flag == 0:
            if A[i-1] < A[i]:
                flag = 1
            elif A[i-1] > A[i]:
                flag = -1
        elif flag == 1:
            if A[i-1] > A[i]:
                ans += 1
                flag = 0
        else:
            if A[i-1] < A[i]:
                ans += 1
                flag = 0
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 27260
#include<cstdio>
using namespace std;

int main(){
	int N;
	scanf("%d",&N);
	if(N<105)printf("0\n");
	else if(N<135)printf("1\n");
	else if(N<165)printf("2\n");
	else if(N<189)printf("3\n");
	else if(N<195)printf("4\n");
	else printf("5\n");
	return 0;
}
		

Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

#solve
def solve():
    n = II()
    a = LI()
    x = 1
    if 1 in a:
        x = 0
    a = [i for i in a if i != 1]
    M = 10 ** 6 + 1
    p = [True] * M
    p[0] = False
    p[1] = False
    d = [-1] * M
    for xi in range(2, M):
        if p[xi]:
            d[xi] = xi
            for i in range(xi * 2, M, xi):
                p[i] = False
                if d[i] == -1:
                    d[i] = xi
    res = defaultdict(int)
    flg = 0
    for ai in a:
        tmp = []
        if d[ai] == -1:
            res[ai] = 1
            tmp = [ai]
        else:
            while d[ai] != -1:
                tmp.append(d[ai])
                ai = ai // d[ai]
        for t in set(tmp):
            if res[t]:
                flg = 1
            res[t] = 1
        if flg:
            break
    else:
        print("pairwise coprime")
        return
    g = a[0]
    for i in a:
        g = math.gcd(g, i)
    if g == 1 or x == 0:
        print("setwise coprime")
        return
    print("not coprime")
    
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 220580
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n;
    cin >> n;
    int now = 0;
    int now_x = 0;
    int now_y = 0;
    int out = 0;
    rep(i,0,n){
        int t,x,y;
        cin >> t>>x>>y;
        int time = t-now;
        int distance = abs(now_x-x)+abs(now_y-y);
        if(time>=distance&&time%2==distance%2){
            now = t;
            now_x = x;
            now_y = y;
            continue;
        }else{
            out = 1;
            break;
        }
        now = t;
        now_x = x;
        now_y = y;


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

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

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

    vector<int> bw(s.size());
    rep(i, 0, s.size()) bw[i] = int(s[i] == 'B');


    int cnt = 1;
    int status = bw[0];
    rep(i, 0, bw.size())
    {
        if (status == bw[i]) continue;
        else
        {
            status = not status;
            cnt++;
        }
    }
    cout << cnt - 1 << endl;
    return 0;
}

Measured memory_bytes: 896