akhauriyash/Code-Regression huggingface dataset:
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    namespace DSU
    {
        int fa[N],siz[N];void clear(){fo(i,0,N-1)fa[i]=i,siz[i]=1;}
        int findfa(int x){return fa[x]==x?x:fa[x]=findfa(fa[x]);}
        void merg(int x,int y){x=findfa(x),y=findfa(y);if(x==y)return;if(siz[x]<siz[y])swap(x,y);fa[x]=y,siz[y]+=siz[x];}
    };
    vc< pair<int,pii> > edge;int nxt[N];
    void main()
	{
        int n=qread(),m=qread();mem(nxt,0x3f);
        while(m--)
        {
            int x=qread(),y=qread(),c=qread();
            edge.PB({c,{x,y}});chmin(nxt[x],c+1);chmin(nxt[y],c+2);
            // fo(a,0,n-1) edge.PB({c+a+a+1,{x+a,x+a+1}}),edge.PB({c+a+a+2,{y+a,y+a+1}});
        }
        fo(i,0,n-1) chmin(nxt[(i+1)%n],nxt[i]+2);fo(i,0,n-1) chmin(nxt[(i+1)%n],nxt[i]+2);//环形dp
        fo(i,0,n-1) edge.PB({nxt[i],{i,i+1}});

        sort(all(edge));ll ans=0;DSU::clear();
        for(auto now:edge) {
            int x=DSU::findfa(now.SE.FR%n),y=DSU::findfa(now.SE.SE%n);
            if(x==y)continue;ans+=now.FR;DSU::merg(x,y);
        }
        write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 20716
use std::collections::HashMap;
use std::io::prelude::*;

fn main() {
    let stdin = std::io::stdin();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut s = String::new();
    reader.read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();

    let mut s = String::new();
    reader.read_line(&mut s).unwrap();
    let mut map = HashMap::new();
    let an: Vec<i64> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    for a in an {
        *map.entry(a).or_insert(0) += 1;
    }

    let mut max = 0;
    for i in -1..100002 {
        let tmp = match map.get(&(i - 1)) {
            Some(x) => *x,
            _ => 0
        } + match map.get(&i) {
            Some(x) => *x,
            _ => 0
        } + match map.get(&(i + 1)) {
            Some(x) => *x,
            _ => 0
        };
        max = std::cmp::max(max, tmp);
    }
    println!("{}", max);
}


Measured memory_bytes: 14588
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto c1 = readln.chomp;
  auto c2 = readln.chomp;

  if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 256
readlines.each{|line|
  c1, c2, c3 = line.split.map(&:to_i)
  sum = c1 + c2
  arr = [1,2,3,4,5,6,7,8,9,10]
  arr -= [c1, c2, c3]
  count = 0
  7.times{|i|
    if sum + arr[i] <= 20
      count += 1
    else
      break
    end
  }
  if count > 3
    puts "YES"
  else
    puts "NO"
  end
}

Measured memory_bytes: 8624
#include <stdio.h>
#include <string.h>
#define max 10000
char arr[max];
int main()
{
    int flag1=0,flag2=0;scanf("%s",arr);
int len=strlen(arr);
if(arr[2]==arr[3]){
    flag1=1;
}
if(arr[4]==arr[5]){
    flag2=1;
}
if(flag2==1 && flag1==1){
    printf("Yes\n");
}
else{
    printf("No\n");
}
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
# D - Decayed Bridges
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y] #xにyの個数くっつける 
        par[y] = x #yをxにくっつける
        return 

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

N,M = map(int,readline().split())
#0-index
par = [-1]*N
query = []
for _ in range(M):
    x,y = map(int,readline().split())
    query.append((x-1,y-1))

ans = [N*(N-1)//2]
for i in range(M-1):
    x,y = query[-(i+1)]
    a = ans[-1]
    if same(x,y) == False:
        a = ans[-1]-size(x)*size(y)
    ans.append(a)
    if a == 0:
        break
    union(x,y)
S = len(ans)
for i in range(M-S):
    ans.append(0)

print(*ans[::-1],sep='\n')

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

 if (a==b){
  cout<<"a == b"<<endl;
 }
 else if (a>b){
  cout<<"a > b"<<endl;
 }
 else{
  cout<<"a < b"<<endl;
 }
}


Measured memory_bytes: 3068
//Exhaustive Search
#include <iostream>

using namespace std;

bool solve(int A[], int n, int p, int t) {
    if(A[p] == t) return true;
    else if(p >= n-1) return false;
    else if(A[p] > t) return solve(A, n, p+1, t);
    else return solve(A, n, p+1, t) || solve(A, n, p+1, t-A[p]);
}

int main() {
    int n, q;
    cin >> n;
    int A[n];
    for(int i=0; i<n; i++) cin >> A[i];
    cin >> q;

    int m;
    for(int i = 0; i < q; i++) {
        cin >> m;
        if(solve(A, n, 0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}



Measured memory_bytes: 3092
#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>;

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

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

#define endl '\n'

char get(char a, char b){
    if (a > b) swap(a,b);
    if (a == 'B' && b == 'R') return 'G';
    if (a == 'G' && b == 'R') return 'B';
    return 'R';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    if (n<3){
        cout << 0 << endl;
        return 0;
    }

    long long resp=0;
    map<char, long long> freq;
    for (int i=1; i<n; i++) freq[s[i]]++;

    for (int j=1; j<n-1; j++){
        freq[s[j]]--;
        for (int i=j-1; i>=0; i--){
            if (s[i] == s[j]) continue;
            resp += freq[get(s[i], s[j])];
            if (j + j - i < n && s[j + j - i] == get(s[i], s[j])) resp--;
        }
    }
    cout << resp << endl;
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
  int n,w;
  
  cin >> n >> w;
  int i,j,k;
  int b;
  double o=0.01;
  while(n+w!=0){
    double v[101]={};
    o=0.01;
    int m=0,ma=0;
    for(i=0;i<n;i++) {
      cin >> b;
      v[b/w]++;
      if(ma<b/w) ma=b/w;
      if(m<v[b/w])m=v[b/w];
    }
    //cout << m << " " << ma << endl;
    for(i=0;i<=ma;i++) {
      //cout << (v[i]/m)<<" "<< ((double)(ma-i)/ma) << endl;
      o+=(v[i]/m)*((double)(ma-i)/ma);
      //cout << o << endl;
    }
    cout << o << endl;
    cin >> n >> w;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <cstdio>

int n, d, x, y, amt;

int main() 
{
	scanf("%d%d", &n, &d);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &x, &y);
		if ((long long)x * x + (long long)y * y <= (long long)d * d) ++amt;
	}
	printf("%d\n", amt);
	return 0;
}


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

int main() {
    int N, v, j;
    cin >> N;
    int array[N];
    for(int i = 0; i < N; i++)
    {
        cin >> array[i];
        if(i > 0)
            cout << " ";
        cout << array[i];
    }
    cout << endl;
    for(int i = 1; i <= N - 1; i++)
    {
        v = array[i];
        j = i - 1;
        while(j >= 0 && array[j] > v)
        {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = v;
        for(int k = 0; k < N; k++)
        {
            if(k > 0)
                cout << " ";
            cout << array[k];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstring>

using namespace std;

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

int main(){
  char s[11111];
  scanf("%s", s);
  int len = strlen(s);

  ll ans = 0;
  rep(i, 1 << (len - 1)) {
    ll tmp = s[0] - '0';
    rep(j, len - 1) {
      if (i & (1 << j)) {
        ans += tmp;
        tmp = 0;
      }
      tmp = tmp * 10 + s[j + 1] - '0';
    }
    ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  string S;
  cin>>S;
 
  ll ans1=0;
  ll ans2=0;
  if(S.size()%2==0){
    
  rep(i,S.size()/2){
    
    if(S[i]!=S[S.size()-1-i]){
      ans1++;
    }
  }
  }
 
else{
    
  rep(i,S.size()/2){
    
    if(S[i]!=S[S.size()-1-i]){
      ans2++;
    }
  }
  }
    cout<<max(ans1,ans2)<<endl;

}

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

int n;
long long sum[200001], v[200001];


int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &v[i]);
        sum[i] = sum[i - 1] + v[i];
    }

    long long ans = LLONG_MAX;
    for (int i = 1; i < n; i++)
    {
        long long diff = 1LL * abs(sum[n] - sum[i]);
        ans = min(ans, 1LL * abs(sum[i] - diff) );
    }

    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  char S[N];
  for(int i(0);i<N;i++)	cin >> S[i];
  for(int i(0);i<N;i++){
    if(S[i]=='Y'){
      cout << "Four";
      break;
    }
    else if(i == N-1) cout<<"Three";
  }
}

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

int main(){
    int k, q;
    cin >> k >> q;
    vector<ll> d(k);
    for (int i = 0; i < k; i++) cin >> d[i];
    
    ll dsum = 0;
    for (int i = 0; i < k; i++) dsum += d[i];
    
    for (int z = 0; z < q; z++) {
        ll n, x, m;
        cin >> n >> x >> m;
        vector<ll> e(k);
        ll esum = 0;
        for (int i = 0; i < k; i++) {
            e[i] = d[i]%m;
            esum += e[i];
        }
        ll t = x%m;
        t += esum * ((n-1) / (ll)k);
        for (int i = 0; i < (n-1)%k; i++) t += e[i];
        ll ans = n - 1 - (t/m);
        ans -= count(e.begin(), e.end(), 0) * ((n-1) / (ll)k);
        for (int i = 0; i < ((n-1)%k); i++) {
            if (e[i] == 0) ans--;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 512
function Main(input) {
  input = input.split(" ");
  //空白で区切るってことやろ

  var A = parseInt(input[0], 10);
  var B = parseInt(input[1], 10);
  var C = parseInt(input[2], 10);
  var D = "No";
  if( A + B == C ){
    D = "Yes"
  }
  if( B + C == A ){
    D = "Yes";
  }
  if( A + C == B ){
    D = "Yes";
  }
console.log(D);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n)cin >> h[i];
    sort(h.begin(),h.end());
    ll mindif = 1e10;
    rep(i,n-k+1){
        ll maxh = h[i+k-1];
        ll minh = h[i];
        mindif = min(mindif,maxh - minh);

    }
    cout << mindif << endl;
    return 0;
}

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

namespace ojtEx
{
    class Program
    {
        static void Main(string[] args)
        {
            //int X = int.Parse(Console.ReadLine());
            //int a = int.Parse(Console.ReadLine());
            //string s = Console.ReadLine();

            string[] xa = Console.ReadLine().Split(' ');
            int x = int.Parse(xa[0]);
            int a = int.Parse(xa[1]);


            int ans = Solve(x, a);

            //int x, y, z, w;
            //x = int.Parse(s[0].ToString());
            //y = int.Parse(s[1].ToString());
            //z = int.Parse(s[2].ToString());
            //w = int.Parse(s[3].ToString());


            //string ans = S(x, y, z, w);

            Console.WriteLine(ans);
        }

        //public static int Solve(int X, int A)
        //{
        //    if (X < A)
        //    {
        //        return 0;
        //    }
        //    if (A <= X)
        //    {
        //        return 10;
        //    }

        //    return 0;
        //}

        public static string S(int x, int y,int z,int w)
        {
            if(x!=y && y!=z && z!=w)
                {
                return "Good";
                }
            else
            {
                return "Bad";
            }
        }

        //public static int Solve(int N, int A, int B)
        //{
        //    if (N * A < B)
        //    {
        //        return N * A;
        //    }
        //    if (B < N * A)
        //    {
        //        return B;
        //    }
        //}

        public static int Solve(int A, int B)
        {
            if (A + B > A - B && A + B > A * B)
            {
                return A + B;
            }
            else if (A * B > A + B && A * B > A - B)
            {
                return A * B;
            }
            else
            {
                return A - B;
            }
        }


    }
}


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

using namespace std;

#define endl "\n"


int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && a != c && b != c)|| (b == c && a != b && a != c) || (a == c && b != c && b!= a))
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

vi solve(int n, int a, int b){
    vi ans(1<<n);
    if(n==1){
        ans[0] = a;
        ans[1] = b;
    }else{
        int k=0;
        while(((a>>k) & 1) == ((b>>k) & 1)) k++;
        int a1,b1,b2;
        a1 = (a>>(k+1))<<k;
        a1 += a%(1<<k);
        b1 = (b>>(k+1))<<k;
        b1 += b%(1<<k);
        //printf("x %d %d %d: %d %d %d\n", n,a,b,k, a1, b1);
        
        vi ans1 = solve(n-1,a1,a1^1);
        vi ans2 = solve(n-1,a1^1,b1);
        rep(i,0,1<<(n-1)){
            int x = (ans1[i]>>k)<<(k+1);
            x += ans1[i]%(1<<k);
            x ^= a&(1<<k);
            ans[i] = x;
        }
        rep(i,0,1<<(n-1)){
            int x = (ans2[i]>>k)<<(k+1);
            x += ans2[i]%(1<<k);
            x ^= b&(1<<k);
            ans[i+(1<<(n-1))] = x;
        }
    }
    /*
    cout << n << " " << a << " " << b << ": ";
    trav(v, ans){
        cout << v << ",";
    }
    cout << endl;*/
    return ans;
}

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n,a,b;
    cin >> n >> a >> b;
    int c = a^b;
    int k=0;
    while(c>0){
        k += c%2;
        c /= 2;
    }
    if(k%2 == 0){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
        vi ans = solve(n,a,b);
        trav(x,ans){
            cout << x << " ";
        }
        cout << endl;
    }

    return 0;
}


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

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

    for(int i=0;i<k;i++){
        if(i%2==0){
            if(a%2!=0){
                a--;
                b+=a/=2;
            }else{
                b+=a/=2;
            }
        }else{
            if(b%2!=0){
                b--;
                a+=b/=2;
            }else{
                a+=b/=2;
            }
        }
    }
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
sa = input()
sb = input()
sc = input()

nx = 'a'

for i in range(len(sa) + len(sb) + len(sc)):
	if nx == 'a':
		if sa == '':
			print('A')
			break
		else:
			nx = sa[0]
			sa = sa[1:]
	elif nx == 'b':
		if sb == '':
			print('B')
			break
		else:
			nx = sb[0]
			sb = sb[1:]
	elif nx == 'c':
		if sc == '':
			print('C')
			break
		else:
			nx = sc[0]
			sc = sc[1:]

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) Yes;
    else if(s[1] == s[2] && s[2] == s[3]) Yes;
    else No;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
mint f(int n){
    if(n == 0){
        return 1;
    }
    mint x = f(n / 2);
    x *= x;
    if(n % 2 == 1){
        x = x * 2;
    }
    return x;
}

mint choose(int n, int k){
    mint x = 1, y = 1;
    for(int i = 0; i < k; i++){
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

int main(void){
    int n, a, b;
    std::cin >> n >> a >> b;
    mint ans = f(n);

    ans -= 1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    cout << ans.x << endl;


    return 0;
}

Measured memory_bytes: 3640
A = [[int(i) for i in input().split()] for i in range(3)]

ans = 'Yes'
for i in range(2):
    if A[i][0] - A[i+1][0] != A[i][1] - A[i+1][1] or A[i][1] - A[i+1][1] != A[i][2] - A[i+1][2]:
        ans = 'No'
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define loop(i, a, b) for(ll i = a; i < b; i++)
#define rloop(i, e, s) for(ll i = e; i >= s; i--)
const ll mod = 1e9 + 7;
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr);

int main()
{
  //Dice and Coin
    double ans = 0;
    int n, k;
    cin >> n >> k;
    loop(i, 1, n+1){
        double c = 1.0/n;
        int p = i;
        while(p < k){
            p *= 2;
            c /= 2;
        }
        ans += c;
    }
    cout << setprecision(15) << fixed;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    string s;
    cin >> s;
    if(s[0]!=s[s.length()-1]){
        if(s.length()%2==1) puts("First");
        else puts("Second");
    }
    else{
        if(s.length()%2==0) puts("First");
        else puts("Second");
    }
    return 0;
}

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

void dfs(vector<vector<int>> &to, vector<int> &dp, int index) {
  if (dp.at(index) != -1) return;
  dp.at(index) = 0;
  for (auto next : to.at(index)) {
    dfs(to, dp, next);
    dp.at(index) = max(dp.at(index), dp.at(next) + 1);
  }
  return;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    to.at(x).push_back(y);
  }
  vector<int> dp(n, -1);
  for (int i = 0; i < n; i++) {
    dfs(to, dp, i);
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int x,y,z;
  cin>>x>>y>>z;
  cout << z << " "<< x << " "<<y << endl;
  return 0;
}


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

maxnum = [-1] * (n+1)
cost = [0,2,5,5,4,5,6,3,7,6]
maxnum[0] = 0
for i in range(n+1):
    for num in a:
        if ( i+cost[num] < n+1 ):
            maxnum[i+cost[num]] = max(maxnum[i+cost[num]], num + maxnum[i]*10)

print(maxnum[n])

Measured memory_bytes: 14692
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << a + b + c + max({a, b, c})*(pow(2,k) - 1) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll h, w;
	cin >> h >> w;
	Matrix a(h, Array(w, 0)), b(h, Array(w, 0));

	REP(i, h) {
		REP(j, w) {
			cin >> a[i][j];
		}
	}
	REP(i, h) {
		REP(j, w) {
			cin >> b[i][j];
		}
	}

	vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(80*160+1, false)));

	dp[0][0][abs(a[0][0] - b[0][0])] = true;
	REP(i, h) {
		REP(j, w) {
			REP(k,80*160+1) {
				if (dp[i][j][k] == true) {
					//cout << i << ":" << j << ":" << k << endl;
					if (i + 1 < h) {
						ll d = abs(a[i + 1][j] - b[i + 1][j]);
						dp[i + 1][j][abs(k+d)] = true;
						dp[i + 1][j][abs(k-d)] = true;
					}
					if (j + 1 < w) {
						ll d = abs(a[i][j + 1] - b[i][j + 1]);
						dp[i][j+1][abs(k + d)] = true;
						dp[i][j+1][abs(k - d)] = true;
					}
				}
			}
		}
	}

	ll ans = INF;

	REP (i,80*160+1) {
		if (dp[h - 1][w - 1][i] == true) {
			//cout << i << endl;
			chmin(ans,i);
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=1e16;
const ll ms=(1e6) +5;



int main()
{
    idfc;
    int a,b;
    cin>>a>>b;
    int aa,bb;
    int i;
    for(i=1;i<=10000;i++)
    {
        aa=(i*8)/100;
        bb=i/10;
        if(aa==a&&bb==b)
        {
            cout<<i;return 0;
        }
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
const int mod = 998244353;
int n,m,B,ans;
int f[1<<15][15],p[1<<15],w[15][15];
int main(){
	n = rd(),m = rd();
	Rep(i,1,m) {
		int a = rd()-1,b = rd()-1,c = rd();
		w[a][b] = w[b][a] = c;
		ans+=c;
	}
	p[0] = 0;
	rep(i,1,1<<n){
		int now=0;
		rep(j,0,n)if(i>>j&1){now=j;break;}
		p[i]=p[i^(1<<now)];
		rep(j,0,n)if(i>>j&1)p[i]+=w[now][j];
	}
	mem(f,0xc0);
	f[1][0]=0;
	rep(s,0,1<<n){
		rep(i,0,n){
			for(int t=s;t;t=(t-1)&s)
				if(t>>i&1) f[s][i]=max(f[s][i],f[(s-t)|(1<<i)][i]+p[t]);
			rep(j,0,n)
				if(!(s>>j&1) && w[i][j])
					f[s|(1<<j)][j]=max(f[s|(1<<j)][j],f[s][i]+w[i][j]);
		}
	} 
	writeln(ans-f[(1<<n)-1][n-1]);
}

Measured memory_bytes: 2304
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else if(a == b){
        printf("a == b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2540
require 'set'
 
class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def push(queue, key, value)
  size = queue.size
  index = queue.index{|target, _| target >= key} || size

  return queue[index][1] if index < size && queue[index][0] == key
  return nil if index > 0 && !key.start_with?(queue[index - 1][0])
  queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(key)

  queue.insert(index, [key, value])
  value
end

def calc(n, arrows, start, goal)
  ins = Array.new(n){[]}
  arrows.each do |arrow|
    ins[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    ins[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end

  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  outs = Array.new(n){[]}
  arrows.each do |arrow|
    outs[arrow.source] << arrow
  end

  max = n * arrows.map{|arrow| arrow.label.size}.max

  queue = [['', {start => true}]]
  until queue.empty?
    spell, map = queue.shift
    return spell if map[goal]

    return nil if spell.size > max

    map.each do |node, _|
      outs[node].each do |arrow|
        t = push(queue, spell + arrow.label, {})
        t[arrow.sink] = true if t
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  end

  puts calc(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 9916
#include <stdio.h>
#include <math.h>

int main(void)
{
    double x1, y1, x2, y2;

    scanf("%lf", &x1);
    scanf("%lf", &y1);
    scanf("%lf", &x2);
    scanf("%lf", &y2);

    printf("%lf\n", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)));

    return (0);
}


Measured memory_bytes: 2056
s = input()
key = 0
l = []
for i in range(len(s)-2):
    key = s[i]+s[i+1]+s[i+2]
    l.append(int(key))
ans = abs(l[0]-753)
for i in range(1,len(l)):
    ans = min(ans,abs(l[i]-753))
print(ans)


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

using namespace std;

int main()
{
    int n,m,a;
    cin >> n >> m;
    for(int i = 0;i < m;i++){
        cin >> a;
        n-= a;
    }
    if(n >= 0){
        cout << n <<endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (a, b, c): (usize, usize, usize);
    input!(a, b, c);
    if a - b > c {
        p(0);
    } else {
        p(c + b - a);
    }
}

Measured memory_bytes: 4352
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define FILE
//#define int long long
//#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) ksm((x),mod - 2)
#define lowbit(x) ((x) & (-(x)))

const int MAXN = 1;
const int INF = 2e9;
const double PI = acos(-1);
const double eps = 1e-6;
//const int mod = 1e9 + 7;
//const int mod = 998244353;
//const int G = 3;

int n;

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(n);
	cout << (n ^ 1) << endl;
	return 0;
}



Measured memory_bytes: 3592
sub f{my($u,$t,$p)=@_;push@$t,$u;$_-$p&&f($_,$t^R,$u)for@$u}@a=$,=$";@n=1..<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f 1,b;map{$s=++$x-3;$s+3>$.or$a[$_]||=$s+=3for@$_}@b>$./3&@0>$./3?(0,b):(@b>@0?b:0)x2,n;print@a

Measured memory_bytes: 272512
n,m = map(int, input().split())

matrix = list()
vector = list()

for i in range(n):
    matrix.append(list(map(int, input().split(' '))))

for i in range(m):
    vector.append(int(input()))

for i in range(n):
    result = 0
    for num in range(m):
        result += matrix[i][num] * vector[num]
    print(result)


Measured memory_bytes: 6012
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N);
    ll two_cnt = 0,four_cnt = 0;
    for(auto& in:a) {
        cin >> in;
        if(in%2 == 0) two_cnt++;
        if(in%4 == 0) four_cnt++;
    }
    if(four_cnt >= N/2){
        cout << "Yes" << endl;
        return 0;
    }
    two_cnt -= four_cnt;
    N -= four_cnt*2;
    if(two_cnt >= N){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

constexpr int MAX_M = 1000, MAX_N = 100, INF = std::numeric_limits<int>::max()>>2;

int N, M;
int a[MAX_M], b[MAX_M], c[MAX_M];
int d[MAX_N][MAX_N];

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, M )
    scanf( "%d%d%d", a+i, b+i, c+i ), --a[i], --b[i];

  std::fill( (int*)d, (int*)(d+N), INF );
  rep( i, M )
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  rep( i, N )
    d[i][i] = 0;

  rep( k, N ) rep( i, N ) rep( j, N )
    d[i][j] = std::min( d[i][j], d[i][k]+d[k][j] );

  int ans = 0;
  rep( i, M ) if( d[a[i]][b[i]] < c[i] )
    ++ans;

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

  return 0;
}

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

int main(int argc, char const *argv[]) {
    const double pi = 3.141592653589793;
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double rad = 2*pi/12 * H + 2*pi/(12*60) * M - 2*pi/60 * M;
    double ans = A * A + B * B - 2 * A * B * cos(rad);
    printf("%.20f\n", sqrt(ans));
    return 0;
}


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

using namespace std;

int main(void)
{
    const long long INF = 1e9;
    long long n,m,r;
    cin>>n>>m>>r;
    vector<long long> t(r);
    for(long long i=0;i<r;++i){
        cin>>t[i];
        t[i]--;
    }
    vector<vector<long long>> adj(n,vector<long long>(n,INF));
    for(long long i=0;i<n;++i){
        adj[i][i]=0;
    }
    for(long long i=0;i<m;++i){
        long long a,b,c;
        cin>>a>>b>>c;
        --a; --b;
        adj[a][b]=adj[b][a]=c;
    }

    //フロイド法
    for(long long k=0;k<n;++k){
        for(long long i=0;i<n;++i){
            for(long long j=0;j<n;++j){
                if(adj[i][k]!=INF && adj[k][j]!=INF){
                    adj[i][j]=min(adj[i][j],adj[i][k]+adj[k][j]);
                }
            }
        }
    }

    //tをsortしてnext_permutaionでうまくやる
    sort(t.begin(),t.end());
    long long ans=INF;
    do{
        long long tmp=0;
        for(long long i=0;i<r-1;++i){
            tmp+=adj[ t[i] ][ t[i+1] ];
        }
        if(ans>tmp) ans=tmp;
    }while(next_permutation(t.begin(),t.end()));

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

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <cstring>
#include <cmath>
#include <stack>

const int MOD = 1e9 + 7;
const int MAX = 100000;
#define rep(i,n) for(int i=0;i<(n);i++)

using ll = long long int;
using namespace std;

vector<int> G[MAX];
int color[MAX];
int n;

void dfs(int r, int c)
{
    stack<int> S;
    S.push(r);
    color[r] = c;
    while(!S.empty())
    {
        int u = S.top(); S.pop();
        for(int i = 0; i < G[u].size(); i++)
        {
            int v = G[u][i];
            if(color[v] == -1)
            {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor()
{
    int id = 1;
    for(int i = 0; i < n; i++)
        color[i] = -1;
    for(int u = 0; u < n; u++)
        if(color[u] == -1)
            dfs(u, id++);
}

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

    for(int i = 0; i < m; i++)
    {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for(int i = 0; i < q; i++)
    {
        cin >> s >> t;
        if(color[s] == color[t])
            cout << "yes" << endl;
        else 
            cout << "no" << endl;
    }


    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    ll N;
    cin >> N;
    vector<ll> v(N);
    for(int i=0;i<N;i++) cin >> v[i];
    ll sum = 0;
    sort(v.rbegin(),v.rend());
    ll n=N-2;
    sum += v[0];
    for(int i=1;i<N-1;i++){
        if(n >= 2){
            sum += v[i]*2;
            n-=2;
        }else if(n >= 1){
            sum += v[i];
            n--;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <cstdio>
#include <map>
typedef long long ll; 
inline ll quick_pow(ll a, ll n, ll mod)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % mod; 
		a = a * a % mod;
		n >>= 1; 
	}
	return res; 
}
struct data
{
	ll arr[5]; 
	inline ll &operator [](const int &x)
	{
		return arr[x]; 
	}
	inline const ll &operator [](const int &x) const
	{
		return arr[x]; 
	}
	inline bool operator <(const data &x) const
	{
		for (int i = 0; i < 5; i++)
		{
			if (arr[i] != x[i])
				return arr[i] < x[i]; 
		}
		return false; 
	}
} hsh[300005], cur; 
const ll bs[] = {500003, 250001, 250007, 1234567, 34252124}, md[] = {1000000007, 1000000009, 998244353, 1234567891, 2147483647}; 
ll pw[5][600005], inv[5][600005]; 
int arr[300005]; 
std::map<data, int> app; 
char str[300005]; 
int main()
{
	// freopen("ARC099-F.in", "r", stdin); 
	int n; 
	scanf("%d%s", &n, str); 
	for (int i = 0; i < 5; i++)
	{
		pw[i][0] = 1;
		for (int j = 1; j < 600005; j++)
			pw[i][j] = pw[i][j - 1] * bs[i] % md[i]; 
		inv[i][0] = 1; 
		int x = quick_pow(bs[i], md[i] - 2, md[i]); 
		for (int j = 1; j < 600005; j++)
			inv[i][j] = inv[i][j - 1] * x % md[i]; 
	}
	int pos = n + 5; 
	for (int i = 0; i <= n; i++)
	{
		hsh[i] = cur;
		arr[i] = pos; 
		switch (str[i])
		{
		case '+':
			for (int j = 0; j < 5; j++)
				cur[j] = (cur[j] + pw[j][pos]) % md[j]; 
			break; 
		case '-':
			for (int j = 0; j < 5; j++)
				cur[j] = (cur[j] - pw[j][pos] + md[j]) % md[j]; 
			break; 
		case '<':
			pos--; 
			break; 
		case '>':
			pos++;
		}
	}
	ll ans = 0; 
	for (int i = n; i >= 0; i--)
	{
		int diff = arr[i] - n - 5; 
		data x; 
		if (diff >= 0)
		{
			for (int j = 0; j < 5; j++)
				x[j] = (hsh[i][j] + cur[j] * pw[j][diff]) % md[j]; 
		}
		else
		{
			for (int j = 0; j < 5; j++)
				x[j] = (hsh[i][j] + cur[j] * inv[j][-diff]) % md[j];
		}
		ans += app[x]; 
		app[hsh[i]]++; 
	}
	printf("%lld\n", ans);
	return 0; 
}


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

int main() {
    long int a,b;
    cin>>a>>b;
    long int x=a;
    long int i=1;
    if(b==1)
    {
        std::cout << 0 << std::endl;
        exit(0);
    }
    while(x<b)
    {
        i++;
        x+=a-1;
    }
    // cout<<x<<endl;
    cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int X;
    bool flag = true,isprime = true;
    cin >> X;

    while(flag){
        isprime = true;
        repc(i, 2, X){
            if(X % i == 0){
                isprime = false;
                break;
            }
        }

        if(isprime){
            cout << X << endl;
            return 0;
        }
        X++;
    }
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("story.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	//File();
	int n, m;
	cin >> m >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(all(arr));
	ll sum = 0;
	vector<int> res;
	for (int i = 0; i < n - 1; i++)
	{
		res.push_back(arr[i + 1] - arr[i]);
	}
	res.push_back(m - arr[n - 1] + arr[0]);
	sort(all(res));
	for (int i = 0; i < n - 1; i++)
		sum += res[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 2168
module Main where

import Control.Applicative
import Control.Monad
import Data.List (break)

solve :: String -> Int -> IO ()
solve ss k = do
    let (as, bs) = break (/= '1') ss
    if k <= (length as)
        then putStrLn "1"
        else putStrLn [head bs]

main :: IO ()
main = do
    ss <- getLine
    k <- readLn :: IO Int
    solve ss k

Measured memory_bytes: 508
import java.util.*;
class Main{

    int INF=1<<28;
    int[][] cost,time;

    void run(){

	Scanner sc=new Scanner(System.in);

	while(true){
	int n=sc.nextInt();int m=sc.nextInt();
	if((n|m)==0)break;

	cost=new int[m][m];
	time=new int[m][m];
	for(int i=0;i<m;i++)for(int j=0;j<m;j++){
		cost[i][j]=INF;time[i][j]=INF;
	    }

	for(int i=0;i<n;i++){
	    int a=sc.nextInt()-1;int b=sc.nextInt()-1;
	    cost[a][b]=cost[b][a]=sc.nextInt();
	    time[a][b]=time[b][a]=sc.nextInt();
	}

	for(int k=0;k<m;k++){
	    for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
		    cost[i][j]=Math.min(cost[i][j],cost[i][k]+cost[k][j]);
		    time[i][j]=Math.min(time[i][j],time[i][k]+time[k][j]);
		}}}

	int z=sc.nextInt();
	for(int i=0;i<z;i++){
	    int p=sc.nextInt()-1;int q=sc.nextInt()-1;int r=sc.nextInt();
	    if(r==0){//cost
		System.out.println(cost[p][q]);
	    }else{//time
		System.out.println(time[p][q]);
	    }
	}
	}
    }
    public static void main(String[] args){
	new Main().run();
    }
}

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

int main() {
	int N;
	cin>>N;
	
	map<string,int> zisyo;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		zisyo[s]++;
	}
	
	int saihin=0;
	for(auto z:zisyo){
		saihin=max(saihin,z.second);
	}
	
	for(auto z:zisyo){
		if(z.second==saihin)cout<<z.first<<endl;
	}
	
}


Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

const int N = 50;
const double EPS = 1e-8;

int n;
vector<pair<double, int> > data;

bool equals(double a, double b){ return abs(a - b) < EPS; }

int solve(){
  pair<double, double> dist[N];
  int round[N], res;
  for(int i=0;i<n;i++){
    dist[i] = make_pair(0.0, 0.0);
    round[i] = 1;
  }
  for(res=0;;res++){
    for(int i=0;i<n;i++) if(data[i].second) goto CONT; break;
    CONT:
    for(int i=0;i<n;i++){
      if(data[i].second == 0) continue;
      dist[i] = make_pair(dist[i].second, dist[i].second + data[i].first);
      for(int j=0;j<i;j++){
        if(data[j].second == 0) continue;
        if(round[i] != round[j]) continue;
        if(equals(dist[i].first, 0.0) && equals(dist[j].first, 0.0)) continue;
        if(!equals(dist[j].first, dist[i].first) && dist[j].first < dist[i].first) continue;
        if(!equals(dist[i].first, dist[j].second) && dist[i].first < dist[j].second) dist[i].second = min(dist[i].second, dist[j].second);
      }
      dist[i].second = min(dist[i].second, 1.0);
      if(equals(dist[i].second, 1.0)){
        dist[i].second = 0.0;
        if(round[i] == 0) data[i].second--;
        round[i] = 1 - round[i];
      }
    }
  }
  return res;
}

main(){
  while(cin >> n && n){
    data.clear();
    for(int i=0;i<n;i++){
      int a, b;
      cin >> a >> b;
      data.push_back(make_pair(1.0 / a, b));
    }
    sort(data.begin(), data.end());
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1200
s = input()
x,y = map(int, input().split())
start = 0
key = len(s)
way = 0
dist = 0
now = 0
now_x = set([0])
now_y = set([0])
for k,i in enumerate(s):
  if i == "T":
    key = k
    break
  start += 1
x -= start
for i in s[key:]:
  if i == "T":
    if now:
      now = 0
      if way:
        new_y = set()
        for i in now_y:
          new_y.add(i+dist)
          new_y.add(i-dist)
        now_y = new_y
      else:
        new_x = set()
        for i in now_x:
          new_x.add(i+dist)
          new_x.add(i-dist)
        now_x = new_x
      dist = 0
    way ^= 1
  else:
    now = 1
    dist += 1
if way:
  new_y = set()
  for i in now_y:
    new_y.add(i+dist)
    new_y.add(i-dist)
    now_y = new_y
else:
  new_x = set()
  for i in now_x:
    new_x.add(i+dist)
    new_x.add(i-dist)
    now_x = new_x
if (x in now_x) and (y in now_y):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 51860