akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

    map<string,int> dic;
    long long int cnt = 0;
    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if(dic.find(s)!=dic.end())
        {
            dic[s]+=1;
            cnt += dic[s];
        }
        else
        {
            dic[s]=0;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 11136
#include<cstdio>
int main() {
	int n, y, a, b, c, s, t, m;
	scanf("%d%d", &n, &y);
	y /= 1000;
	//a+b+c=n,10a+5b+c=yの整数解を一つ見つける
	//（解き方：c,s,tを下のように決めて、不定方程式a+b=s,2a+b=tを解けばよい）
	c = y % 5;
	s = n - c;
	t = (y - c) / 5;
	a = t - s;
	b = 2 * s - t;
	//この解(a,b,c)について、cは非負なもののうち最小、a,bの符号は不定
	//a->a-4,b->b+9,c->c-5で和は不変だが、cの最小性から調べなくてよい
	//a->a+4,b->b-9,c->c+5で和は不変で、これを繰り返す以外に条件を満たす和を作る方法はない
	if (b < 0) printf("-1 -1 -1");
	else if (a >= 0) printf("%d %d %d", a, b, c);
	//残ったa<0,b>=0の場合は、「a>=0とするのに必要な操作回数」<=「b>=0でいられる操作回数」が必要十分条件
	else if ((3-a)/ 4 <= b / 9) {
		m = (3 - a) / 4;
		printf("%d %d %d", a + 4 * m, b - 9 * m, c + 5 * m);
	}
	else printf("-1 -1 -1");
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 9e18
#define mod 1000000007

string increment(string A) {
  for(int i = A.size() - 1; i >= 0; --i) {
    if(A[i] < '9') {
      A[i]++;
      break;
    } else {
      A[i] = '0';
    }
  }
  if(A[0] == '0') {
    return "1"+A;
  } else {
    return A;
  }
}

int main(){
  while(1){
    string S;
    cin>>S;
    if(S=="#")break;
    if(S=="0"){
      cout<<11<<endl;
      continue;
    }
    int N=S.size();
    ll res=INF;
    repl(d,1,N+1){
      repl(i,1,d+1){
        string suf=S.substr(0,i),prf=S.substr(i,d-i);
        bool all9=true;
        rep(j,suf.size())if(suf[j]!='9')all9=false;
        string ini;
        if(all9&&(int)prf.size()>0){
          bool plus1=true;
          if(prf[0]!='1')plus1=false;
          repl(j,1,prf.size()){
            if(prf[j]!='0')plus1=false;
          }
          if(plus1){
            ini=prf; rep(j,i+1)ini+='0';
          }else{
            ini=prf; rep(j,i)ini+='0';
          }
        }else{
          ini=prf+suf; ini=increment(ini);
        }
        string crt=suf,con=ini;
        while((int)crt.size()<N){
          crt+=con; con=increment(con);
        }
        if(crt.substr(0,N)==S){
          ll pos=0,num=stoll(ini);
          repl(j,1,ini.size())pos+=j*(pow(10,j-1)*9);
          pos+=(num-pow(10,(ll)ini.size()-1))*(ll)ini.size();
          pos-=(ll)suf.size();
          minch(res,pos+1);
        }
      }
      if(res<INF)break;
    }
    if(res>=10000000000000000)res=10000000000000000-1;
    cout<<res<<endl;
  }

  return 0;
}



Measured memory_bytes: 3344
class dice():
    
    def __init__(self, nums):
        self.pos = []
        self.pos.extend(nums)
    
    def right(self, et, ef):
        # t : 上面のラベル
        # f : 正面のラベル

        t = self.pos.index(et)  # 上面（の扱いになっている）のラベルを取得
        f = self.pos.index(ef)  # 前面（の扱いになっている）のラベルを取得
        
        # u,f,r
        dr = [(1,2,4,3),(0,3,5,2),(0,1,5,4),(0,4,5,1),(0,2,5,3),(1,3,4,2)]
        r = (dr[t].index(f) + 1) % 4
        print(self.pos[dr[t][r]])

d = dice([int(x) for x in input().split()])
q = int(input())
for i in range(q):
    d.right(*map(int, input().split()))


Measured memory_bytes: 5608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

ll n=0,m=0;
int main(){
    cin>>n>>m;
    vector<ll> x(m,0);
    ll sum=0;
    rep(i,m){
        cin>>x[i];
    }
    sort(x.begin(),x.end());
    vector<ll> y(m,0);
    rep(i,m){
        if(i!=0) y[i]=x[i]-x[i-1];
        sum += y[i];   
    }
    sort(y.begin(),y.end(),greater<int>());
    if(n>=m) sum=0;
    else {
        rep(i,n-1){
            sum -= y[i];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    // #ifndef ONLINE_JUDGE
	// 	freopen("test", "r", stdin);
	// #endif
    fastio;
    
    int N, M;
    cin >> N >> M;

    if(N % 2 == 1){
        repA(i, 1, M){
            cout << i << " " << N - i << endl;
        }
    }else{
        int mid = (M + 1) / 2;
        repA(i, 1, mid){
            cout << i << " " << N - i + 1 << endl;
        }
        repA(i, mid+1, M){
            cout << i << " " << N - i << endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3608
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();

		List<Character> list = new ArrayList<Character>();
		for (int i = 0; i < n; i++) {
			if (list.size() == 0) {
				list.add(s[i]);
				continue;
			}
			if (list.get(list.size() - 1).equals(s[i])) {
				continue;
			}
			list.add(s[i]);
		}
		System.out.println(list.size());
	}
}

Measured memory_bytes: 27476
#include<stdio.h>
#include<queue>
struct S{int x,y,h,c;}s,t;
int main()
{
	int w,h,i,j,k,V=9999,a[]={0,1,0,-1,0};
	while(scanf("%d%d",&w,&h),w)
	{
		int m[10][10]={0};
		int d[9][9][7];
		for(i=0;i<9;++i)for(j=0;j<9;++j)for(k=0;k<7;++k)d[i][j][k]=V;
		for(i=1;i<=h;++i)for(j=1;j<=w;++j)if(scanf("%d",&m[i][j]),m[i][j]==2)s.y=i,s.x=j;
		std::queue<S>q;
		s.c=0;
		s.h=6;
		q.push(s);
		while(q.size())
		{
			s=q.front();q.pop();
			if(d[s.y][s.x][s.h]<=s.c)continue;
			d[s.y][s.x][s.h]=s.c;
			if(m[s.y][s.x]==3)
			{
				printf("%d\n",s.c);
				goto E;
			}
			if(s.h<2)continue;
			for(i=0;i<4;++i)
			{
				t=s;
				t.x+=a[i];
				t.y+=a[i+1];
				if(m[t.y][t.x])
				{
					if(m[t.y][t.x]==4)t.h=6;
					else t.h--;
					t.c++;
					q.push(t);
				}
			}
		}
		puts("-1");
E:;
	}
	return 0;
}

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

ac = 0
wac = 0
count = [0 for x in range(n+1)]

for i in range(m):
  a , b = input().split()
  c = int(a)
  if count[c] >= 0:
    if b == "AC":
      ac += 1
      wac += count[c]
      count[c] = -1
    else:
      count[c] += 1

print(ac, wac)

Measured memory_bytes: 50720
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 while(1){
 ll h,w;
 cin>>h>>w;
 if( h==0 && w==0 ) break;
 vector<vector<ll> > e(h+2,vector<ll>(w+2,0) );
 for(ll i=1;i<=h;i++)for(ll j=1;j<=w;j++) cin>>e[i][j];
 ll res = 0;
 for(ll l=1;l<=h;l++){
  for(ll u=l+2;u<=h;u++){
   for(ll r=1;r<=w;r++){
    for(ll le=r+2;le<=w;le++){
     ll side = inf;
     ll inner = 0;
     for(ll i=l+1;i<u;i++)for(ll j=r+1;j<le;j++) inner = max( inner , e[i][j] );

     for(ll i=l;i<=u;i++) side = min( side , min( e[i][r] , e[i][le] ) );
     for(ll i=r;i<=le;i++) side = min( side , min( e[l][i] , e[u][i] ) );

     if( inner < side ){
      ll cnt = 0;
     for(ll i=l+1;i<u;i++)for(ll j=r+1;j<le;j++) cnt += side - e[i][j];

      res = max( res , cnt );
     }
    }
   }
  }
 }

 cout<<res<<endl;

 }
    return 0;
}



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

b = [0]*(n+2)
b[0] = 1

for i in range(m):
    b[int(input())] = -1

for i in range(n):
    if b[i] != -1:
        if b[i+1] != -1:
            b[i+1] += b[i]
        if b[i+2] != -1:
            b[i+2] += b[i]
        b[i] %= 1000000007

print(b[n]%1000000007)


Measured memory_bytes: 6900
parseint(x) = parse(Int, x)
ints() = map(parseint, readline() |> split)

function main()
    n, m = ints()
    s = [ints()[2:end] for _ = 1:m]
    sset = [Set{Int}(s[i]) for i = 1:m]
    p = ints()
    cnt = 0
    for i = 0:(1<<n)-1
        set = Set{Int}()
        for bit = 0:n-1
            if ((1<<bit) & i) != 0
                push!(set, bit + 1)
            end
        end
        b = true
        for j = 1:m
            c = 0
            for e in set
                if e in sset[j]
                    c = 1 - c
                end
            end
            if c != p[j]
                b = false
            end
        end
        if b
            cnt += 1
        end
    end
    println(cnt)
end

main()

Measured memory_bytes: 125140
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}

int myPow(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    return x * myPow(x, p-1);
}

int main() {
    int N,D;
    cin >> N>>D;
    vvi X = vvi(N,vi(D));

    map<Int,Int> pows;
    rep(i,10000){
        pows[i*i] = 1;
    }
    rep(i,N){
        rep(j,D){
            cin >> X[i][j];
        }

    }
    Int ans =0;

    rep(i,N){
        REP(k,i+1,N){
            int tmp =0;
            if(i==k){
                continue;
            }
            rep(j,D){
                tmp += myPow(X[i][j]-X[k][j],2);
            }
            if(pows[tmp] == 1){
                ans++;
            }
        }
    }



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

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

int main() {
  	int X, N;
  	cin >> X >> N;
  	int p[N];
  	for (int i = 0; i < N; i++) cin >> p[i];
  
  	bool flag[102];
  	for (int i = 0; i < 102; i++) flag[i] = false;
  
  	for (int i = 0; i < N; i++){
      	flag[p[i]] = true;
    }
  
  	int count = 10000;
  	int res = 100000;
  
  	for (int i = 0; i < 102; i++){
      	if (flag[i] == false){
          	if (count > abs(X - i)){
              	count = abs(X - i);
              	res = i;
            }
        }
    }
  
  	cout << res << endl;
}

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


int main() {
    int N;
    cin >> N;
    if(N%10 == 3)cout << "bon" << endl;
    else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 ==8) cout<<"pon"<<endl;
    else cout << "hon" << endl;



}

Measured memory_bytes: 3576
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>
#include <set>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	int d, t, s;
	cin >> d >> t >> s;
	if (s * t >= d) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

const int maxN=3010;
const int Mod=1e9+7;
const int inv2=500000004;

int n,Q,Seq[maxN];
int F[maxN][maxN],G[maxN][maxN];

void Plus(int &x,int y);
void Outp();
int main(){
    //freopen("in","r",stdin);
    scanf("%d%d",&n,&Q);
    for (int i=1;i<=n;i++) scanf("%d",&Seq[i]);
    for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) F[i][j]=Seq[i]<Seq[j];
    for (int qi=1;qi<=Q;qi++){
        int x,y;scanf("%d%d",&x,&y);
        if (x==y) continue;
        for (int i=1;i<=n;i++) if (i!=y&&i!=x){
            Plus(G[i][x],1ll*F[i][x]*inv2%Mod);Plus(G[i][y],1ll*F[i][x]*inv2%Mod);
            Plus(G[x][i],1ll*F[x][i]*inv2%Mod);Plus(G[y][i],1ll*F[x][i]*inv2%Mod);
        }
        for (int i=1;i<=n;i++) if (i!=x&&i!=y){
            Plus(G[i][y],1ll*F[i][y]*inv2%Mod);Plus(G[i][x],1ll*F[i][y]*inv2%Mod);
            Plus(G[y][i],1ll*F[y][i]*inv2%Mod);Plus(G[x][i],1ll*F[y][i]*inv2%Mod);
        }
        G[y][x]=G[x][y]=1ll*(F[x][y]+F[y][x])%Mod*inv2%Mod;
        for (int i=1;i<=n;i++) F[x][i]=G[x][i],F[i][x]=G[i][x],F[y][i]=G[y][i],F[i][y]=G[i][y];
        for (int i=1;i<=n;i++) G[x][i]=G[i][x]=G[y][i]=G[i][y]=0;
        //cout<<"after "<<qi<<endl;
        //Outp();
    }
    int Ans=0;
    for (int i=1;i<=n;i++) for (int j=1;j<i;j++) Plus(Ans,F[i][j]);
    for (int i=1;i<=Q;i++) Ans=2ll*Ans%Mod;
    printf("%d\n",Ans);return 0;
}
void Plus(int &x,int y){
    x+=y;if (x>=Mod) x-=Mod;return;
}
void Outp(){
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++)
            cout<<F[i][j]<<" ";cout<<endl;
    }
    return;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "yes" << endl;}
void no(){ cout << "no" << endl;}

//-----------------------------------------
//-----------------------------------------

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

  while(1){
    int a, b;
    char c;
    cin >> a >> c >> b;
    if(c=='+') cout << a + b <<endl;
    else if(c == '-') cout << a - b <<endl;
    else if(c == '*') cout << a * b <<endl;
    else if(c == '/') cout << a / b <<endl;
    else return 0;
  }



  return 0;
}






Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<ll> x(N),y(N),z(N);
	ll ans = 0;
	rep(i,N)cin >> x[i] >> y[i] >> z[i];
	int Sig[3];
	for(int i=0;i<(1<<3);i++){
		ll sums = 0;
		vector<ll> tmp;
		for(int j=0;j<3;j++){
			if((i>>j)&1)Sig[j] = 1;
			else Sig[j] = 0;
		}
		rep(a,N){
			ll sum = 0;
			if(Sig[0])sum+=x[a];
			else sum -=x[a];
			if(Sig[1])sum+=y[a];
			else sum -=y[a];
			if(Sig[2])sum+=z[a];
			else sum -=z[a];
			tmp.push_back(sum);
		}
		sort(ALL(tmp),greater<>());
		rep(a,M)sums += tmp[a];
		ans = max(ans,sums);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int dp[32768];
int main(void)
{
  cout << fixed << setprecision(10);
  for(;;){
    int n,m,k;
    cin >> n >> m >> k;
    if(!n&&!m&&!k) return 0;
    double answer=0.0;
    if(n==1){
      answer+=(LL)(m-k)*(m-k+1)/2;
      answer+=k;
      answer/=m;
      cout << answer << endl;
      continue;
    }
    REP(i,32768) dp[i]=0;
    dp[0]=1;
    REP(i,n){
      for(int i=20000;i>=0;--i){
	dp[i+1]+=dp[i];
	dp[i+m+1]-=dp[i];
	dp[i]=0;
      }
      REP(i,20000) dp[i+1]+=dp[i];
    }
    REP(i,20000) answer+=max(1,i-k)*dp[i];
    REP(i,n) answer/=m;
    cout << answer << endl;

  }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll dp1[333][333*333];
ll dp2[333][333*333];

void modadd(ll &a, ll b){
    a += b;
    a %= MOD;
}

void cal_dp1(vector<int> v){
    dp1[0][0] = 1;
    int n = v.size();
    REP(i, n){
        REP(j, 333*333)if(dp1[i][j]){
            modadd(dp1[i+1][j], dp1[i][j] * 2);
            modadd(dp1[i+1][j + v[i]], dp1[i][j]);
        }
    }
}

void cal_dp2(vector<int> v){
    dp2[0][0] = 1;
    int n = v.size();
    REP(i, n){
        REP(j, 333*333)if(dp2[i][j]){
            modadd(dp2[i+1][j], dp2[i][j]);
            modadd(dp2[i+1][j + v[i]], dp2[i][j]);
        }
    }
}
int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

    int n;cin >> n;
    ll sum = 0;
    vector<int> v(n);
    REP(i, n)cin >> v[i], sum += v[i];
    cal_dp1(v);
    cal_dp2(v);

    ll A = 1;
    ll B = 0;
    ll C = 0;
    REP(i, n)A = (A * 3) % MOD;
    REP(i, 333*333)if(i >= (sum+1) / 2)modadd(B, dp1[n][i]);
    if(sum % 2 == 0)C = dp2[n][sum / 2];

    ll ans = (10LL * MOD + A - 3 * B + 3 * C) % MOD;
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 524544
// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
#include <map>
#include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define sz(a) (int)(a.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin>>n;
    if(n%11 && n%11 <= 6) {
        cout<<2*((n+10)/11) - 1;
    }
    else {
        cout<<2*((n+10)/11);
    }

    return 0;
}   

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

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

void solve()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt=0;
	string t="";
	for(ll i=0;i<n;i++)
	{
		if(s[i]==')' && cnt==0)
			t='('+t;
		else if(s[i]==')') 
			cnt--;
		else	
			cnt++;
		t+=s[i];
	}
	while(cnt>0)
	{
		t+=')';
		cnt--;
	}
	cout<<t;
	return;
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	int i, a, b;
	cin >> a >> b;
	if(a<b){
		for(i=1; i<=b; i++){
			cout << a;
		}
		cout << endl;
	}
	else{
		for(i=1; i<=a; i++){
			cout << b;
		}
		cout << endl;
	}
	 return 0;
 }
	


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

public class Main{
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), M = sc.nextInt();
    int X = sc.nextInt(), Y = sc.nextInt();
    int maxX = X, minY = Y;
    for(int i = 1; i<=N; i++){
      int x = sc.nextInt();
      maxX = Math.max(x, maxX); 
    }
    for(int i = 1; i<=M; i++){
      int y = sc.nextInt();
      minY = Math.min(y, minY);
    }
    if(maxX < minY){
      System.out.println("No War"); 
    }
    else{
      System.out.println("War");
    }
  }
}


Measured memory_bytes: 27196
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll v(5);
        rep(i, 0, 5) cin >> v[i];
        ll mn = *min_element(all(v));
        ll tmp = N / mn;
        if (N % mn != 0) ++tmp;
        cout << tmp + 4 << endl;
}

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

    int n;
    cin >> n;

    vector<long long> A(5, 0);
    REP(i, n){
        string s;
        cin >> s;
        if(s[0] == 'M') A[0]++;
        if(s[0] == 'A') A[1]++;
        if(s[0] == 'R') A[2]++;
        if(s[0] == 'C') A[3]++;
        if(s[0] == 'H') A[4]++;
    }

    long long ans = 0;
    for(int i = 0; i < 3; i++){
        for(int j = i + 1; j < 4; j++){
            for(int k = j + 1; k < 5; k++){
                ans += A[i] * A[j] * A[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll X; cin >> X;
  ll x = 0, t = 1;
  while(x < X){
    x += t;
    t++;
  }
  t--;
  cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  	
	int n;
  	cin >> n;
  	vi x(n);
  	rep(i,n){cin >> x[i];}
  	vi ans(100);
  	fill(all(ans),0);
  	int kari;
  	rep(i,100){rep(j,n){kari = x[j]-(i+1);ans[i]+=kari*kari;}}
  	cout << minel(ans) << endl;
  	return 0;
}

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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (1 <= N <= 10000 && 0 <= A <= 1000 && N % 500 <= A){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		int list[] =  {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};		
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		System.out.println(list[k-1]);
		
	}
}

Measured memory_bytes: 23380
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

//    slld(testcase);

//    for(ll cs = 1; cs <= testcase; cs++)
    {
		cin >> input;

		cout << input + (input * input) + (input * input * input) << '\n';
    }


}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll ret = 0;
    if (a >= k) {
        cout << k << endl;
        return;
    } else {
        ret = a;
    }

    if ((k - a - b) <= 0) {
        cout << ret << endl;
        return;
    }
    ret -= (k - a - b);
    cout << ret << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

LL dp[10000000L+2] = {0};
int p[10000000+2] = {0};

long long N;
vector<LL> PR;

void PINIT(long long n){
	for(int i=2; i<=n; i++){
		if(p[i] > 0) continue;
		for(int j=2; i*j <= n; j++){
			p[i*j]++;
		}
	}
	for(int i=2; i<=n; i++){
		if(p[i] == 0){
			dp[i] = 2;
			PR.push_back((long long)i);
		}
	}
}

LL f(LL x, LL p){
	if(x == 1) return 1;
	if(dp[x] > 0) return dp[x];

	LL ret = 1;
	if(p == 0){
		for(int i=0; i<PR.size(); i++){
			if((x % PR[i]) == 0){
				p = PR[i];
				break;
			}
		}
	}
	int e = 1;
	LL tmp = x;
	while(true){
		tmp = tmp / p;
		if((tmp % p) !=0){
			break;
		}
		e++;
	}
	ret = f(tmp, 0) * (e + 1);
	dp[x] = ret;
	return ret;
}

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

	cin >> N;

	PINIT(N);
	long long ans = 0;
	for(int k=1; k<=N; k++){
		ans += (k * f(k, 0));
	}
	printf("%lld\n", ans);
	return 0;

}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll H, W, N;
    cin >> H >> W >> N;
    pll s;
    cin >> s.first >> s.second;
    s.first--;
    s.second--;
    string S, T;
    cin >> S >> T;

    //! 高橋が左右から脱出できるか見る
    bool e = false;
    ll wr = s.second;
    ll wl = s.second;
    REP(i, N)
    {
        //! 高橋の手番
        if (S[i] == 'L')
        {
            wl--;
        }
        else if (S[i] == 'R')
        {
            wr++;
        }

        if (wr >= W)
            e = true;
        if (wl < 0)
            e = true;
        //if (w < 0 || w >= W)
        //    e = true;

        //! 青木の手番
        if (T[i] == 'L')
        {
            wr = std::max(0LL, wr - 1);
        }
        else if (T[i] == 'R')
        {
            wl = std::min(W - 1, wl + 1);
        }
    }

    //! 高橋が上下から脱出できるか
    ll hu = s.first;
    ll hd = s.first;
    REP(i, N)
    {
        //! 高橋の手番
        if (S[i] == 'U')
        {
            hu--;
        }
        else if (S[i] == 'D')
        {
            hd++;
        }

        if (hu < 0 || hd >= H)
            e = true;
        // if (h < 0 || h >= H)
        //    e = true;

        //! 青木の手番
        if (T[i] == 'U')
        {
            hd = std::max(0LL, hd - 1);
        }
        else if (T[i] == 'D')
        {
            hu = std::min(H - 1, hu + 1);
        }
    }

    if (e)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776
/*input
8 4
9 1 8 2 7 5 6 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=1005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn];
vector<ll> v;

ll pre[42][maxn];

bool tg[1000005];

int main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	REP(i,n) cin>>a[i];
	REP(i,n){
		ll cur=0;
		for(int j=i;j<n;j++){
			cur+=a[j];
			v.pb(cur);
		}
	}
	sort(ALL(v));
	int m=SZ(v);
	//for(int i:v) cout<<i<<'\n';
	ll ans=0;
	for(int i=41;i>=0;i--){
		int cnt=0;
		REP(j,m) if(!tg[j]) if(v[j]&(1LL<<i)) cnt++;
		if(cnt<k);
		else{
			REP(j,m) if((v[j]&(1LL<<i))==0)  tg[j]=1;
			ans^=(1LL<<i);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 6512
# 解説AC 包除原理 外側を数えるのが難しいとき, 完全順列
n, m = map(int, input().split())
mod = 10 ** 9 + 7


def table():
    k = 5 * 10**5 + 5  # 変える
    fac = [1] * k
    finv = [1] * k
    inv = [0] * k
    inv[1] = 1
    for i in range(2, k):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


fac, finv = table()


def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def perm(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * finv[n - k] % mod


res = 0
sgn = 1
for i in range(n + 1):
    res += sgn * perm(m - i, n - i) * comb(n, i)
    res %= mod
    sgn *= -1
print(perm(m, n) * res % mod)


Measured memory_bytes: 68188
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define INF (1LL<<62)

LL slv(LL x,LL y,LL s)
{
    LL X = x/2,Y = y/2;
    return min (
        max( max(abs(X*y-s),abs((x-X)*y-s)), abs(X*y-(x-X)*y) ),
        max( max(abs(x*Y-s),abs((y-Y)*x-s)), abs(Y*x-(y-Y)*x) )
    );
}

int main()
{
    LL h,w;
    cin>>h>>w;
    LL ans = INF;
    for (int i=1;i<=h;i++)
        ans = min (ans,slv(h-i,w,i*w));
    for (int i=1;i<=w;i++)
        ans = min (ans, slv(w-i,h,i*h));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
#define fl(i,a,n) for(int i=a;i<=n;i++)
#define pb push_back
#define pob pop_back
#define int long long int
#define ff first
#define ss second
#define pi 3.1415926535898
#define vi vector<int>
#define mi map<int,int>
#define umi unordered_map<int,int>
#define endl "\n"
#define w(x) int x; cin>>x; while(x--)
#define db(x) cout<<(#x)<<" "<<(x)<<"\n";
#define db2(x,y) cout<<(#x)<<" "<<(x)<<" ,"<<(#y)<<" "<<(y)<<"\n";
#define db3(x,y,z) cout<<(#x)<<" "<<(x)<<" ,"<<(#y)<<" "<<(y)<<" ,"<<(#z)<<" "<<(z)<<"\n";
#define print(a) for(auto x:a){cout<<x<<" ";}
#define ios ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
//using namespace boost::multiprecision;
int mod = 1000000007;
int gcd(int a, int b) {
    return (b == 0) ? a : gcd(b, a % b);
}
int lcm(int a, int b) {
    return (a * b) / gcd(a, b);
}
template<class type>
type power(type x, int n) {
    type temp; int y = n;
    if (y == 0) return 1;
    temp = power(x, y / 2);
    return ((y % 2) ? ((y > 0) ? x * temp * temp : (temp * temp) / x) : temp * temp);
}
void c_p_c() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {

    ios
    //c_p_c();
    //w(t)
    {
        int n,k;cin>>k>>n;
        vi v(n);
        fl(i,0,n-1){
            cin>>v[i];
        }
        sort(v.begin(),v.end());
        int mx=INT_MIN;
        fl(i,1,n-1){
            mx=max(mx,abs(v[i]-v[i-1]));
        }
         mx=max(mx,abs(k-v[n-1]+v[0]));
         cout<<k-mx<<endl;

    }

    return 0;
}
//ctrl+option+F to auto format- sublimeastyleformat package


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int a,b,c,hoge,s=0,r=0;
    while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
        if(a*a+b*b==c*c)s++;
        if(a==b)r++;
    }
    printf("%d\n%d\n",s,r);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n, m, l=0, r=INF;
    cin >> n >> m;
    vector<ll> a(200000,0);
    rep(i,m){
        ll a, b;
        cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }
    cout << max(0LL, r-l+1) << endl;
    return 0;
}

Measured memory_bytes: 4816
def main():
    grid = []
    height, width = map(int, input().split())
    grid.append(["."] * (width + 2))
    search_directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
    for _ in range(height):
        grid.append(["."] + list(input()) + ["."])
    grid.append(["."] * (width + 2))
    for i in range(1, height + 1):
        for j in range(1, width + 1):
            if grid[i][j] == ".":
                count_bomb = 0
                for dir in search_directions:
                    if grid[i + dir[0]][j + dir[1]] == "#":
                        count_bomb += 1
                grid[i][j] = str(count_bomb)
    for i in range(1, height + 1):
        print("".join(grid[i][1:-1]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
function Main(input: any) {
  let nums = input.split('\n')[1].split(' ')
  console.log(Math.min(...nums.map(process)))
}

function process(num) {
  let count = 0
  while ((num % 2) === 0) {
    num = num / 2
    count = count + 1
  }
  return count
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N),B(N),C(N);
  rep(i,N) {
    cin >> A[i];
  }
  rep(i,N) {
    cin >> B[i];
  }
  rep(i,N) {
    cin >> C[i];
  }
  sort(rng(A));
  sort(rng(B));
  sort(rng(C));
  ll ans = 0;
  rep(i,N) {
    auto a = lower_bound(rng(A),B[i]);
    auto c = upper_bound(rng(C),B[i]);
    ans += distance(A.begin(),a) * (N - distance(C.begin(),c));
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1408