akhauriyash/Code-Regression huggingface dataset:
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
int n,m,x;
cin>>n>>m>>x;
vi c(n);
vvi inc(n);
forn(i,n)
{
cin>>c[i];
forn(j,m)
{
  int y;
  cin>>y;
  inc[i].pb(y);
}

}
i64 mn=INT_MAX;
forn(i,(1<<n))
{
  vi tmp(m,0);
  i64 tt=0;
  forn(j,n)
  {
    if(i&(1<<j))
    {
      tt+=c[j];
      forn(k,m)
      {

        tmp[k]+=inc[j][k];
      }
    }
  }
  bool is=true;

  forn(j,m)
  {
    if(tmp[j]<x)is=false;
  }
  if(is)uin(mn,tt);
}
if(mn!=INT_MAX)
cout<<mn;
else cout<<-1;


    return 0;
  }


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    char c;
    cin>>c;
    c++;
    cout<<c<<endl;
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(0, min(b, d) - max(a, c)) << endl; // 賢い…
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)50;
using namespace std;

int main()
{
	int n; cin >> n;
	int a, b;
	if(n & 1) a = (n + 1) / 2;
	else a = n / 2;
	b = n / 2;
	cout << a * b << endl;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	int Alice = 0;
	int Bob = 0;
	rep(i,n){
		if(i%2 == 0) Alice += a[i];
		else Bob += a[i];
	}
	cout << Alice - Bob << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <bitset>
#include <map>

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

using namespace std;

int main() {
    int K, Y;
    vector<int> kane(3, -1);
    scanf("%d %d", &K, &Y);
    int yen = Y;
    for (int m = 0; m <= K; m++) {
        for (int g = 0; g <= K - m; g++) {
            int yen = Y - ((10000 * m) + (5000 * g));
            if (yen % 1000 == 0 && yen / 1000 == K - (m + g)) {
                kane[0] = m;
                kane[1] = g;
                kane[2] = K - (m + g);
            }
        }
    }
    cout << kane[0] << " " << kane[1] << " " << kane[2] << endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sp <<" "<<
bool isprime(ll n){
    if (n <= 1)return false;ll g=sqrt(n);
    for (ll i = 2; i <= g; i++)if (n % i == 0)return false;
    return true;
}
ll MOD=LLONG_MAX;
ll power(ll base, ll exp)
{
    if(exp==1)return base;
    else{if(exp%2==0){ll base1=(pow(power(base, exp/2),2));return base1%MOD;}
        else{ll ans=(base*pow(power(base,(exp-1)/2),2));return ans%MOD;}}
}
int temp,temp1,temp2;
int main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s,t;
    int res=INT_MAX;
    cin>>s>>t;
    int n=s.length(),nt=t.length();
    for(int i=0;i+nt<n+1;i++)
    {
        temp=0;
        for(int j=0;j<nt;j++)
        {
            if(s[i+j]!=t[j])
                temp++;
        }
        if(temp<res)
            res=temp;
    }
    cout<<res;
    
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

vector<lli> g[N];
lli ans ;
lli n, k;

void dfs(lli u, lli p) {

    lli avl = k - 1;
    if(p != -1) {
        avl --;
    }

    for(auto it : g[u]) {
        if(it == p) {
            continue ;
        }
        ans *= max(avl, 0LL);
        ans %= mod;
        avl --;
        dfs(it, u);
    }
    return ;
}

void solve()
{

    cin>>n>>k;
    for(int i = 0; i < n - 1; i ++ ) {
        lli a, b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ans = k;

    dfs(1, -1);

    cout<<ans;

    cout<<"\n";
    return ;
}

/*
*/

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

long long int Min(long long int a,long long int b){
    if(a>b)
        return b;
    else
        return a;
}

int main(){
    long long int n,ans=0,i,f=0;

    scanf("%lld",&n);
    for(i=2;i<=sqrt(n);i++){
        if(n%i == 0){
            if(f==0){
                ans = i+n/i-2;
                f=1;
                continue;
            }
            ans = Min(ans,(i+n/i-2));
        }
    }
    if(ans == 0)
        printf("%lld",n-1);
    else
        printf("%lld",ans);

}


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

const ll MOD = 1e9 + 7;
ll fact[211111];

ll inv(ll x) {
    ll res = 1, p = MOD - 2;
    while(p) {
        if(p & 1) res = (res * x) % MOD;
        x = (x * x) % MOD;
        p /= 2;
    }
    return res;
}

ll c(ll n, ll k) {
    return ((fact[n] * inv(fact[k]) % MOD) * inv(fact[n - k])) % MOD;
}

ll ways(ll n, ll m) {
    return c(n + m - 2, m - 1);
}

int main() {
    fact[0] = 1;
    for(ll i = 1; i < 211111; i++) 
        fact[i] = (i * fact[i - 1]) % MOD; 
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    ll ans = ways(H, W);
    for(int i = 0; i < A; i++) {
        ans = (ans - ways(H - A + 1 + i, B) * ways(A - i, W - B) % MOD+ MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
print(n*(n-1)//2-n//2)

for i in range(n):
    a = n-1-i if n%2 == 0 else n-2-i
    for j in range(i+1,n):
        if j != a:
            print(i+1,j+1)

Measured memory_bytes: 3612
#include "bits/stdc++.h" 
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rerep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll xa=min(a,k);
    k-=xa;
    ll xb=min(b,k);
    k-=xb;
    ll xc=min(c,k);
    cout<<xa-xc<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {

	int a, b, t, biscuit;
  	cin >> a >> b >> t;
  	
  	for(int i = 1; i <= t; i++){
      if(i % a == 0)
      biscuit += b;
    }
	cout << biscuit << endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=200000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n;
char s[N];

int main()
{
    scanf("%s",s+1);n=strlen(s+1);
    int cnt=0;ll ans=0;
    rep(i,1,n)
    {
        if (s[i]=='B') cnt++;
        else ans+=cnt;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4000
from decimal import * 
import math
a,b,x = map(int,input().split())
X = x/a
P = X /(a*b)
if P >= 0.5 :
    print(math.degrees(math.atan((2*b*(1-P)/a))))
else:
    print(math.degrees(math.atan((a*b**2/(2*x)))))

Measured memory_bytes: 5076
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int N,M,Lx=0,Rx=1000000000,r=0;
    cin>>N>>M;
    int L,R;
    for(int i=0;i<M;i++){
        cin>>L>>R;
        Lx=max(L,Lx);
        Rx=min(R,Rx);
    }
    for(int i=Lx;i<=Rx;i++){
        r++;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)

signed main(){
    fast

    int n,d;
    cin>>n>>d;
    int c=0;
    f0(i,0,n)
    {
        int a,b;
        cin>>a>>b;
        if((a*a+b*b)<=d*d)c++;
    }cout<<c<<endl;
}

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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  int sum = a*100 + b*10 + c;
  if(sum%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef long long int64;

int main() {
  int a, b, c;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);

  int remain_a = a - b;
  if(remain_a > 0){
    c -= remain_a;
  }

  if(c > 0) printf("%d\n",c);
  else printf("0\n");

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0; //これはmax
    for (auto p : mp)
        mx = max(mx, p.second);
    for (auto p : mp){
        if (mx == p.second)
            cout << p.first << endl;
    }

    return 0;
}

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


int main(){
    int n;cin>>n;
    vector<long long> nums(n); for(int i=0;i<n;i++){cin >> nums[i];}
    int acc = 0;
    for (auto v:nums){
        acc += v - 1;
    }
    cout << acc << endl;
    return 0;

}

Measured memory_bytes: 256
// G - Longest Path
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int in(){int x;cin>>x;return x;}

#define MAX 100000
vvi V(MAX);
vi D(MAX,-1);
int N,M;

int dfs(int);

int to_child(vi v){
	int ans = 0;
	for(int c:v) ans = max(ans, dfs(c)+1);
	return ans;
}

int dfs(int p){
	if(D[p]>-1 || V[p].size()<=0) return D[p];
	return D[p] = to_child(V[p]);
}

int main(){
	cin>>N>>M;
	while(M--) V[in()-1].push_back(in()-1);
	vi r; while(N--) r.push_back(N);
	cout<< to_child(r) <<endl;
}

Measured memory_bytes: 17144
#!/usr/bin/env python3
import sys
import math


def solve(N: int, K: int):
    s = max(0, N - K + 1) / N
    for k in range(1, min(N+1, K)):
        current_order = math.ceil(math.log(K / k, 2))
        s += (1 / 2) ** current_order / N
    print(s)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Long> list = new ArrayList<>();
        int h = sc.nextInt(), w = sc.nextInt();
        for (int i = 0; i < w; i++) {
            list.add(sc.nextLong());
            h -=list.get(i);
        }
        System.out.println (h < 0 ? -1 : h);
    }
}


Measured memory_bytes: 46496
//@source : 
//@create : 23:27:56 Monday 29/06/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int k, n;
    cin >> n >> k;
    vector<int> p(n);
    for (auto &i: p) {
        cin >> i;
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += p[i];
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    while (t--) {
        solve();
    }
    cerr << fixed << setprecision(5) << double(clock()) * 1000 / CLOCKS_PER_SEC << " ms\n";
  // return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 100000;
int n, m, q, v[M], d[M], c[M];
vector<int> g[M];
pair<int, int> ans[M];

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	cin >> q;
	inc(i, q) { cin >> v[i] >> d[i] >> c[i]; v[i]--; }
	
	inc(i, n) { ans[i] = MP(-1, -1); }
	dec(i, q) {
		queue<pair<int, int>> que;
		que.emplace(v[i], d[i]);
		while(! que.empty()) {
			auto p = que.front(); que.pop();
			if(p.SE < 0) { continue; }
			if(i <= ans[p.FI].FI && p.SE <= ans[p.FI].SE) { continue; }
			setmax(ans[p.FI].FI, i);
			setmax(ans[p.FI].SE, p.SE);
			for(auto && e: g[p.FI]) { que.emplace(e, p.SE - 1); }
		}
	}
	inc(i, n) { cout << (ans[i].FI == -1 ? 0 : c[ans[i].FI]) << "\n"; }
	
	return 0;
}


Measured memory_bytes: 8952
s = list(input())
w_len = len(s)
word = []
for x in range(w_len):
  if s[x] == 'B':
    if word != []:
      word.pop(-1)
  else:
    word.append(s[x])
result = ''
for y in word:
  result = result+y
print(result)

Measured memory_bytes: 9040
import java.util.*;
class Main{
    public static void main(String[] a){
        Scanner sc=new Scanner(System.in);
        long k=sc.nextLong();
        for(int i=0;i<51;i++) System.out.print(i<1?50+"\n":(k/50+(i<51-k%50?49:100)-k%50)+" ");
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int l, r, d;
  cin >> l >> r >> d;

  int l_d = l / d;
  if(l % d == 0) {
    l_d--;
  }
  int r_d = r / d;
  cout << r_d - l_d << endl;
}

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

using namespace std;

int N;
int hit(int k, int i) {
    assert(0 <= k && k < N);
    assert(i == 1 || i == 10);
    return 1 << (2 * k + (i == 1 ? 0 : 1));
}

typedef long long LL;

int main(){
    while(cin >> N && N > 0){
        vector<int> low(N);
        vector<int> high(N);
        REP(i, N) cin >> low[i] >> high[i];
        LL ans = 0;

        for(int len = N; len <= 2 * N; len++) {
            static LL dp[20][20][1 << 12] = {};
            memset(dp, 0, sizeof(dp));

            REP(x, 10) if(x > 0) {
                int s = hit(0, 10);
                if(low[0] <= x && x <= high[0]) {
                    s |= hit(0, 1);
                }
                dp[1][x][s] = 1;
            }

            REP(i, len) if(i > 0) REP(x, 10) REP(s, 1 << (2 * N)) if(dp[i][x][s] > 0) REP(y, 10) {
                int ns = 0;
                REP(k, N - 1) if(s & hit(k, 1)) {
                    // 10
                    if(y > 0) ns |= hit(k + 1, 10);
                    // 1
                    if(low[k + 1] <= y && y <= high[k + 1]) {
                        ns |= hit(k + 1, 1);
                    }
                }
                REP(k, N) if(s & hit(k, 10)) {
                    assert(x != 0);
                    int d = x * 10 + y;
                    if(low[k] <= d && d <= high[k]) {
                        ns |= hit(k, 1);
                    }
                }
                // printf("(%d, %d, %x) -> (%d, %d, %x) : %d\n", i, x, s, i + 1, y, ns, dp[i][x][s]);
                dp[i + 1][y][ns] += dp[i][x][s];
            }

            LL subans = 0;
            REP(x, 10) REP(s, 1 << (2 * N)) if(s & hit(N - 1, 1)) {
                subans += dp[len][x][s];
            }
            // cout << len << " " << subans << endl;
            ans += subans;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 14000
import java.util.Scanner;

import java.util.Arrays;
import java.util.ArrayList;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A>=13) {
			System.out.println(B);
		}
		else if(A>=6) {
			System.out.println(B/2);
		}
		else {
			System.out.println(0);
		}
	}
}	


Measured memory_bytes: 21716
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007
#define MAX 1000000000000000000

ll n,ans=0;
vector<ll> a(n);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
//     if (A.size() == n) {
//         return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

int main(){
  ll n;
  cin>>n;
  a.resize(n); 
  vector<ll> b(n);
  rep(i,n){
    cin>>a[i];
    if(a[i]==0){
      cout<<0;
      return 0;
    }
    b[i]=a[i];
  }
  

ll ans=1,count=0;
  rep(i,n){
    while(true){
      if(b[i]>=10){
        b[i]/=10;
        count++;
      }else{
        break;
      }
    }
  }
  
  if(count<18){
    rep(i,n){
      if(ans*a[i]>MAX){
        ans=-1;
        break;
      }
      ans*=a[i];
    }
    cout<<ans<<endl;
  }else{
    rep(i,n){
      if(ans*a[i]==MAX){
        cout<<MAX;
        return 0;
      }
      ans*=a[i];
    }
    cout<<-1<<endl;
  }
  

  //cout<<ans;


  return 0;
}


Measured memory_bytes: 4792
N = int(input())
P = list(map(float, input().split()))
memo = [[0 for j in range(N+1)] for i in range(N)]

memo[0][0] = 1 - P[0]
memo[0][1] = P[0]

for i in range(1, N):
    memo[i][0] = memo[i-1][0] * (1 - P[i])
    for j in range(1, i+2):
        memo[i][j] = memo[i-1][j-1] * P[i]
        memo[i][j] += memo[i-1][j] * (1 - P[i])
            
print(sum(memo[-1][N//2+1:]))


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

namespace ABC168C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int H = int.Parse(input[2]);
            int M = int.Parse(input[3]);
            //Console.WriteLine(H);
            double pi = 3.1415926535897931;
            double hrad = 30.0 * H / 180.0 * pi + 0.5 * M / 180.0 * pi;
            double mrad = 6.0 * M / 180.0 * pi;
            //Console.WriteLine(hrad);
            //Console.WriteLine(mrad);
            double rad = Math.Abs(hrad - mrad);
            double ans2 = A * A + B * B - 2 * A * B * Math.Cos(rad);
            double ans = Math.Sqrt(ans2);
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 27936
#include <cstdio>

const int p=1000000007;

int i,n,l,r,s,t,w;

inline int calc(int x)
{
	if (x<10) return 1;
	if (x<100) return 2;
	if (x<1000) return 3;
	if (x<10000) return 4;
	if (x<100000) return 5;
	if (x<1000000) return 6;
	if (x<10000000) return 7;
	return 8;
}

inline int power(int x,int y)
{
	int s=1;
	for (int i=30;i>=0;i--)
	{
		s=1LL*s*s%p;
		if ((1<<i)&y)
			s=1LL*s*x%p;
	}
	return s;
}

int main()
{
	scanf("%d",&n);
	for (i=8;i<=n;i++)
	{
		if (! (n%i))
			s=(s+9LL*power(10,i-1)-(n/i)%p+p)%p;
		if (n>=1LL*(n%i)*(i+1))
			s=(s+((n-(n%i)*(i+1))/i+i)/(i+1))%p;
	}
	t=0;
	for (l=1,r=1;calc(l)<=7;l++)
	{
		for (;t<n;r++)
			t=t+calc(r);
		if (t==n)
			s++;
		t=t-calc(l);
	}
	printf("%d",s%p);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
vector<ll>a[100005];
ll dp[100005][2];
ll mod=1e9+7;
void dfs(int i,int par)
{
  dp[i][0]=1;dp[i][1]=1;
  trav(x,a[i])
  {
    if(x!=par)
    {
      dfs(x,i);
      dp[i][0]*=dp[x][1];
      dp[i][0]%=mod;
      dp[i][1]*=dp[x][0]+dp[x][1];
      dp[i][1]%=mod;
    }
  }
}
void solve()
{
  ll n;
  cin>>n;
  ll p,q;
  //rep(i,n){dp[i][0]=1;}
  rep(i,n-1){cin>>p>>q; a[p].pb(q);a[q].pb(p);}
  //repA(i,1,n+1){if(a[i].size()==1){l=i;break;}}
  dfs(1,-1);
  cout<<(dp[1][0]+dp[1][1])%mod;

}
int main()
{
  fastio;
  //fopen();
  int t;
  //cin>>t;
  rep(i,1)
  { 
    solve();
    cout<<endl;
  }
  
}


Measured memory_bytes: 11520
<?php

fscanf(STDIN,"%d",$n);

$value = explode(" ", trim(fgets(STDIN)));
$cost = explode(" ", trim(fgets(STDIN)));

$ans=0;
for($i=0;$i<$n;$i++){
    $getvalue = $value[$i] - $cost[$i];
    if($getvalue > 0){
        $ans+=$getvalue;
    }
}

echo $ans;

Measured memory_bytes: 4604
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b); 
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	ll n, t, r = 1;
	scanf("%lld", &n);
	REP(i, n) {
		scanf("%lld", &t);
		r = Llcm(t, r);
	}
	printf("%lld", r);
	return 0;
}

Measured memory_bytes: 128
x, y = gets.split.map(&:to_i)

result = []
for i in 0..x
  if i * 4 + (x - i) * 2 == y
    result << 'OK'
  end
    result << 'NG'
end

if result.any? 'OK'
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14316
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){

    int k, a, b;
    cin >> k >> a >> b;
    bool flag = false;
    FOR(i,a,b + 1){
        if(i % k == 0){
            flag = true;
            break;
        }
    }
    if(flag)
        cout << "OK" << endl;
    else
    {
        cout << "NG" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://agc010.contest.atcoder.jp/tasks/agc010_a>
 問題文============================================================
 黒板に N 個の整数が書かれています。i 番目の整数は Ai です。
 
 これらの数に対して、高橋君は以下の操作を繰り返します。
 
 偶奇が等しい 2 つの数 Ai,Aj を一組選び、それらを黒板から消す。
 その後、二つの数の和 Ai+Aj を黒板に書く。
 
 最終的に黒板に数が 1 つだけ残るようにできるかどうか判定して下さい。
 
 =================================================================
 
 解説=============================================================
 
 even + even = even
 odd + odd = even
 より、
 
 oddはいずれevenに変わる
 ここで、数字が全て偶数であれば、黒板の数字は一つずつ減っていくだけなので、存在すればYES
 よって、oddの個数にだけ気をつければ良い
 
 odd is even then
 yes
 else then
 no
 
 ただし、evenが存在せず、初めからoddが唯一１個であればyes
 ================================================================
 */
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N);
    int eo[2] = {0};
    for(auto& in:A) {
        cin >> in;
        eo[in%2]++;
    }
    if(eo[1]%2 == 0){
        cout << "YES" << endl;
    }else{
        if(eo[1] == 1 && eo[0] == 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);

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

int main() {

	int N;
	cin >> N;
	
	vector<int>A(N);

	REP(i, N) cin >> A[i];

	vector<int> left(N + 1, 0);
	vector<int> right(N + 1, 0);

	for (int i = 0; i < N; i++) left[i + 1] = GCD(left[i], A[i]);//左から left[i+1]→A[i]までのgcd
	for (int i = N - 1; i >= 0; i--) right[i] = GCD(right[i+1], A[i]);//右から right[i]→A[i]までのgcd

	vector<int>ans(N);

	for (int i = 0; i < N; i++) {
		int l = left[i];//A[i-1]までのgcd
		int r = right[i + 1];//A[i+1]までのgcd
		ans[i] = GCD(l, r);
	}

	int maxnum = 0;
	REP(i, N) {
		maxnum = max(maxnum, ans[i]);
	}

	cout << maxnum << endl;

	return 0;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n;
  cin>>n;
  set<int> set;
  rep(i,n){
    int x;
    cin>>x;
    set.insert(x);
  }
  int q;
  cin>>q;
  int ans=0;
  while(q--){
    int x;
    cin>>x;
    ans+=(set.find(x)!=set.end());
  }

  cout<<ans<<endl;


}


Measured memory_bytes: 3140
_, _, c=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
a=$<.map{|m|m.split.map(&:to_i)}
p a.select {|m| [b,m].transpose.map{|m| m[0]*m[1]}.inject(:+) + c > 0 }.size

Measured memory_bytes: 1788
import numpy as np


s = input()
size = len(s)

num = 0
for i in range(2**(size-1)):
    sp = np.array([(i >> j) & 1 for j in range(size)])
    st = ''.join([k + (' ' if sp[j] == 1 else '') for j, k in enumerate(s)])
    x = map(int, st.split())
    num += sum(x)
print(num)

Measured memory_bytes: 12504
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N, M;

void solve()
{
  set<int> candidate;
  for (int i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      candidate.insert(i);
      candidate.insert(M / i);
    }
  }
  int ans = 0;
  for (auto c : candidate) {
    if (M / N >= c) ans = max(ans, c);
  }
  cout << ans << endl;
}

int main(void)
{
  cin >> N >> M;
  solve();
  return 0;
}


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

using namespace std;

int main() {
	char s[4];
	for (int i = 0; i < 4; ++i) scanf("%c", &s[i]);
	sort(s, s+4);
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes";
	else cout << "No";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll INF = 1LL <<50;

int main(){
  int n,m;
  cin>>n>>m;
  int a[2000],b[2000];
  ll c[2000];

  rep(i,m){
    cin>>a[i]>>b[i]>>c[i];
    c[i] = -c[i];
  }

  ll dist[2000];
  rep(i,n){
    dist[i] = INF;
  }

  dist[0] = 0;

  rep(i,n-1){
    rep(j,m){
      if(dist[a[j]-1]==INF) continue;

      if(dist[b[j]-1]>dist[a[j]-1]+c[j]){
        dist[b[j]-1] = dist[a[j]-1]+c[j];
      }
    }
  }

  ll ans = dist[n-1];
  bool neg[2000] ={};

  rep(i,n){
    rep(j,m){
      if(dist[a[j]-1]==INF) continue;
      if(dist[b[j]-1]>dist[a[j]-1]+c[j]){
        dist[b[j]-1] = dist[a[j]-1]+c[j];
        neg[b[j]-1] = true;
      }
      if(neg[a[j]-1]){
        neg[b[j]-1] = true;
      }
    }
  }

  if(neg[n-1])
    cout<<"inf"<<endl;
  else
    cout<<-ans<<endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int t;
int h, w, n;
string field[100];
string s;
P pos;

void solve(char c){
	int y = pos.first, x = pos.second;
	if (c == 'U'){
		if (y != 0){
			if (field[y - 1][x] == '.'){
				field[y - 1][x] = '^';
				field[y][x] = '.';
				y--;
			}
			else field[y][x] = '^';
		}
		else field[y][x] = '^';
	}
	else if (c == 'D'){
		if (y != h - 1){
			if (field[y + 1][x] == '.'){
				field[y + 1][x] = 'v';
				field[y][x] = '.';
				y++;
			}
			else field[y][x] = 'v';
		}
		else field[y][x] = 'v';
	}
	else if (c == 'L'){
		if (x != 0){
			if (field[y][x - 1] == '.'){
				field[y][x - 1] = '<';
				field[y][x] = '.';
				x--;
			}
			else field[y][x] = '<';
		}
		else field[y][x] = '<';
	}
	else if (c == 'R'){
		if (x != w - 1){
			if (field[y][x + 1] == '.'){
				field[y][x + 1] = '>';
				field[y][x] = '.';
				x++;
			}
			else field[y][x] = '>';
		}
		else field[y][x] = '>';
	}
	else{
		int cy = y, cx = x;
		if (field[y][x] == '^'){
			while (cy >= 0){
				if (field[cy][cx] == '*'){
					field[cy][cx] = '.';
					break;
				}
				else if (field[cy][cx] == '#')break;
				cy--;
			}
		}
		else if (field[y][x] == 'v'){
			while (cy <= h - 1){
				if (field[cy][cx] == '*'){
					field[cy][cx] = '.';
					break;
				}
				else if (field[cy][cx] == '#')break;
				cy++;
			}
		}
		else if (field[y][x] == '<'){
			while (cx >= 0){
				if (field[cy][cx] == '*'){
					field[cy][cx] = '.';
					break;
				}
				else if (field[cy][cx] == '#')break;
				cx--;
			}
		}
		else {
			while (cx <= w - 1){
				if (field[cy][cx] == '*'){
					field[cy][cx] = '.';
					break;
				}
				else if (field[cy][cx] == '#')break;
				cx++;
			}
		}
	}
	//REP(i, h){
	//	REP(j, w){
	//		cout << field[i][j];
	//	}
	//	cout << endl;
	//}
	pos = P(y, x);
}

int main(){
	cin >> t;
	while (t--){
		cin >> h >> w;
		REP(i, h){
			cin >> field[i];
			REP(j, w){
				if (field[i][j] == '^' || field[i][j] == 'v'
					|| field[i][j] == '>' || field[i][j] == '<'){
					pos = P(i, j);
				}
			}
		}
		cin >> n >> s;
		REP(i, n){
			solve(s[i]);
		}
		REP(i, h){
			REP(j, w){
				cout << field[i][j];
			}
			cout << endl;
		}
		if (t != 0)cout<< endl;
	}
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int H, W, N, ans=1;
	cin>>H>>W>>N;
	if(H<W) swap(H,W);
	for(;ans*H<N;ans++);
	cout<<ans<<'\n';
	return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  int count = 1;
  
  for(int i = 1; i < N; ++i) {
    if(S.at(i) == S.at(i - 1)) {
      continue;
    } else {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	long long n, a[10000], Min, Max, Sum;
	cin >> n;
	Min = 1000000;
	Max = -1000000;
	Sum = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		if (a[i] < Min){
			Min = a[i];
		}
		if (a[i] > Max){
			Max = a[i];
		}
		Sum = Sum + a[i];
	}
	cout << Min << " " << Max << " " << Sum << endl;
		return 0;
}

Measured memory_bytes: 3160
N=int(input())

def keta(x, k):
    if x%10==x:
        return k
    else:
        y=x//10
        k+=1
        return keta(y,k)

ls_375_tmp=[]
def func(a, n, keta):
    if n==keta:
        return
    for num in ['3', '5', '7']:
        ls_375_tmp.append(int(num+a))
        func(num+a, n+1,keta)

keta_N=keta(N,1)
func('', 0, keta_N)

ct=0
for i in ls_375_tmp:
    if all(x in str(i) for x in ['3', '5', '7']) and i<=N:
        ct+=1
print(ct)


Measured memory_bytes: 4340
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
l = 0; r = 0
bit = [False] * 22
res = 0
def f(n):
    return "".join(list(bin(n))[2:])
def back(l):
    c = f(a[l])[::-1]
    for i,t in enumerate(c):
        if t == '1':
            bit[i] = False
def check(c):
    for i,t in enumerate(c):
        if t == '1' and bit[i]:
            return False
    return True

def write(c):
    for i,t in enumerate(c):
        if t == '1': bit[i] = True

while l < n and r < n+1:
    if r == n:
        res += r-l
        back(l)
        l += 1
        continue
    now = f(a[r])[::-1]
    if check(now):
        write(now)
        r += 1
    else:
        res += r-l
        back(l)
        l += 1
    # print(l,r,res,bit)
res += r-l
print(res)

Measured memory_bytes: 101960
s=input()
for _ in range(int(input())):
 a=input().split()
 if a[0]=='print':print(s[int(a[1]):int(a[2])+1])
 else:
  t=s[int(a[1]):int(a[2])+1][::-1]if'reverse'==a[0]else a[3]
  s=s[0:int(a[1])]+t+s[int(a[2])+1:]

Measured memory_bytes: 5612
n,k,*a=map(int,open(0).read().split())
a.sort()
mod=10**9+7
ans=1
i=0
j=-1
kk=k
while kk>1:
    if a[i]*a[i+1]>a[j]*a[j-1]:
        ans=ans*a[i]*a[i+1]%mod
        i+=2
        kk-=2
    else:
        ans=ans*a[j]%mod
        j-=1
        kk-=1
if kk==1:
    ans=ans*a[j]%mod

if a[-1]<0 and k%2==1:
    ans=1
    for i in a[n-k:]:
        ans=ans*i%mod
print(ans)

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<char> vec(W);
  
  for(int i=0; i< W+2; i++){
    cout << "#";
  }
  cout << endl;
  
  for(int j=0; j<H; j++){
    cout << "#";
  	for(int i=0; i<W; i++){
   	 cin >> vec.at(i);
   	 cout << vec.at(i);    
  	}
    cout << "#" << endl;
  }
  
  for(int i=0; i< W+2; i++){
    cout << "#";
  }
  cout << endl;
  
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll N,A,B;
int main(){
	cin >> N >> A >> B;
	if(!(A+B-1<=N&&N<=A*B)){
		cout << -1 << endl;
		return 0;
	}
	vector<int> ans;
	for(int i=B;i>=1;i--)ans.pb(i);
	int M = B;
	if(A>1){
		int k = (N-B)/(A-1);
		int rem = (N-B)%(A-1);
		for(int i=0;i<rem;i++){
			for(int j=k+1;j>=1;j--){
				ans.pb(M+j);
			}
			M += k+1;
		}
		for(int i=0;i<A-1-rem;i++){
			for(int j=k;j>=1;j--){
				ans.pb(M+j);
			}
			M+=k;
		}
	}
	for(int i=0;i<ans.size();i++){
		printf("%d%c",ans[i],(i+1==ans.size())?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 3440
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

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

    double p = 0;

    if (N-K+1>=0) {
        p += (double)(N-K+1)/N;
    }
    for (int i=1; i<=N; i++) {
        if (i>=K) break;
        int n = ceil(log2((double)K/i));
        // cout << n << endl;
        p += (double)1.0/N * (double)pow(double(0.5), n);
    }

    cout << fixed << setprecision(10) << p << endl;

    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef long long LL;
LL fun(LL x,LL n)
{
    LL res=1;
    while(n>0)
    {
        if(n & 1)
            res=(res*x);
        x=(x*x);
        n >>= 1;
    }
    return res;
}
ll a[200]={0,2 ,3 ,5 ,7 ,11 ,13 ,17 ,19 ,23 ,29 ,31 ,37 ,41 ,43 ,47 ,53 ,59 ,61 ,67 ,71 ,73 ,79 ,83 ,89 ,97 ,101 ,103 ,107 ,109 ,113 ,127 ,131 ,137 ,139 ,149 ,151 ,157 ,163 ,167 ,173 ,179 ,181 ,191 ,193 ,197 ,199 ,211 ,223 ,227 ,229 ,233 ,239 ,241 ,251 ,257 ,263 ,269 ,271 ,277 ,281 ,283 ,293 ,307 ,311 ,313 ,317 ,331 ,337 ,347 ,349 ,353 ,359 ,367 ,373 ,379 ,383 ,389 ,397 ,401 ,409 ,419 ,421 ,431 ,433 ,439 ,443 ,449 ,457 ,461 ,463 ,467 ,479 ,487 ,491 ,499 ,503 ,509 ,521 ,523 ,541 ,547 ,557 ,563 ,569 ,571 ,577 ,587 ,593 ,599 ,601 ,607 ,613 ,617 ,619 ,631 ,641 ,643 ,647 ,653 ,659 ,661 ,673 ,677 ,683 ,691 ,701 ,709 ,719 ,727 ,733 ,739 ,743 ,751 ,757 ,761 ,769 ,773 ,787 ,797 ,809 ,811 ,821 ,823 ,827 ,829 ,839 ,853 ,857 ,859 ,863 ,877 ,881 ,883 ,887 ,907 ,911 ,919 ,929 ,937 ,941 ,947 ,953 ,967 ,971 ,977 ,983 ,991 ,997 ,1001};
int main()
{
    ll n;
    ll mod=1e9+7;
    ll ans=1;
    cin>>n;
    ll b[1010];
    int pos=0;
    while(1)
    {
        if(a[pos]<=n)
        {
           pos++;
        }
        else
        {
            break;
        }
    }
    //cout<<<<endl;
    for(int i=1; i<=pos-1; i++)
    {
        ll sum=0;
        for(int j=1; j<=n; j++)
        {
            if(fun(a[i],j)<=n)
            {
                sum+=(n/fun(a[i],j));
            }
            else
            {
                break;
            }
        }
        ans=ans*(sum+1);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int f;
	double r;
	scanf("%lf", &r);
	double f1, f2;
	f1 = r * r * 3.141592653589;
	f2 = 2 * r * 3.141592653589;
	printf("%.6lf %.6lf\n", f1, f2);
	
	return 0;
}

Measured memory_bytes: 652
program prob2
    implicit none
    character(len=100) :: S, T
    integer :: i, N

    read(*,*) S, T

    N = len_trim(S)
    do i = 1, N-1
        if(S(1:i) == T(N-i+1:N) .and. S(i+1:N) == T(1:N-i)) then
            write(*,*) 'Yes'
            stop
        end if
    end do
    if(S == T)then
        write(*,*) 'Yes'
        stop
    end if

    write(*,*) 'No'

    stop
contains
end program prob2

Measured memory_bytes: 2864
#include <iostream>
using namespace std;
int main(){
    int As;
    cin >> As;
    if((65<=As)&&(As<=90)){
        cout << "1" << endl;
    }else if((97<=As)&&(As<=122)){
        cout << "2" << endl;
    }else{
        cout << "0" << endl;
    }
}


Measured memory_bytes: 3132