akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<stack>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>b;
	b.push_back(-1);

	int tmp;
	for(int i=0;i<n;i++){
		cin>>tmp;
		if(i==0&&tmp!=1){cout<<"-1"<<endl;return 0;}
		b.push_back(tmp);
	}

	stack<int>a;
	//cout<<"test1"<<endl;

	for(int i=0;i<n;i++){
		//cout<<"test2"<<endl;
		if(b[1]!=1){cout<<"-1"<<endl;return 0;}
		for(int j=n-i;j>0;j--){
			if(b[j]==j){
				a.push(j);
				b.erase(b.begin()+j);
				break;
			}
		//cout<<"test3"<<endl;
		}
	}
	
	//cout<<"test4"<<endl;
	while(!a.empty()){
		cout<<a.top()<<endl;
		a.pop();
	}
	return 0;
}

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

int main(void) {
	int n; cin >> n; int X; cin >> X;
	int ans;
	for (int i = 1; i <= n; ++ i) {
		int x; scanf("%d", &x);
		if (i == 1) ans = abs(X - x);
		else ans = __gcd(ans, abs(X - x));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
 
using namespace std;
 
typedef long long int ll;
typedef vector<long long int> VL;
typedef vector<VL> VVL;
 
int main() {
    string str;
    int q;
    cin >> str >> q;
    
    for(int i=0; i<q; i++) {
        string cmd;
        cin >> cmd;
        if(cmd.compare("print") == 0) {
            int a, b;
            cin >> a >> b;
            
            cout << str.substr(a, b-a+1) << endl;
        } else if(cmd.compare("reverse") == 0) {
            int a, b;
            cin >> a >> b;
            
            for(int ofs=0; ofs<(b-a+1)/2; ofs++) {
                char temp = str[a+ofs];
                str[a+ofs] = str[b-ofs];
                str[b-ofs] = temp;
            }
        } else {
            int a, b;
            string p;
            cin >> a >> b >> p;
            
            for(int ofs=0; ofs<b-a+1; ofs++) {
                str[a+ofs] = p[ofs];
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000007;
//------------------------------------------//

int main(){
    string s;cin>>s;
    if(s[s.size()-1]!='s') cout<<s<<'s'<<endl;
    else cout<<s<<"es"<<endl;
}


Measured memory_bytes: 3636
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
ans = [0]*2
t = 0
for i in sorted(count.items(), reverse=True):
  if i[1] >= 4:
    if t == 0:
      ans[0],ans[1] = i[0],i[0]
      t = 2
    elif t == 1:
      ans[t] = i[0]
      t += 1
  elif i[1] >= 2:
    ans[t] = i[0]
    t += 1
  if t == 2: break
print(ans[0]*ans[1])

Measured memory_bytes: 25636
using System;
class aoj
{
    static void Main()
    {
        while (true)
        {
            int n = int.Parse(Console.ReadLine());
            if (n == 0) break;
            int[] a = new int[n];
            int[] b = new int[n];
            for(int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(a);
            int z = 0;
            for(int i = 1; i <=(2 * n); i++)
            {
                for(int j=0;j<n;j++)
                    if (i == a[j]) goto stop;
                b[z] = i;
                z++;
                stop:;
            }
            int ba = 0, a2 = n, b2 = n;
            bool[] c = new bool[n];
            bool[] d = new bool[n];
            z = 0;
            while (true)
            {
                if (z % 2 == 0)
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (c[i] == false)
                        {
                            if (ba < a[i]) { c[i] = true; a2--; ba = a[i]; goto stop;}
                        }
                    }
                    ba = 0;
                }
                else
                {
                    for(int i = 0; i < n; i++)
                    {
                        if (d[i] == false)
                        {
                            if (ba< b[i]) { d[i] = true; b2--;ba = b[i]; goto stop; }
                        }
                    }
                    ba = 0;
                }
                stop:;
                if (a2 == 0 || b2 == 0) break;
                z++;
            }
            Console.WriteLine(b2 + "\n" + a2);
        }
    }
}

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

int main() {
	char a, b;
	cin >> a >> b;

	if (a == 'H')cout << b << endl;
	else {
		if (b == 'H')cout << 'D' << endl;
		else cout << 'H' << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int A[200];
int solve ( int N, int i, int m ) {
    int ans;
    if ( m == 0 ) return 1;
    if ( i >= N ) return 0;
    ans = solve( N, i + 1, m ) || solve( N, i + 1, m - A[i] );
    return ans;
}
int main(void){
    int n, q, M[2000], i, j;
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
    scanf("%d", &q);
    for ( i = 0; i < q; i++ ) scanf("%d", &M[i]);
    for ( i = 0; i < q; i++ ) {
        if( solve( n, 0, M[i]) ) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
string s[8];
vector<vector<int> > rot;
void do_rotate(vector<int>& v, int a, int b, int c, int d){
  int t = v[a];
  v[a] = v[b]; v[b] = v[c]; v[c] = v[d]; v[d] = t;
}
void make_rot(){
  vector<int> v(6);
  REP(i, 6) v[i] = i;
  for(int k = 0; k < 6; k++){
    if(k % 2 == 0) do_rotate(v, 0, 2, 5, 3);
    else do_rotate(v, 0, 1, 5, 4);
    for(int l = 0; l < 4; l++){
      do_rotate(v, 1, 2, 4, 3);
      rot.push_back(v);
    }
  }
}
bool used[8];
int d_id[8];
int r_id[8];
// {id1, id2, r1, r2}
int RULE[12][4] = {
  {0, 1, 2, 3},
  {0, 2, 1, 4},
  {0, 4, 5, 0},
  {1, 3, 1, 4},
  {1, 5, 5, 0},
  {2, 3, 2, 3},
  {2, 6, 5, 0},
  {3, 7, 5, 0},
  {4, 5, 2, 3},
  {4, 6, 1, 4},
  {5, 7, 1, 4},
  {6, 7, 2, 3}
};
vector<int> id1[8];
vector<int> id2[8];
vector<int> r1[8];
vector<int> r2[8];
void make_rule(){
  for(int i = 0; i < 12; i++){
    int x = RULE[i][1];
    id1[x].push_back(RULE[i][0]);
    id2[x].push_back(RULE[i][1]);
    r1[x].push_back(RULE[i][2]);
    r2[x].push_back(RULE[i][3]);
  }
}
bool match(char c, char d){
  if(c > d) swap(c, d);
  return c - 'A' + 'a' == d;
}
bool dfs(int k){
  if(k == 8) return true;
  for(int i = 0; i < 8; i++) if(!used[i]){
    used[i] = true;
    d_id[k] = i;
    for(int j = 0; j < 24; j++){
      r_id[k] = j;
      bool ok = true;
      for(int i = 0; i < id1[k].size(); i++){
        char c1 = s[d_id[id1[k][i]]][rot[r_id[id1[k][i]]][r1[k][i]]];
        char c2 = s[d_id[id2[k][i]]][rot[r_id[id2[k][i]]][r2[k][i]]];
        if(!match(c1, c2)){
          ok = false;
          break;
        }
      }
      if(ok && dfs(k + 1)) return true;
    }
    used[i] = false;
  }
  return false;
}
int main(){
  make_rot();
  make_rule();
  while(true){
    REP(i, 8) cin >> s[i];
    if(cin.eof()) break;
    memset(used, 0, sizeof used);
    memset(d_id, 0, sizeof d_id);
    memset(r_id, 0, sizeof r_id);
    if(dfs(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define FORR(i,a,b) for (int i = a; i <= b; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

const int MX = 100005;
int n, a[MX], b[MX], in;
vii x, y;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> in;
		if (i & 1) a[in]++;
		else b[in]++;
	}

	for (int i = 0; i < MX; i++) {
		x.emplace_back(a[i], i);
		y.emplace_back(b[i], i);
	}

	sort(ALL(x), greater<ii>()), sort(ALL(y), greater<ii>());

	if (x[0].se == y[0].se) {
		cout << n - max(x[0].fi + y[1].fi, x[1].fi + y[0].fi) << endl;
	} else {
		cout << n - (x[0].fi + y[0].fi) << endl;
	}

	return 0;
}

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

int main()
{
    int A, B, K;
    cin >> A>>B>>K;

    if((B-A)>=2*K){
        for (int i = A; i < A + K;i++){
            cout << i << endl;
        }
        for (int i = B - K+1; i <= B;i++){
            cout << i << endl;
        }
    }
    else{
        for (int i = A; i <= B;i++){
            cout << i << endl;
        }
    }

}


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

#define pi 3.141592654
#define lit 1000000007
#define endl '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define _max(a,b) ((a)>(b)?(a):(b))
#define _min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define lbd lower_bound
#define ubd upper_bound
#define ll  long long
#define ull unsigned long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define out(n) cout << n << " "
#define outl(n) cout << n << endl
#define line cout << endl
#define bug(n) {outl(n);return;}
#define debug(arr) cout << #arr << " = [ "; for(auto x : arr) cout << x << ' '; cout <<']' << endl;
#define print(mp) for(auto x : mp){ cout << #mp << " = [ "; cout << x.first << " , " << x.second << " ]" << endl;};
int main()
{
    io;

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    int n,k,ans=0;

    cin>>n>>k;

    vector <int > v(n);

    for(auto &i:v) 
    {
        cin>>i;
    }

    sort(v.begin(),v.end());

    for(int i=0 ; i<k ; i++)
    {
        ans+=v[i];
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

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

int main(void){
    ll N, X; cin >> N >> X;
    vector<ll> x(N); for(int i = 0; i < N; i++) cin >> x[i];
    
    ll D = abs(X - x[0]);
    for(int i = 1; i < N; i++){
        D = gcd(D, abs(X - x[i]));
    }
    
    cout << D << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n,k;
	cin >> n >> k;
	cout << n%k << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static int[] g;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        g = new int[N];
        for (int i = 0; i < N; i++) {
            g[i] = i;
        }

        for (int i = 0; i < M; i++) {
            int A = sc.nextInt();
            A--;
            int B = sc.nextInt();
            B--;
            unite(A, B);
        }

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
            set.add(root(g[i]));
        }

        System.out.println(set.size()-1);
    }

    private static int root(int n) {
        if (g[n] == n) return n;
        return g[n] = root(g[n]);
    }

    private static void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        g[rx] = ry;
    }
}


Measured memory_bytes: 59252
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <cfloat>
#include <iomanip>
using namespace std;
vector <int> edges[600];
double dp[600];
int main(){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int s;
    int t;
    cin >> s >> t;
    edges[s - 1].push_back(t - 1);
  }

  double ans;
  dp[N - 1] = 0;
  for(int i = N - 2; i >= 0; i--){
    dp[i] = edges[i].size();
    for(int j = 0; j < edges[i].size(); j++){
      dp[i] += dp[edges[i][j]];
    }
    dp[i] /= edges[i].size();
  }
  ans = dp[0];
  
  for(int i = 0; i < N - 1; i++){
    if(edges[i].size() > 1){
      dp[N - 1] = 0;
      for(int j = N - 2; j >= 0; j--){
        if(j != i){
          dp[j] = edges[j].size();
          for(int k = 0; k < edges[j].size(); k++){
            dp[j] += dp[edges[j][k]];
          }
          dp[j] /= edges[j].size();
        } else {
          dp[j] = edges[j].size() - 1;
          double max_dp = 0;
          for(int k = 0; k < edges[j].size(); k++){
            dp[j] += dp[edges[j][k]];
            max_dp = max(max_dp, dp[edges[j][k]]);
          }
          dp[j] -= max_dp;
          dp[j] /= (edges[j].size() - 1);
        }
      }
    }
    ans = min(ans, dp[0]);
  }

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 4976
import Control.Monad
import Data.List

main = do
    [n, m] <- getPairs
    ab_s <- replicateM m getPairs
    let points = sort $ mconcat ab_s
    mapM_ print $ map (\z -> length $ filter (== z) points) [1 .. n]

getPairs :: IO [Int]
getPairs = map read . words <$> getLine

Measured memory_bytes: 4372
import sys
from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().rstrip()

def div2_cnt(n):
    m = n
    c = 0
    while m % 2 == 0:
        m /= 2
        c += 1
    return c

def lcm(n, m):
    return (n * m) // gcd(n, m)

def main():
    _, m = map(int, input().split())
    a = [int(i) // 2 for i in set(input().split())]

    a0_c = div2_cnt(a[0])
    for i in a[1:]:
        if a0_c != div2_cnt(i):
            print(0)
            exit()

    first = reduce(lcm, a)
    if m < first:
        print(0)
    else:
        print((m - first) // first // 2 + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13296
#include<stdio.h>
int main()
{
	int n, t;
	scanf("%d %d", &n, &t);
	int i, j;
	int a[3003], b[3003];
	for (i = 0; i < n; i++)
		scanf("%d %d", &a[i], &b[i]);
	for (i = 0; i < n - 1; i++)
	{
		if (a[i] > a[i + 1])
		{
			int f = a[i];
			a[i] = a[i + 1];
			a[i + 1] = f;
			f = b[i];
			b[i] = b[i + 1];
			b[i + 1] = f;
			if (i > 0)
				i -= 2;
		}
	}
	int dp[3003][3003];
	for (i = 0; i <= n; i++)
		for (j = 0; j <= t; j++)
			dp[i][j] = 0;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < t; j++)
			dp[i + 1][j] = dp[i][j];
		for (j = 0; j < t - a[i]; j++)
			if (dp[i + 1][j + a[i]] < dp[i][j] + b[i])
				dp[i + 1][j + a[i]] = dp[i][j] + b[i];
	}
	int ans = 0;
	for (i = 0; i < n; i++)
		if (b[i] + dp[i][t - 1] > ans)
			ans = b[i] + dp[i][t - 1];
	printf("%d\n", ans);
	return 0;
}


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

int main(){

string S, S2;
cin >> S >> S2;

for(int i = 0; i < 3; i++){ 
     if(S.at(i) != S2.at(2 - i)){

      cout << "NO" << endl; 
     return 0;
     }
}

cout << "YES" << endl; 

}


Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).sort
if as.uniq.count <= K
  puts 0
else
  as << nil
  previous = nil
  count = 0
  as = as.map.with_index { |a, i|
    if a == previous
      count += 1
      nil
    else
      output = previous ? { num: previous, count: count } : nil
      previous = a
      count = 1
      output
    end
  }.compact.sort { |a, b| b[:count] <=> a[:count] }
  rewrite = 0
  as[K..-1].map { |a| rewrite += a[:count] }
  puts rewrite
end


Measured memory_bytes: 63668
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll t1,t2,a1,a2,b1,b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;
  if(t1*a1+t2*a2 == t1*b1+t2*b2){
    cout << "infinity" << endl;
    return 0;
  }
  if(a1 > b1 && a2 > b2){
    cout << 0 << endl;
    return 0;
  }
  if(b1 > a1 && b2 > a2){
    cout << 0 << endl;
    return 0;
  }

  ll d,d1;
  ll c,ans;
  if(a1 < b1){
    c = b1;
    b1 = a1;
    a1 = c;
    c = b2;
    b2 = a2;
    a2 = c;
  }

  if(a1 > b1 && a2 < b2){
    d = t1*(a1-b1)+t2*(a2-b2);
    if(d > 0){
      cout << 0 << endl;
      return 0;
    }
    else{
      d1 = t1*(a1-b1);
      d = -d;
      if(d > d1){
        ans = 1;
        cout << ans << endl;
        return 0;
      }
      if(d1%d == 0){
        ans = 2*(d1/d);
        cout << ans << endl;
        return 0;
      }
      else{
        ans = 1+2*(d1/d);
        cout << ans << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i, n) {
        cin >> p[i].first;
        p[i].second = i + 1;
    }
    sort(p.begin(), p.end());
    rep(i, n - 1) {
        cout << p[i].second << " ";
    }
    cout << p[n - 1].second << endl;
    return 0;
}

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

string S;
int x1, x2, x3, x4, x5; 

int main(){
    int x1, x2, x3, x4, x5; 
    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1==0) cout << 1 <<endl;
    if(x2==0) cout << 2 <<endl;
    if(x3==0) cout << 3 <<endl;
    if(x4==0) cout << 4 <<endl;
    if(x5==0) cout << 5<<endl;

    return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var oneLine = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            Console.WriteLine(oneLine.Sum() >= 22 ? "bust" : "win");
        }
    }
}



Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
char s[5000];
int a,i,k;
int b=0;
int lari=0;
int rari=0;
int count=0;
int max=0;
int main(){
 scanf("%d",&a);
scanf("%s",s);
 for(i=1;i<a;i++){
if(s[0]==s[i]&&b==0){
  b++; 
  max++;
}
}
 for(i=1;i<a;i++){
  for(k=0;k<i;k++){
   if(s[k]==s[i])lari++;
   }
  for(k=i+1;k<a;k++){
  if(s[k]==s[i])rari++;
}
 if(lari!=0&&rari==0){
 b--;
 lari=0;
 }else if(lari==0&&rari!=0){
b++;
if(max<b)max=b;
rari=0;
}else{
rari=0;
lari=0;
}
}
printf("%d",max);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

//142 B
int main(void) {
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	rep(i, 0, n) {
		ll h;
		cin >> h;
		if (h >= k)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
N = 100

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, H + W + 1):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


ans = 0
for w in range(B + 1, W + 1):
    ans += nCr(H - A - 1 + w - 1, w - 1) * nCr(A - 1 + W - w, A - 1) % MOD
print(ans % MOD)


Measured memory_bytes: 18984
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b = 0,c, n, k;
string s, t;
//cout<<<<endl;


bool anagram(string s,string t)
{
	sort(all(s)); sort(all(t));
	if (s == t)
		return 1;
	else
		return 0;
}

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


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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int n, cnt = 0;
   cin >> n;
   vector<int> x;
   x.resize(n);

   rep(i, n)
   {
      cin >> x[i];
   }

   reps(i, n - 1)
   {
      if (x[i] == x[i - 1])
      {
         ++cnt;
         x[i] = 0;
      }
   }

   cout << cnt << '\n';
}

Measured memory_bytes: 256
// The very basic /////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ALL_H 1

// Print elements of containers using << operator /////////////////////////////
// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  for (auto &elem : v) {
    s << elem;
    if (&elem != &v.back()) s << " ";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  for (auto &elem : vv) {
    s << elem;
    if (&elem != &vv.back()) s << endl;
  }
  return s;
}
// map
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto &elem: m) {
    s << " " << elem.first << " : " << elem.second << endl;
  }
  s << "}";
  return s;
}
//set
template<typename T> ostream& operator<<(ostream& s, const set<T>& m) {
  s << "{ ";
  for (auto &elem: m) {
    s << elem << " ";
  }
  s << "}";
  return s;
}

// Convenient macros //////////////////////////////////////////////////////////

// types
#define ll long long
#define ld long double
#define int ll
#define Pi pair<int, int>
#define Graph vector<vector<int>>
#define WeightGraph vector<vector<Pi>>

// other
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

#define MOD 1000000007
#define INF LLONG_MAX/100

// update max or min //////////////////////////////////////////////////////////

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

// gcd
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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


// Debug it by D(x) ///////////////////////////////////////////////////////////
#define DEBUG 1
#if DEBUG
#define D(x) x
#else
#define D(x)
#endif

///////////////////////////////////////////////////////////////////////////////
//                             Start Coding Here                             //
///////////////////////////////////////////////////////////////////////////////

signed main() {
  int N, K, S; cin >> N >> K >> S;
  srand (time(NULL));
  rep(i, N) {
    if (i < K) cout << S;
    else cout << rand() % 1000000000 + 1;
    if (i != N -1) cout << " ";
    else cout << endl;
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define faster ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
int main() {
    faster
    int n, cnt = 0;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for (int i = 1; i < n - 1; i++) {
        int temp[] = {arr[i - 1], arr[i], arr[i + 1]};
        sort(temp, temp+3);
        if (temp[1] == arr[i]) {
            cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
typedef long long ll;
using namespace std;

int abs(int a) {
 return a > 0 ? a : -a;
}

int main(void) {
  ll i, j, k, n, ans = 1000, a, b, x, y, c;
  scanf("%lld%lld%lld", &a, &b, &c);
  if(ans > abs(a - b) + abs(b - c)) ans = abs(a - b) + abs(b - c);
  if(ans > abs(a - c) + abs(b - c)) ans = abs(a - c) + abs(b - c);
  if(ans > abs(a - c) + abs(b - a)) ans = abs(a - c) + abs(b - a);
  printf("%lld\n", ans);
  return 0;
}

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

int main() {
  int c[3][3];
  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++)
      cin >> c[i][j];
  int a[3], b[3], g[4];
  a[0] = c[0][0] + c[0][1] + c[0][2];
  a[1] = c[1][0] + c[1][1] + c[1][2];
  a[2] = c[2][0] + c[2][1] + c[2][2];
  b[0] = c[0][0] + c[1][0] + c[2][0];
  b[1] = c[0][1] + c[1][1] + c[2][1];
  b[2] = c[0][2] + c[1][2] + c[2][2];
  g[0] = abs(a[1] - a[0]);
  g[1] = abs(a[2] - a[1]);
  g[2] = abs(b[1] - b[0]);
  g[3] = abs(b[2] - b[1]);
  if(g[0] % 3 || g[1] % 3 || g[2] % 3 || g[3] % 3)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

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

int main() {
    int n;
    cin >> n;
    int ans = n%10;
    n /= 10;
    if(ans==2 || ans== 4||ans==5||ans==7||ans==9) cout << "hon" << endl;
    else if(ans==0||ans==1||ans==6||ans==8) cout << "pon" << endl;
    else if(ans==3) cout << "bon" << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    bool c = false;
    int p = 10 * b;
    for(int i = 0; i < 10; i++) {
        int pp = p + i;
        pp *= 0.08;
        if(pp == a) {
            p = p + i;
            c = true;
            break;
        }
    }
    if(c) {
        cout << p << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

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

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int ans = 0;
    char c;
    rep(i, 6) {
        cin >> c;
        if (c == '1') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
import collections

N = int(input())

A = list()
if N == 1:
	A.append(1)
else:
	while N%2 == 0:
		A.append(2)
		N = N//2
	f = 3
	while f*f <= N:
		if N % f == 0:
			A.append(f)
			N = N//f
		else:
			f += 2
	if N != 1:
		A.append(N)

A = collections.Counter(A)
del A[1]
count = 0

for a in A.values():
	n = 1
	th = n*(n+1)/2
	while a >= th:
		n += 1
		th = n*(n+1)/2
	count += n-1

print(count)

Measured memory_bytes: 9468
fun main() {
    var n = readLine()!!.toLong() - 1L
    var pow = 1L
    for (e in 1..115) {
        pow *= 26L
        if (n < pow) {
            var answer = ""
            for (f in 1..e) {
                answer = ('a' + (n % 26L).toInt()) + answer
                n /= 26L
            }
            println(answer)
            return
        } else {
            n -= pow
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> p;
  p.reserve(n);
  for (int i = 0; i < n; i++) {
    int P;
    cin >> P;
    p.emplace_back(P);
  }
  
  int cnt = 0;
  for (int i = 1; i < n-1; i++) {
    if (p[i-1] < p[i] && p[i] < p[i+1]) {
      cnt++;
    } else if (p[i+1] < p[i] && p[i] < p[i-1]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  
  return 0;
}

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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,ans=1,k;
    cin>>n>>k;
    ans=k;                         //for first ball we have k different options
    for(int i=2;i<=n;i++)
    {
        ans*=(k-1);        //for remaining balls we have k-1 options
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define il inline
#define int long long
const int N=1e5+5;

int n,a[N],du[N];
int to[N+N],nx[N+N],hd[N],sze;

il void add(int u,int v){to[++sze]=v,nx[sze]=hd[u],hd[u]=sze,du[v]++;}

il bool dfs(int u,int F)
{
	int i,v,x=0,y=0,o=0;
	for (i=hd[u]; i; i=nx[i]) if ((v=to[i])!=F)
	{
		if (!dfs(v,u)) return 0;
		o=1,x+=a[v],y=std::max(y,a[v]);
	}
	if (!o) return 1;
	if (a[u]>x||a[u]<x-a[u]||a[u]<y) return 0;
	return a[u]-=x-a[u],1;
}

signed main()
{
	scanf("%lld",&n); int i,u,v;
	for (i=1; i<=n; i++) scanf("%lld",a+i);
	for (i=1; i<n; i++) scanf("%lld%lld",&u,&v),add(u,v),add(v,u);
	if (n==2) return puts(a[1]==a[2]?"YES":"NO"),0;
	
	for (i=1; i<=n; i++) if (du[i]==1) return puts(dfs(i,0)?"YES":"NO"),0;
	
	return 0;
}

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

int main(){
    int n,x;
    cin >> n >> x;
    int m[n];
    for(int i = 0; i<n; ++i){
        cin >> m[i]; x -= m[i];
    }
    sort(m, m+n);
    int result = n;
    for(; x >= m[0]; ){
        x -= m[0]; ++result;
    }
    cout << result <<endl; return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8       as BS
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, x] <- getIntList
  ts <- getIntList

  ct <- VM.new 1
  VM.set ct (0::Int)

  as <- VM.new (n+1)
  VM.write as 0 (0::Int)
  forM_ (zip [1..] ts) $ \(i, a) -> VM.write as i a

  forM_ [1..n] $ \i -> do
    ai_1 <- VM.read as (i-1)
    ai <- VM.read as i
    m <- VM.read ct 0
    let d = max (ai_1 + ai - x) 0
    VM.write as i (ai - d)
    VM.write ct 0 (m + d)

  ans <- VM.read ct 0
  print ans

Measured memory_bytes: 3964
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0;i < (int)(n); i++)
#define pb push_back
typedef long long ll;

using namespace std;







int main() {
    ll n;
    cin >> n;
    string s;
    while(n != 0){
        if(n % 2 == 0){
            n /= -2;
            s = '0' + s;
        }else{
            n = (n - 1) / -2;
            s = '1' + s;
        }

    }
    if(s == "") s = "0";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    ll Q;
    cin >> Q;
    vector<ll> A(Q,0);
    vector<ll> B(Q,0);
    for(ll i=0;i<Q;i++){
        cin>>A[i]>>B[i];
        ll ab=A[i]*B[i];
        ll x=sqrt(ab);
        if(A[i]==B[i]){print(2*x-2) continue;}
        if(x*x==ab){x--;}
        if(x*(x+1)<ab)print(2*x-1)
        else print(2*x-2)
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
const int INF = 999999999;

int main(){
    int N; cin >> N;
    vector<vector<int>> abc(N,vector<int>(3,0));
    vector<vector<int>> dp(N,vector<int>(3,0));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            cin >> abc.at(i).at(j);
        }
    }
    
    //前処理
    for(int i = 0; i < 3; i++){
        dp.at(0).at(i) = abc.at(0).at(i);
    }
    
    for(int i = 1; i < N; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                dp.at(i).at(j) = max(dp.at(i).at(j), abc.at(i).at(j) + dp.at(i-1).at(k));
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 3; i++){
        ans = max(ans, dp.at(N-1).at(i));
    }
    cout << ans << endl;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<vector<int> > field(h, vector<int> (w, 0));

    if (a == 0 && b != 0) {
      rep(i, h) {
	rep(j, w) {
	  if (i < b) field[i][j] = 1;
	}
      }
    } else if (a != 0 && b == 0) {
      rep(i, h) {
	rep(j, w) {
	  if (j < a) field[i][j] = 1;
	}
      }
    } else {
      rep(i, h) {
	rep(j, w) {
	  if ((i < b && j >= a) || (i >= b && j < a)) field[i][j] = 1;
	}
      }
    }

    rep(i, h) {
      rep(j, w) {
	cout << field[i][j];
      }
      cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n, l;
  cin >> n >> l;
  int total = n * (l - 1) + n * (n + 1) / 2;
  int eat;
  if (l + n - 1 < 0) {  // 最大を足しても負なので、最大を食べる
    eat = l + n - 1;
  } else if (l >= 0) {  // 何も食べなくても正なので、最小を食べる
    eat = l;
  } else {  // ZEROになるように食べる
    eat = 0;
  }

  cout << total - eat << endl;
  return 0;
}


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

using Lint=long long;

template<int mod> class ModInt
{
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

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

   vector<vector<mint>> dp(N+1,vector<mint>(K+1));
   dp[0][0]=1;
   for(int i=0;i<N;i++){
      for(int j=0;j<=K;j++){
         int L=j;
         int R=j+min(K-j,a[i]);
         // add dp[i][j] to dp[i+1][L]~dp[i+1][R]
         dp[i+1][L]+=dp[i][j];
         if(R+1<=K) dp[i+1][R+1]-=dp[i][j];
      }
      for(int j=0;j<K;j++) dp[i+1][j+1]+=dp[i+1][j];
   }
   cout<<dp[N][K].value()<<endl;
   return 0;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

	map<int, int> m;
	vector<int> sum(N+1,0);
	for(int i=0;i<=N;i++) sum[i+1]=(sum[i]+A[i])%M;

	ll ans=0;
	for(int i=0;i<sum.size();i++) {
			ans += m[sum[i]];
			m[sum[i]]++;
	}

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


Measured memory_bytes: 3968
h,w,m, = gets.split.map(&:to_i)
subject = readlines.map{|line| line.split.map(&:to_i)}
hh = Array.new(h,0)
ww = Array.new(w,0)
haha = Hash.new(0)
subject.each do |i|
  hh[i[0]-1] += 1
  ww[i[1]-1] += 1
  haha[[i[0]-1,i[1]-1]] = 1
end
k = hh.max
l = ww.max
hhh = []
www = []
for x in 0..(h-1)
  hhh << x if hh[x] == k
end
for y in 0..(w-1)
  www << y if ww[y] == l
end
hs = hhh.size
ws = www.size
for x in 0..(hs-1)
  for y in 0..(ws-1)
    hx = hhh[x]
    wy = www[y]
    if haha[[hx,wy]] == 0
      puts k+l
      exit
    end
  end
end
puts k+l-1

Measured memory_bytes: 83268
import numpy as np
n = int(input())
p = list(map(int, input().split()))
p = np.array(p)
count = 0

p_sorted = np.sort(p)
for i in range(n):
    if p_sorted[i] != p[i]:
        count += 1

if count >2:
    print("NO")
else :
    print("YES")




Measured memory_bytes: 12488
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let v: Vec<char> = get!(String).chars().collect();
    // println!("{:?}", v);
    let mut flag = true;
    for i in 0..v.len() {
        if i % 2 == 1 {
            // L U D
            // if v[i] == 'L' || v[i] == 'U' || v[i] == 'D' {
            //     flag = true;
            // } else {
            //     flag = false;
            // }
            if v[i] == 'R' {
                // eprintln!("i: {} v[i]: {}", i, v[i]);
                flag = false;
            }
        } else {
            // R U D
            // ``if v[i] == 'R' || v[i] == 'U' || v[i] == 'D' {
            // ``    flag = true;
            // ``} else {
            // ``    flag = false;
            // ``}
            if v[i] == 'L' {
                // eprintln!("i: {} v[i]: {}", i, v[i]);
                flag = false;
            }
        }
    }
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#input
S = str(input())[::-1]

#output
from collections import Counter
#2019 = 3 * 673
N = len(S)
#上からi桁目までの数を決めた時2019の個数をdp[i]とする。
dp = [0] * (N)
dp[0] = int(S[0])
times =10
for i in range(N-1):
    dp[i+1] = dp[i] + times * int(S[i+1])
    dp[i+1] %= 2019
    times *= 10
    times %= 2019

T = Counter(dp)

answer = T[0]

for t in T.values():
    answer += t*(t-1)//2

print(answer)

Measured memory_bytes: 16720
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int inf=100000000;//とにかく大きい数
				
				int n=sc.nextInt();//圧縮する入力信号の数
				int m=sc.nextInt();//コードブックに含まれる値の個数
				if(n+m==0) break;
				int[] c=new int[m+1];//コードブックの値
				int[] x=new int[n+1];//入力信号の値
				for(int i=0; i<m; i++) {
					c[i]=sc.nextInt();
				}
				for(int i=0; i<n; i++) {
					x[i]=sc.nextInt();
				}
				
				int[][] dp=new int[n+1][256];
				for(int i=0; i<256; i++) {
					for(int j=0; j<=n; j++) {
						dp[j][i]=inf;
					}
				}
				dp[0][128]=0;
				ArrayList<Integer> list=new ArrayList<>();
				for(int i=0; i<n; i++) {
					for(int j=0; j<256; j++) {
						if(dp[i][j]==inf) {
							continue;
						}
						for(int k=0; k<m; k++) {
							int yn=j+c[k];
							if(yn>255) yn=255;
							else if(yn<0) yn=0;
							int sum=(x[i]-yn)*(x[i]-yn);
							dp[i+1][yn]=Math.min(dp[i+1][yn], dp[i][j]+sum);
							//System.out.println("dp["+(i+1)+"]["+yn+"]="+dp[i+1][yn]);
						}
					}
				}
				
				for(int j=0; j<256; j++) {
					if(dp[n][j]!=inf) {
						list.add(dp[n][j]);
					}
				}
				Collections.sort(list);
				System.out.println(list.get(0));
				
			}


		}
	}
}


Measured memory_bytes: 126588
// 5/2

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    ll X;
    cin >> X;

    for (ll A = 1; A < 120; A++) {
        for (ll B = 0; B < A; B++) {
            ll A5 = (ll)pow((double)A, 5.0);
            ll B5 = (ll)pow((double)B, 5.0);

            if (A5 - B5 == X) {
                cout << A << " " << B << endl;
                return 0;
            }
            else if (A5 + B5 == X) {
                cout << A << " " << - B << endl;
                return 0;
            }
            else if (- A5 - B5 == X) {
                cout << - A << " " << B << endl;
                return 0;
            }
            else if (- A5 + B5 == X) {
                cout << - A << " " << - B << endl;
                return 0;
            }
        }
    }

}


Measured memory_bytes: 4044
import bisect
n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
ans=0
for i in range(q):
    tmp=bisect.bisect_left(s,t[i])
    if s[tmp]==t[i]:
        ans+=1

print(ans)


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n, m;
    cin >> n >> m;
    rep(i, m) {
        li x;
        cin >> x;
        n -= x;
    }
    cout << (n < 0 ? -1 : n) << endl;

    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define forn for(int i=0;i<n;i++)
//#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    int d=a^b^c;
    if((a==b)||(b==c)||(a==c))
    {
    	if((a!=b)||(b!=c)||(a!=c))
    	cout<<"Yes";
    	else
    	cout<<"No";
	}
	else
	cout<<"No";
}
 


Measured memory_bytes: 256
package main
import (
  "fmt"
  "math"
)

func main() {
  var N, t, x, y, t_now, x_now, y_now int
  fmt.Scan(&N)
  for i := 0; i < N; i++ {
    fmt.Scan(&t, &x, &y)
    length := int(math.Abs(float64(x-x_now))) + int(math.Abs(float64(y-y_now)))
    duration := t - t_now
    if length <= duration && (length - duration) % 2 == 0 {
      continue
    } else {
      fmt.Println("No")
      return
    }
  }
  fmt.Println("Yes")
}


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

int ceil1(int a){
	if(a%10!=0)return (a/10)*10+10;
	else return a;
}

int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	int ans1=a+ceil1(b)+ceil1(c)+ceil1(d)+ceil1(e);
	int ans2=ceil1(a)+b+ceil1(c)+ceil1(d)+ceil1(e);
	int ans3=ceil1(a)+ceil1(b)+c+ceil1(d)+ceil1(e);
	int ans4=ceil1(a)+ceil1(b)+ceil1(c)+d+ceil1(e);
	int ans5=ceil1(a)+ceil1(b)+ceil1(c)+ceil1(d)+e;
	vector<int> ans;
	ans.push_back(ans1);
	ans.push_back(ans2);
	ans.push_back(ans3);
	ans.push_back(ans4);
	ans.push_back(ans5);
	sort(ans.begin(),ans.end());
	cout<<ans[0]<<endl;
}


Measured memory_bytes: 256