akhauriyash/Code-Regression huggingface dataset:
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba-064a5016a 

#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod ((int)(1e9 + 7))
signed main()
{
	fast_io
	int n, k;
	cin >> n >> k;	
	int dp[k + 1] = {0};
	int a[n + 1];
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= k; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(i - a[j] >= 0)
			{
				if(dp[i - a[j]] == 0)
				{
					dp[i] = 1;
					break;
				}
			}
			else
				break;
		}
	}	
	if(dp[k] == 1)
		cout << "First\n";
	else
		cout << "Second\n";
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int mod = 1000000007;
        long result = 1;
        for (int i = 2; i <= N; i++) {
            result *= i;
            if (result > mod) {
                result %= mod;
            }
        }
        for (int i = 2; i <= M; i++) {
            result *= i;
            if (result > mod) {
                result %= mod;
            }
        }
        if (N == M) {
            System.out.println((result * 2) % mod);
        } else if (Math.abs(N - M) == 1) {
            System.out.println(result);
        } else {
            System.out.println(0);
        }

    }
}


Measured memory_bytes: 23764
import sys
N,M = map(int,input().split())
s = [0]*M
c = [0]*M
ans = [0]*N
intans = 0
for i in range(M):
    s[i],c[i] = map(int,input().split())
if N != 1:
    if M == 0:
        print(pow(10,N-1))
        sys.exit()
    else:
        for i in range(M):
            if s[i] == 1 and c[i] == 0:
                print(-1)
                sys.exit()
else:
    if M !=0:
        for i in range(M):
            for j in range(i+1,M):
                if s[i] == s[j] and c[i] !=c[j]:
                    print(-1)
                    sys.exit()
        for i in range(M):
            ans[s[i]-1] = c[i]
        print(ans[0])
        sys.exit()
    else:
        print(0)
        sys.exit()
if M !=0:
    for i in range(M):
        for j in range(i+1,M):
            if s[i] == s[j] and c[i] != c[j]:
                print(-1)
                sys.exit()
    for i in range(M):
        ans[s[i]-1] = c[i]
    if ans[0] != 0:
        for i in range(N):
            intans = intans + ans[i] * pow(10,N-i-1)
    else:
        ans[0] =1
        for i in range(N):
            intans = intans + ans[i] * pow(10,N-i-1)
print(intans)


Measured memory_bytes: 38476
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int res;
string S;
stack<char>st;
int main() {
	cin >> S;
	for (int i = 0; i != S.size(); ++i) {
		if (!st.empty() && st.top() != S[i]) {
			res += 2;
			st.pop();
		}
		else {
			st.push(S[i]);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#define LL long long
#define inf 0x3f3f3f3f
#define lson rt<<1
#define rson rt<<1|1
#define PII pair<int,int>
#define test freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
using namespace std;
const int maxn=2e5+5;
int main()
{
    string s;
    cin>>s;
    if(s=="SUN") cout<<7;
    else if(s=="SAT") cout<<1;
    else if(s=="FRI") cout<<2;
    else if(s=="THU") cout<<3;
    else if(s=="WED") cout<<4;
    else if(s=="TUE") cout<<5;
    else cout<<6;
    return 0;
}


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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) { cin >> s[i]; }
    sort(s.begin(), s.end());
    rep(i, n) { cout << s[i]; }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

// f(2, 3) := BABAB
// f(6, 4) := AABAABAABB
// f(2, 4) := ABBABB
// f(3, 5) := ABBABBAB

// g(A, B) := length item 3;
int g(int a, int b) {
    if (a < b) swap(a, b);
    return (a+b) / (b+1);
}

int A, B, C, D;

void MAIN() {
    scanf("%d%d%d%d", &A, &B, &C, &D);
    C--;

    int z = g(A, B);
    // a(z), a(z), ..., a(A%z);
    // b(B%z), b(z), b(z), ...;
    
    LL lo = 0, hi = min(A/z, B)+1;
    while (hi - lo > 1) {
	LL mid = (lo + hi) / 2;
	LL ta = A-mid*z;
	LL tb = B-mid;
	bool ok;
	if (ta == 0) ok = false;
	else ok = (g(ta - 1, tb) <= z);
	(ok? lo: hi) = mid;
    }

    LL L = lo;
    // a(z)b * L;

    LL R = min(A-z*L, (B-L)/z);

    LL MA = A - z*L - R;
    LL MB = B - L - z*R;

    int len = D - C;
    string ans;

    vector<pair<int, char> > v;
    int left;
    if (C < (z+1)*L) {
	left = C / (z+1) * (z+1);
	int pos = left;
	while (pos < D && pos + z+1 <= (z+1)*L) {
	    v.emplace_back(z, 'A');
	    v.emplace_back(1, 'B');
	    pos += z+1;
	}
    } else {
	left = (z+1) * L;
    }

    if (C < (z+1)*L + MA && (z+1)*L < D) {
	v.emplace_back(MA, 'A');
    } else if ((z+1)*L+MA <= C) {
	left = (z+1)*L + MA;
    }

    if (C < (z+1)*L + MA + MB && (z+1)*L + MA < D) {
	v.emplace_back(MB, 'B');
    } else if ((z+1)*L+MA+MB <= C) {
	left = (z+1)*L + MA + MB;
    }
    
    int right = (z+1)*L+MA+MB;
    if (right <= C) {
	left = (C-right)/(z+1)*(z+1)+right;
	right = left;
    }
    while (right < D) {
	v.emplace_back(1, 'A');
	v.emplace_back(z, 'B');
	right += z+1;
    }

    EACH (e, v) {
//	eprintf("%d %c : ", e->first, e->second);
	right = left + e->first;
	int ma = max(C, left);
	int mi = min(D, right);
	if (ma < mi) ans += string(mi - ma, e->second);
	left = right;
    }

    cout << ans << endl;
    

}


int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 384
from collections import defaultdict
N,M = map(int,input().split())
AC_List = defaultdict(int)
WA_List = defaultdict(int)

for i in range(M):
    Num,Sta = map(str,input().split())
    if Num in AC_List:
        continue
    else:
        if Sta == "WA":
            WA_List[Num] += 1
        else:
            AC_List[Num] += 1

ansct = 0
for k,v in WA_List.items():
    if k in AC_List:
        ansct += v
            
print(str(len(AC_List))+" " +str(ansct))
            
            

Measured memory_bytes: 22156
#include<iostream>
#include<vector>
#include<algorithm>
 using namespace std;
 const long long mod = 1e9 + 7;

 int main() {
	 int N, M;
	 cin >> N >> M;


	 if (1 <= N && N <= 9 && 1 <= M && M <= 9) {
		 cout << N * M << endl;
	 }

	 else cout << "-1";


	 return 0;
 }

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] n1 = new int[N];
   for(int i=0;i<N;i++) n1[i]= sc.nextInt();
   
   int[] n2 = new int[N];
   for(int i=0;i<N;i++) n2[i]= sc.nextInt();
  
   int sum =0;
   
   for(int i=0;i<N;i++)
   {
     sum+= n1[i]+n2[i];
   }
   
   int tmp = sum;
   int ans = 0;
   int minussumtmp=0;
   
   for(int i=0;i<N;i++)
   {
     tmp =sum;
     minussumtmp =0;
     for(int k=0;k<i;k++)
     {
        minussumtmp+=n2[k];
     }
     for(int k=i+1;k<N;k++)
     {
        minussumtmp+=n1[k];       
     }
     if(ans <sum - minussumtmp) ans = sum - minussumtmp;
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;

ll llgcd(ll a, ll b){
    if(b == 0)
        return a;
    return llgcd(b, a % b);
}

ll llpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n, m;
    cin >> n >> m;
    if(n % 2 == 0){
        n--;
    }
    ll cnt = 0;
    ll maehukumazu = (n + 1) / 2;
    // ***** ******(ki, guu);

    ll mae = (maehukumazu - 1) / 2;
    vector<P> ans(100000);
    for (ll i = 1; i <= mae; i ++){
        ans[cnt] = make_pair(i, maehukumazu - i);
        cnt++;
    }

    ll ato = maehukumazu / 2;
    for (ll i = 1; i <= ato; i ++){
        ans[cnt] = make_pair(i + maehukumazu - 1, n + 1 - i);
        cnt++;
    }
    for (ll i = 0; i < m; i ++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
        return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=405,mod=998244353;
int b[N],sa,sb,n;
ll a[N],A[N],fac[N],ni[N],dp[2][N][N],yc[N],xs[N][N],inv[N];
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main(){
	For(i,fac[0]=ni[0]=1,N-1){
		fac[i]=fac[i-1]*i%mod; ni[i]=ksm(fac[i],mod-2);
	}
	n=read(); ll s=0;
	For(i,1,n){s+=(a[i]=read());b[i]=read(); }
	inv[1]=1; For(i,2,n)inv[i]=mod-mod/i*inv[mod%i]%mod;
	s=ksm(s%mod,mod-2);
	For(i,1,n){
		A[i]=a[i]*s%mod;
	}
	dp[0][0][0]=1;
	For(i,1,n){
		int t=i&1,s=t^1;
		For(j,yc[0]=1,b[i]-1)yc[j]=yc[j-1]*A[i]%mod;
		For(j,0,b[i]-1)yc[j]=yc[j]*(mod-ni[j])%mod;
		sa+=a[i]; sb+=b[i]-1;
		For(j,0,sa)For(k,0,sb){
			dp[t][j][k]=j>=a[i]?dp[s][j-a[i]][k]:0;
			int meiju=min(k,b[i]-1);
			//cout<<meiju<<" "<<k<<" "<<i<<" "<<j<<endl;
			For(l,0,meiju)dp[t][j][k]=(dp[t][j][k]+dp[s][j][k-l]*yc[l])%mod;
		} 
	}
	//cout<<sa<<" "<<sb<<endl;
	For(i,0,sa-1){
		xs[i][0]=ksm((1-i*s)%mod,mod-2);
		For(j,1,sb){
			xs[i][j]=xs[i][j-1]*j%mod*xs[i][0]%mod;
			//wri(xs[i][j]); 
		}//puts("");
	}
	ll ans=0;
	//For(i,0,sa-1)For(j,0,sb)cout<<dp[n&1][i][j]<<" "<<i<<" "<<j<<endl;
	For(i,0,sa-1)For(j,0,sb)ans=(ans+xs[i][j]*dp[n&1][i][j])%mod;
	cout<<(-ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005]={0};
char a[3005];
char b[3005];
char c[3005];
void lcs()
{
	int len1=strlen(a);
	int len2=strlen(b);
	for(int i=1;i<=len1;i++)
	{
		for(int j=1;j<=len2;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]);
		}
	}
}

void look()
{
	int i=strlen(a);
	int j=strlen(b);
	
	int k=dp[i][j];
	memset(c,0,sizeof c);
	while(i!=0&&j!=0)
	{
		if(a[i-1]==b[j-1])
		{
			c[--k]=a[--i];
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
		{
			i--;
		}
		else
		{
			j--;
		}
	}
}
int main()
{
	while(~scanf("%s",a))
	{
		scanf("%s",b);
		lcs();
		look();
		int lenn=strlen(c);
		if(c!=0) 
		printf("%s\n",c);
	}
	return 0;
}

Measured memory_bytes: 35456
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, k; rd(n, k);
  auto x=new long[](n), y=new long[](n);
  foreach(i; 0..n) rd(x[i], y[i]);

  long mn=5_000_000_000_000_000_000;
  foreach(i1; 0..n)foreach(i2; (i1+1)..n){
    foreach(j1; 0..n)foreach(j2; (j1+1)..n){
      auto x1=x[i1], x2=x[i2];
      auto y1=y[j1], y2=y[j2];
      if(x1>x2) swap(x1, x2);
      if(y1>y2) swap(y1, y2);
      if((x2-x1)*(y2-y1)>=mn) continue;
      int cnt=0;
      foreach(t; 0..n){
        if(x1<=x[t] && x[t]<=x2 && y1<=y[t] && y[t]<=y2) cnt++;
      }
      if(cnt>=k) mn=min(mn, (x2-x1)*(y2-y1));
    }
  }
  writeln(mn);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
	cin >> n >> m;
	cout << (n == m ? "Yes" : "No") << endl; 
    
    return 0;
}



Measured memory_bytes: 3652
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b,c,d] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let f n = n - n `quot` c - n `quot` d + n `quot` lcm c d
  print $ f b - f (a - 1)


Measured memory_bytes: 380
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, M, Q = reads()

mat = [[0] * N for _ in range(N)]
for _ in range(M):
  l, r = reads()
  l, r = l-1, r-1
  mat[l][r] += 1

acc = [[0] * (N+1) for _ in range(N+1)]
for i in range(N):
  vec = [0] + list(accumulate(mat[i]))
  acc[i+1] = [acc[i][j] + vec[j] for j in range(N+1)]

for _ in range(Q):
  p, q = reads()
  p, q = p-1, q-1
  ans = acc[N][q+1] - acc[p][q+1]
  print(ans)


Measured memory_bytes: 66136
#include <cstdio>

constexpr int MAX_N = 105;

using namespace std;

int num_white_components, num_black_components;
int color[MAX_N][MAX_N];

int main() {
    scanf(" %d %d", &num_white_components, &num_black_components);

    int h = 100;
    int w = 100;

    for (int i = 0; i < h / 2; ++i) {
        for (int j = 0; j < w; ++j) {
            color[i][j] = 0;
        }
    }

    for (int i = h / 2; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            color[i][j] = 1;
        }
    }

    int per_row = 50;

    for (int i = 0; i < num_white_components - 1; ++i) {
        int row_idx = i / per_row;
        int col_idx = i % per_row;
        col_idx *= 2;
        row_idx *= 2;

        color[row_idx][col_idx] = 1;
    }

    for (int i = 0; i < num_black_components - 1; ++i) {
        int row_idx = i / per_row;
        int col_idx = i % per_row;
        col_idx *= 2;
        row_idx *= 2;

        color[h - row_idx - 1][col_idx] = 0;
    }

    printf("%d %d\n", h, w);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            printf("%c", color[i][j] ? '.' : '#');
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
h = li = list(map(int,input().split()))

c = []
d = []
g = []
s = [1]*n

for i in range(m):
    a,b = map(int,input().split())
    e = [a,b]
    f = [b,a]
    c.append(e)
    d.append(f)

g = c + d
g.sort()

for j in range(2*m):
    k = g[j][0]-1
    l = g[j][1]-1
    if h[k] <= h[l]:
        s[k] = 0

x = s.count(1)
print(x)


Measured memory_bytes: 40548
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define y1 djsfah
using namespace std;
const int N=205;
char s[N][N];
int dis[N],q[N],n,ans;
void check(int S){
	For(i,1,n) dis[i]=-1;
	int h=0,t=1; q[1]=S; dis[S]=1;
	while (h!=t){
		int x=q[++h];
		For(i,1,n)
			if (s[x][i]=='1'&&dis[i]==-1){
				dis[i]=dis[x]+1;
				q[++t]=i;
			}
	}
	For(i,1,n)
		For(j,i+1,n)
			if (s[i][j]=='1')
				if (abs(dis[i]-dis[j])!=1)
					return;
	ans=max(ans,dis[q[n]]);
}
int main(){
	ans=-1;
	scanf("%d",&n);
	For(i,1,n) scanf("%s",s[i]+1);
	For(i,1,n) check(i);
	printf("%d\n",ans);
}
/*
6
2
1 3
4 5
*/

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?b:gcd(b%a,a); }

#define ll long long int 
#define ld long double
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
ll n, m;
int main()
{
	FAST
	cin>>n>>m;
	vector<ll> A(n, 0);
	FOR(i,0,n-1) cin>>A[i];
	ll sum=0, grad=0, base=0;
	vector<ll> B(m+1, 0), O(m+1, 0);
	function <ll(ll)> cy=[&](ll x) {
		return (x-1)%m+1;
	};
	FOR(i,0,n-2) {
		ll a=A[i], b=A[i+1];
		if(a==b) continue;
		if(b>a) base+=b-a;
		else base+=m-a+b;
		if(a > b) {
			if(a+2<=m) ++ B[cy(a+2)];
			sum += (m-a);
			if(b>1) ++ B[2];
			if(b+1<=m) {
				if(b>1) -- B[b+1];
				O[b+1] -= ((b+1-2)+(m-a));
			}
		} else {
			if(a+2 <= m) ++ B[cy(a+2)];
			// cerr<<"cylce: "<<cy(a+2)<<'\n';
			if(b+1<=m) {
				-- B[cy(b+1)];
				O[cy(b+1)] -= (b+1-a-2);
			}
		}
	} assert(B[1]==0);
	// cerr<<"base: "<<base<<'\n';
	// cerr<<"sum: "<<sum<<'\n';
	// FOR(i,1,m) cerr<<B[i]<<'\n';
	ll ans=0;
	FOR(i,1,m) {
		grad += B[i];
		sum += grad+O[i];
		ans = max(ans, sum);
		// if(sum == 5) cerr<<"6: "<<i<<'\n';
	}
	// cerr<<"ans: "<<ans<<'\n';
	cout<<base-ans<<'\n';
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

  public static void main(final String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final long A = Long.parseLong(scanner.next());
    final long B = Long.parseLong(scanner.next());

    final long a = getXorSum(A - 1);
    final long b = getXorSum(B);
    System.out.println(a^b);
  }

  private static long getXorSum(final long n) {
    final long i = (n + 1) / 2; // 1の数
    final boolean f = n % 2 == 0; // 2の倍数かどうか
    if (i % 2 == 0) {
      return f ? n : 0;
    } else {
      return f ? n ^ 1 : 1;
    }
  }
}


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

int main(){
	int N;
	cin >> N;
    int a=N;

	int sum = 0;
	while(N > 0){
		sum += N%10;
		N /= 10; 
	}

	if (a % sum == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" <<endl;
    }
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
field = []
for _ in range(H):
    field.append(input())

def get_adj(pos):
    ans = []
    for v in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        adj = (pos[0] + v[0], pos[1] + v[1])
        if adj[0] >= 0 and adj[0] < H and adj[1] >= 0 and adj[1] < W:
            ans.append(adj)
    return ans

start = (0, 0)
goal = (H-1, W-1)

q = deque()
q.append((start, 1))
visited = {}

while q:
    pos, dist = q.popleft()
    if field[pos[0]][pos[1]] == '#':
        continue
    if pos in visited:
        continue
    visited[pos] = dist
    if pos == goal:
        break
    for adj in get_adj(pos):
        q.append((adj, dist+1))

count_walls = sum([row.count('#') for row in field])

if goal in visited:
    print(H*W-visited[goal]-count_walls)
else:
    print(-1)


Measured memory_bytes: 9624
#include <cstdio>
#include <algorithm>
#include <cstring>


char s[200];
int a[200];

int main()
{
    scanf("%s", s);
    int n = strlen(s);
    for (int i = 0; i < n; ++ i)
        a[i] = s[n - 1 - i] - '0';
    int result = 0;
    for (int i = 0; i < n; ++ i)
        result += a[i];
    for (int i = 0; i < n; ++ i) if (a[i]) {
        int tmp = i * 9 + a[i] - 1;
        for (int j = i + 1; j < n; ++ j)
            tmp += a[j];
        if (result < tmp)
            result = tmp;
    }
    printf("%d\n", result);
}


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

using ll = long long;

#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 pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }

//* 座標nx, nyがWidth,Heightの領域内にあるかどうかのチェック
inline bool rangeCheck2D(int nx, int ny, int Width, int Height)
{
	return nx >= 0 and nx < Width and ny >= 0 and ny < Height;
}

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll H, W; cin >> H >> W;
	vector<string> field(H);
	REP(i, H) cin >> field[i];

	int dx4[] = { 1, -1, 0, 0 };
	int dy4[] = { 0, 0, 1, -1 };
	REP(i, H) {
		REP(j, W) {
			if (field[i][j] == '.') continue;
			bool okay = false;
			REP(k, 4) {
				ll nx = j + dy4[k], ny = i + dx4[k];
				if (not rangeCheck2D(nx, ny, W, H)) continue;
				if (field[ny][nx] == '#')
					okay = true;
			}
			if (not okay) {
				cout << "No" << endl;
				return 0;
			}
		}
	}	
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_V = 10000;
int V;
vector<int> G[MAX_V],rG[MAX_V],vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from,int to)
{
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v)
{
	used[v] = true;
	for(int i = 0;i < G[v].size();++i)
	{
		if(!used[G[v][i]])dfs(G[v][i]);
	}
	vs.push_back(v);
}

void rdfs(int v,int k)
{
	used[v] = true;
	cmp[v] = k;
	for(int i = 0;i<rG[v].size();++i)
	{
		if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
}

int scc()
{
	memset(used,0,sizeof(used));
	vs.clear();
	for(int v = 0;v<V;v++)
	{
		if(!used[v])dfs(v);
	}
	memset(used,0,sizeof(used));
	int k = 0;
	for(int i = vs.size()-1;i>=0;i--)
	{
		if(!used[vs[i]])rdfs(vs[i],k++);
	}
	return k;
}

int main()
{
	int E;
	cin >> V >> E;
	for(int i = 0;i<E;i++)
	{
		int s,t;
		cin >> s >> t;
		
		add_edge(s,t);
	}
	scc();
	//for(int i = 0;i<V;i++)cout<<cmp[i]<<' ';cout<<endl;
	int q;
	cin >> q;
	while(q--)
	{
		int u,v;
		cin >> u >> v;
		cout<<(cmp[u]==cmp[v])<<'\n';
	}
}


Measured memory_bytes: 4716
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
lis=[a,b,c,d,e]
lis.sort()

if(abs(lis[4]-lis[0])<=k):
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        int ret = 0;
        for (int i = a; i <= b; i++) {
            if (c % i == 0) {
                ret++;
            }
        }

        System.out.println(ret);
        System.exit(0);
    }
}



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

void solve(){
    int64_t n;
    string s;
    cin >> n >> s;
    int64_t r = 0, g = 0, b = 0;
    for(int64_t i = 0; i < n; i++){
        if(s[i] == 'R'){
            r++;
        }else if(s[i] == 'G'){
            g++;
        }else{
            b++;
        }
    }
    int64_t ans = r * g * b;
    int64_t l;
    for(int64_t i = 0; i < n; i++){
        for(int64_t j = i+1; j < n; j++){
            l = j + (j - i);
            if(l >= n){
                continue;
            }
            if(s[i] != s[j] && s[j] != s[l] && s[i] != s[l]){
                ans--;
            }
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> arr;
	for(int i =0;i<n;i++)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	int min_util = 1e9;
	vector<int> max_arr;
	for(int i =0;i<n;i++)
	{
		min_util = min(arr[i],min_util);
		max_arr.push_back(min_util);
	}
	int cnt = 0;
	for(int i =0;i<n;i++)
	{
		if(max_arr[i] == arr[i])
			cnt++;
		else
			continue;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	float T,A;
	cin >> T >> A;
	std::vector<int> h(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> h[i];
	}
	float minAbs = 1000000;
	int minID = 0;
	for (int i = 0; i < N; ++i)
	{
		float tmp = T - h[i] * 0.006f;
		if(minAbs > abs(A - tmp)){
			minAbs = abs(A - tmp);
			minID = i;
		}

	}
	cout << minID + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

int main(){
    int N;
    cin >> N;
    int sum_=0;
    int ans=0;
    if(N%2==0){
        sum_=N+1;
        ans=(N-2)*N/2;
    }else{
        sum_=N;
        ans=(N-2)*(N-2)/2+N-1;
    }
    cout << ans << endl;
    for(int i=1; i<N+1; i++){
        for(int j=i+1; j<N+1; j++){
            if(i+j==sum_)continue;
            cout << i << ' ' << j << endl;
        }
    }
}

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	int result = INT_MAX;
	for (int i = 0; i + k - 1< n; i++) {
		result = min(result, A[i + k - 1] - A[i]);
	}
	cout << result << endl;
}



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

int main() {
  int n,m,max=0,total=0;
  cin >> n;
  string strn[n];
  for(int i=0;i<n;i++)
    cin >> strn[i];
  cin >> m;
  string strm[m];
  for(int t=0;t<m;t++)
    cin >> strm[t];
  for(int i=0;i<n;i++){
    for(int l=0;l<n;l++){
      if(strn[i]==strn[l])
        total++;
    }
    for(int t=0;t<m;t++){
      if(strn[i]==strm[t])
        total--;
    }
    if(total>max)
      max = total;
    total=0;
  }
  cout << max << endl;
  
  
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#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 VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int N;
	cin>>N;
	cout<<N*(N+1)/2<<endl;
	return 0; 
}



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

using namespace std;

int main() {
	long long x, k, d; cin >> x >> k >> d;
	x = abs(x);
	cout << (k <= x / d ? x - d * k : (k - x / d) % 2 == 0 ? x % d : abs(x % d - d)) << '\n';
	return 0;
}


Measured memory_bytes: 3640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


N = int(input())
X = list(map(int, input().split()))

# X の avg をとり、Xi と avg との差の二乗を足し合わせていくのでよいのでは?

avg1 = sum(X) // N
avg2 = avg1 + 1
print(min(
    sum([(x - avg1) * (x - avg1) for x in X]),
    sum([(x - avg2) * (x - avg2) for x in X])
))


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

tmp=input()
n = int(tmp.split(" ")[0])
a = int(tmp.split(" ")[1])
b = int(tmp.split(" ")[2])

x=int(0)
y=int(0)

x=min(a,b)
y=max(a+b-n,0)

print(x,y)

Measured memory_bytes: 3064
str_list = [chr(i) for i in range(65,65 + 26)]
n = int(input())
s = input()
new_s = []
for i in s:
    tmp = ord(i) + n if ord(i) + n < 65 + 26 else  (ord(i) + n) % (65 + 26) + 65 
    new_s.append(chr(tmp))
print(''.join(new_s))

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 100
#define white 0
#define black 2
#define gray 1

void dfs(void );
void dvisit(int );

int n;
int Adj[MAX][MAX],d[MAX],f[MAX];
int color[MAX],time;

int main(){
  int u,v,k,i,j;;
  scanf("%d", &n);
   for(i=0; i<n; i++){
     for(j=0;j<n;j++)
      Adj[i][j]=0;
  }

  for(i=0; i<n; i++){
    scanf("%d", &u);
    scanf("%d", &k);
    u--;
  for(j=0;j<k;j++){
      scanf("%d", &v);
      v--;
      Adj[u][v]=1;
  }
  }
   
  dfs();

  return 0;
}

void dfs(void ){
  int u;
  for(u=0;u<n;u++){
    color[u]=white;}
  time=0;
  
  for(u=0;u<n;u++){
    if(color[u]==white)dvisit(u);}
  for(u=0;u<n;u++){
    printf("%d %d %d\n", u+1,d[u],f[u]);
  }
}

void dvisit(int u){
  int v;
  color[u]=gray;
  time+=1;
  d[u]=time;
  for(v=0;v<n;v++){
    if(Adj[u][v]==0)continue;
    if(color[v]==white){
      dvisit(v);}}color[u]=black;
  time+=1;
  f[u]=time;}



Measured memory_bytes: 2112
import java.util.*;
public class Main{
    public static void main(String args[]){
	Scanner sc =new Scanner(System.in);
	String a=sc.next();
	String weather[]={"Sunny","Cloudy","Rainy"};
	int b=0;
	for(int i=0;i<weather.length;i++){
	    if(a.equals(weather[i])){
		b=(i+1)%3;
		System.out.println(weather[b]);
	    }
	}
    }
}


Measured memory_bytes: 20688
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define rep(i,j,k) for(int i=j;i<k;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1LL;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

main(){
    fastio;
    int n,p;
    cin >> n >> p;
    vector<int> w(n),v(n);
    for(int i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    vector<int> dp(p+1,-inf);
    dp[0] = 0;
    for(int j=0;j<n;j++)
        for(int i=p;i>=w[j];i--)
                dp[i] = max(dp[i], dp[i-w[j]] + v[j]);
            
    cout << *max_element(td(dp)) << endl;
}

Measured memory_bytes: 1024
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print('A')
    elif 65<=m+f<80:
        print('B')
    elif 50<=m+f<65:
        print('C')
    elif 30<=m+f<50:
        if r>=50:
            print('C')
        else:
            print('D')
            
    elif m+f<30: 
        print('F')
        



Measured memory_bytes: 5596
#include<stdio.h>
int main(){
  char str[5];
  scanf("%s",str);
  if(str[0] != str[1] && str[1] != str[2] && str[2] != str[3]){
    printf("Good\n");
  }else{
    printf("Bad\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[256];
		String tok = sc.next();
		boolean ok = true;
		for(char ch: tok.toCharArray()) c[(int)ch]++;
		for (char ch : tok.toCharArray()) if (c[(int)ch]%2!=0) { ok=false; break; }
		System.out.println(ok ? "Yes" : "No");
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

}


Measured memory_bytes: 35804
from math import sqrt

N = (int)(input())

sqrt_N = int(sqrt(N))


def F(a, b):
    a = str(a)
    b = str(b)
    return max(len(a), len(b))


for i in reversed(range(sqrt_N+1)):
    if N % i == 0:
        print(F(i, N//i))
        exit()


Measured memory_bytes: 3060
N,C = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(C)]

G = [list(map(int,input().split())) for _ in range(N)]
g1 = []
g2 = []
g3 = []
for i in range(N):
    for j in range(N):
        G[i][j] -= 1
        if (i+j)%3 == 0:
            g1.append(G[i][j])
        if (i+j)%3 == 1:
            g2.append(G[i][j])
        if (i+j)%3 == 2:
            g3.append(G[i][j])



cost = [[0]*3 for _ in range(C)]
for c in range(C):
    for g in range(3):
        if g == 0:
            cost[c][0] = sum(D[clr_g1][c] for clr_g1 in g1)
        if g == 1:
            cost[c][1] = sum(D[clr_g2][c] for clr_g2 in g2)
        if g == 2:
            cost[c][2] = sum(D[clr_g3][c] for clr_g3 in g3)



ans = float('inf')
for c1 in range(C):
    for c2 in range(C):
        for c3 in range(C):
            temp = 0
            if c1 == c2 or c2 == c3 or c3 == c1:
                continue
            # temp += sum(D[clr_g1][c1] for clr_g1 in g1)
            # temp += sum(D[clr_g2][c2] for clr_g2 in g2)
            # temp += sum(D[clr_g3][c3] for clr_g3 in g3)
            temp = cost[c1][0] + cost[c2][1] + cost[c3][2]
            ans = min(ans,temp)
print(ans)

Measured memory_bytes: 56924
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		string str = Console.ReadLine();
		char mae = str[0];
		long r = 0;
		for(int i = 0; i < str.Length; i++)
		{
			if(mae != str[i])
			{
				r++;
			}
			mae = str[i];
		}
		Console.WriteLine(r);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 11232
#include <stdio.h>

int main(void) {
	int H, W;
	char A[16][16];
	int i, j, k;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	for (i = 0; i < H; i++) {
		if (scanf("%15s", A[i]) != 1) return 1;
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (A[i][j] == '#') {
				int tomatu = 0, sumipe = 0;
				for (k = 1; i - k >= 0; k++) {
					if (A[i - k][j] == '#') tomatu = 1;
				}
				for (k = 1; j - k >= 0; k++) {
					if (A[i][j - k] == '#') sumipe = 1;
				}
				if (tomatu && sumipe) {
					puts("Impossible");
					return 0;
				}
			}
		}
	}
	puts("Possible");
	return 0;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<ll> a(n + 1), b(n + 1);
    ll c = 0;
    for(int i = 0; i < n; i++){
        a[i] = c;
        if(s[i] == '<'){
            c++;
        }else{
            c = 0;
        }
    }
    a[n] = c;
    c = 0;
    for(int i = n - 1; i >= 0; i--){
        b[i + 1] = c;
        if(s[i] == '>'){
            c++;
        }else{
            c = 0;
        }
    }
    b[0] = c;
    ll ans = 0;
    for(int i = 0; i < n + 1; i++){
        ans += max(a[i], b[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8708
package main

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

const maxBuf = 200100

const debug = false

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	if debug {
		testFile, err := os.Open("./test/sample-1.in")
		if err == nil {
			sc = bufio.NewScanner(testFile)
		}

	}
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

/* #### main #### */
func main() {
	K := readInt()

	a := 7 % K

	for i := 1; i <= K; i++ {
		if a == 0 {
			fmt.Println(i)
			return
		}
		a = (a*10 + 7) % K
	}
	fmt.Println(-1)
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();

		int A = fs.nextInt();
		int B = fs.nextInt();
		int M = fs.nextInt();



		int a[] = new int[A];
		for (int i = 0; i < A; i++) {
			a[i] = fs.nextInt();
		}
		int b[] = new int[B];
		for (int i = 0; i < B; i++) {
			b[i] = fs.nextInt();
		}

		int t = Arrays.stream(a).min().getAsInt() + Arrays.stream(b).min().getAsInt();

		int[] x = new int[M];
		int[] y = new int[M];
		int[] c = new int[M];


		for (int i = 0; i < M; i++) {
			x[i] = fs.nextInt();
			y[i] = fs.nextInt();
			c[i] = fs.nextInt();

		}

		int[] total = new int[M];
		for(int i = 0; i < M; i++) {
			total[i] = a[x[i]-1] + b[y[i]-1] - c[i];
		}


		Arrays.sort(total);
		if(t < total[0]) {
			System.out.println(t);
		}else {
			System.out.println(total[0]);
		}



	}

}


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

Measured memory_bytes: 33164
str = gets.chomp.split("")
a = str.pop
flag = true
if str.index(a) != nil then
  str.delete_at(str.index(a))
  b = str.pop
  if str.index(b) != nil && a != b then
    puts "Yes"
    flag = false
  end
end
if flag then
puts "No"
end

Measured memory_bytes: 1916
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    double x = Double.parseDouble(sc.next());
    double ans = 0.0;
    if(x >= (a * a * b) / 2.0) {
      ans = 2.0 * (a * a * b - x) / (a * a * a);
    } else {
      ans = a * b * b / (2.0 * x);
    }
    ans = Math.toDegrees(Math.atan(ans));
    System.out.println(ans);
  }
}


Measured memory_bytes: 23380
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n - 1];
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
		}
		
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(i == 0) {
				ans += b[a[i] - 1];;
			}
			else if(a[i - 1] == a[i] - 1) {
				ans += b[a[i] - 1] + c[a[i] - 2];
			}
			else {
				ans += b[a[i] - 1];
			}
		}
		
		System.out.print(ans);
	}
	
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,g,b,n;
  cin >> r >> g >> b;
  n = 100*r + 10*g + b;
  if(n%4==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	int[] a=int_arr();
	        		  	int x=a[0],n=a[1];
	        		  	if(n==0){out.write(x+"");out.flush();return;}
	        		  	int[] p=int_arr();

	        		  	Set<Integer> s=new HashSet<>();
	        		  	for(int xz:p){s.add(xz);}
	        		  	int res=100000,kk=0;
	        		   for(int i=-1000;i<=1000;i++){
	        		   	   if(!s.contains(i)){
	        		   	   	 if(res>Math.abs(x-i)){
	        		   	   	 	res=Math.abs(x-i);
	        		   	   	 	kk=i;
	        		   	   	 }
	        		   	   	 //else if(res==Math.abs(x-i)&&kk){}
	        		   	   }
	        		   }
	        		  	out.write(kk+"");
                      out.flush();
	        		 
	}
}
	       
	          



	
  





	
  





Measured memory_bytes: 36664