akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main(){

	int N,A,B;
	int ans=0;
	int res=0;
	int X;

	cin >>N>>A>> B;

	int a,b,c,d,e;
	


	for(int i=0;i<=N;i++){

		a=i/10000;

		b=(i-a*10000)/1000;

		c=(i-a*10000-b*1000)/100;

		d=(i-a*10000-b*1000-100*c)/10;

		e=(i-a*10000-b*1000-100*c-10*d);

		if(A<=a+b+c+d+e && a+b+c+d+e <=B)ans+=i;

		//cout << i << " "<<a<<" "<<b<<" " <<c <<" " <<d <<" " << e << " " <<ans <<endl;

	}


	
	cout <<ans<<endl;

}


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

using namespace std;

int main(void) {
	int sum = 0, a;

	for (int i = 0; i < 3; i++) {
		cin >> a;
		sum += a;
	}

	if (sum >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;

	return 0;
}

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

using namespace std;

int n;
int A[200000];
deque<int> q;

int main(){
	cin >> n;

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

	if(n % 2 == 0){
		for(int i = 0; i < n; i++){
			if(i % 2 == 0){
				q.push_back(A[i]);
			}else{
				q.push_front(A[i]);
			}
		}
	}else{
		for(int i = 0; i < n; i++){
			if(i % 2 == 1){
				q.push_back(A[i]);
			}else{
				q.push_front(A[i]);
			}
		}
	}

	deque<int>::iterator it = q.begin();
	cout << *it;
	it++;
	for(; it != q.end(); it++){
		cout << " " << *it;
	}
	cout << endl;
	return 0;

}


Measured memory_bytes: 3840
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7
    #epsilon = 10**-9

    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    res = a[0]
    n -= 2
    i = 1
    while n>0:
        res += a[i]
        n -= 1
        if n == 0:
            break
        res += a[i]
        n -= 1
        i += 1

    print(res)

if __name__ == '__main__':
    main()

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

int main() {
  int N; cin >> N;
  int P[N]; for (int i = 0; i < N; i++) cin >> P[i];
  int Q[N]; for (int i = 0; i < N; i++) cin >> Q[i];
  int p[N]; for (int i = 0; i < N; i++) p[i] = i+1;
  int i = 0, pi, qi;
  do {
    bool is_same = true;
    for (int j = 0; j < N; j++) is_same = is_same && (p[j] == P[j]);
    if (is_same) pi=i;
    is_same = true;
    for (int j = 0; j < N; j++) is_same = is_same && (p[j] == Q[j]);
    if (is_same) qi=i;
    i++;
  } while (next_permutation(p, p+N));
  cout << abs(pi-qi) << endl;
}

Measured memory_bytes: 3608
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int main()
{
    fast();
    string s , t , u ;
    cin>>s>>t;
    int a =D(),b=D();
    cin>>u;
    if(s==u)a--;
    if(t==u)b--;

    cout<<a<<" "<<b<<endl;
}


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

int main() {
  int a1,a2,b1,b2,c2;
  cin >> a1;
  b1 = a1%100;//11,10,01,00
  a2 = (a1-b1)/100;
  c2 = b1%10;//1,0
  b2 = (b1-c2)/10;
  
  cout << a2+b2+c2 << endl;
}

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    char s[100001];
    scanf("%s",s);

    int len = strlen(s),count[3] = {0},i;
    for (i = 0; i < len; i++)
    {
        count[s[i] - 'a']++;
    }
    int min = 0;
    for (i = 1; i < 3; i++)
    {
        if(count[i] < count[min])min = i;
    }
    min = count[min];
    for (i = 0; i < 3; i++)
    {
        count[i] -= min;
    }
    
    qsort(count,sizeof(count) / sizeof(int),sizeof(int),asc);
    if((count[0] == count[1] || count[1] == count[2])&&(count[2] < 2))printf("YES");
    else printf("NO");
}

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

using namespace std;

const int maxn = 3000;

int n;
double pos[maxn];
double dp[maxn][maxn];

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> pos[i];
	}

	for (int i = 0; i < n; i++){
		dp[i][0] = 1;
	}
	dp[0][1] = pos[0];

	for (int i = 1; i < n; i++){
		for (int j = 1; j < n; j++){
			dp[i][j] = pos[i] * dp[i-1][j-1] + (1 - pos[i]) * dp[i-1][j];
		}
	}

	printf ("%.10f" , dp[n-1][n/2 + 1]);
	return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>

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

    ll n;
    cin>>n;
    ll ar[n];
    for(ll i=0;i<n;++i)
    {
        cin>>ar[i];
        ar[i]-=i+1;
    }
    sort(ar,ar+n);
    ll ans;
    int t1=ar[n/2];
    ll ch=0;
    for(int i=0;i<n;++i)
    {
        ch+=abs(ar[i]-t1);
    }
    ans=ch;
    if(n%2==0)
    {
        t1=ar[(n-1)/2];
        ch=0;
        for(int i=0;i<n;++i)
        {
        ch+=abs(ar[i]-t1);
        }
        ans=min(ans,ch);
    }
    cout<<ans;
return(0);
}

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

constexpr int inf = 1e9;

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<int> c(m), x(n);
        for(int i = 0; i < m; ++i) {
            cin >> c[i];
        }
        for(int i = 0; i < n; ++i) {
            cin >> x[i];
        }

        vector<int> dp(256, inf);
        dp[128] = 0;
        for(int i = 0; i < n; ++i) {
            vector<int> nxt(256, inf);
            for(int j = 0; j <= 255; ++j) {
                for(int k = 0; k < m; ++k) {
                    int nc = max(0, min(255, j + c[k]));
                    nxt[nc] = min(nxt[nc], dp[j] + (x[i] - nc) * (x[i] - nc));
                }
            }
            dp = move(nxt);
        }

        cout << *min_element(begin(dp), end(dp)) << endl;
    }
}


Measured memory_bytes: 3176
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		if(k == 1){
			System.out.print(0);
		}else{
			System.out.print(n-k);
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  int count=1;
  for(int i=1800;i>=400;i-=200){
      if(i<=N){
          cout <<  count;
          return 0;
      }
    count++;
  }
  
  
  
}


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

using namespace std;

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  if (A <= X) {
    if (A + B > X) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
int n,m;
int w[2100][2100];
int l[2100][2100];
int r[2100][2100];
int u[2100][2100];
int d[2100][2100];
char c;

void init()
{
    cin>>n>>m;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=m; ++j)
        {
            scanf("%c",&c);
            while (c!='.' && c!='#') 
                scanf("%c",&c);
            if (c=='.') w[i][j]=1;
        }
}

void solve()
{
    int ans=0;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=m; ++j)
        {
            if (w[i][j]==0)
            {
                l[i][j]=r[i][j]=u[i][j]=d[i][j]=0;
            }else
            {
                l[i][j]=l[i][j-1]+1;
                u[i][j]=u[i-1][j]+1;
            }
        }
    for (int i=n; i>=1; --i)
        for (int j=m; j>=1; --j)
        {
            if (w[i][j]==0)
            {
                l[i][j]=r[i][j]=u[i][j]=d[i][j]=0;
            }else
            {
                r[i][j]=r[i][j+1]+1;
                d[i][j]=d[i+1][j]+1;
            }
        }
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=m; ++j)
        {
            ans=max(ans,l[i][j]+r[i][j]+d[i][j]+u[i][j]-3);
        }
    cout<<ans<<endl;
}
int main()
{
    init();
    solve();
    return 0;
}



Measured memory_bytes: 86272
import sys
n, a, b = map(int, input().split())

if (b-a) % 2 == 0:
    # 距離が偶数
    print((b-a) // 2)
    sys.exit()
else:
    if a+1 == b:
        print(min([b-1, n-a]))
    else:
        diff = b - a
        a += diff // 2
        b -= diff // 2
        print(min([b-1, n-a]))
# print([b-1, n - a])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  char p[2];
  cin>>a>>p>>b;
  while(p[0]!='?'){
    if(p[0]=='+')cout<<a+b<<endl;
    if(p[0]=='-')cout<<a-b<<endl;
    if(p[0]=='*')cout<<a*b<<endl;
    if(p[0]=='/')cout<<a/b<<endl;
    cin>>a>>p>>b;
  }
  return 0;
}

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

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

using namespace std;

int main(){
  int n;
  cin>>n;
  
  if(n<1000){
    cout<<"ABC";
  }else{
    cout<<"ABD";
  }
  return 0;
}

Measured memory_bytes: 256
open Scanf
open Printf

let explode s =
  let rec exp i l =
    if i < 0 then l else exp (i - 1) (s.[i] :: l)
  in
    exp (String.length s - 1) []

let something_on_it s =
  let s_list = explode s in
    let rec plus_100 s_list =
      match s_list with
        [] -> 700
      | first :: rest -> if first = 'o' then 100 + plus_100 rest
                                        else plus_100 rest
    in
      plus_100 s_list

let () = scanf "%s" something_on_it |> printf "%d\n"

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    vector<int> u(N-1), v(N-1);
    REP(i, N-1){
        cin >> u[i] >> v[i];
    }
    // ll ans = N*(N*N+3*N+2)/6;
    ll ans = 0;
    Rep(i, 1, N+1){
        ll n = N-i+1;
        ans += (ll)n+n*(n-1)/2;
    }
    REP(i, N-1){
        ans -= min(u[i], v[i])*(N-max(u[i], v[i])+1);
    }

    pr(ans);
}

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a<b) {
		rep(i, b) {
			cout << a;
		}
		cout << endl;
		return 0;
	}else{
		rep(i,a){
			cout << b;
		}
		cout << endl;
		return 0;
	}
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
//v.erase(unique(v.begin(),v.end()),v.end());

using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef  pair <ll, ll> pii;
 
const ll N = 200500;
const ll mod = 1e9 + 7;
const ld PI = 3.141592654;



int main() {


	ld n;
	cin >> n;
 
	cout << (ld)2.0 * n * PI << endl;
	
	return 0;
}

Measured memory_bytes: 3264
/*input
AAAAABBBBAAABBBBAAAA
BBBBAAABBBBBBAAAAABB
10
2 15 2 13
2 13 6 16
1 13 2 20
4 20 3 20
1 18 9 19
2 14 1 11
3 20 3 15
6 16 1 17
4 18 8 20
7 20 3 14
*/
#include <bits/stdc++.h>
#define fastIo ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define sz size
#define pb push_back
#define mp make_pair
using namespace std;

//#define LOCAL
#ifdef LOCAL
	#define DEBUG(x) do { cout << #x << ": " << x << '\n'; } while (0)
#else
	#define DEBUG(x) 
#endif

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

const int dr[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dc[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

bool check(int SA, int TA, int SB, int TB){
	SB += SA * 2;
	TB += TA * 2;
	return SB % 3 == TB % 3;
}

int cumA[100005], cumB[100005], cummA[100005], cummB[100005];

int main(){
	fastIo;

	string s, t;
	cin >> s >> t;

	int q;
	cin >> q;

	if(s[0] == 'A') cumA[0] = 1;
	else cumB[0] = 1;
	for(int i = 1; i < s.sz(); i++){
		if(s[i] == 'A') cumA[i] = cumA[i - 1] + 1, cumB[i] = cumB[i - 1];
		else cumB[i] = cumB[i - 1] + 1, cumA[i] = cumA[i - 1];
	}

	if(t[0] == 'A') cummA[0] = 1;
	else cummB[0] = 1;
	for(int i = 1; i < t.sz(); i++){
		if(t[i] == 'A') cummA[i] = cummA[i - 1] + 1, cummB[i] = cummB[i - 1];
		else cummB[i] = cummB[i - 1] + 1, cummA[i] = cummA[i - 1];
	}

	int si, sj, ti, tj;
	while(q--){
		cin >> si >> sj >> ti >> tj;
		si--, sj--, ti--, tj--;
		int SA = cumA[sj] - (si == 0 ?0 :cumA[si - 1]), SB = cumB[sj] - (si == 0 ?0 :cumB[si - 1]);
		int TA = cummA[tj] - (ti == 0 ?0 :cummA[ti - 1]), TB = cummB[tj] - (ti == 0 ?0 :cummB[ti - 1]);
		//cout << SA << ' ' << SB << ' ' << TA << ' ' << TB << '\n';
		if(check(SA, TA, SB, TB)){
			cout << "YES\n";
		}
		else{
			cout << "NO\n";
		}
	}

	return 0;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	int n,r;
	cin >> n >> r;
	int ans = r;
	if(n < 10)
		ans += 100*(10-n);
	cout << ans;
}



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

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i ++){
    for(int j = i+1; j < n; j++){
      ans += a[i] * a[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <array>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

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


void dump(int dye[10][10])
{
    rep(i, 10){
        rep(j, 10) cout << dye[i][j];
        cout << endl;
    }
}

bool puttable(int dye[10][10], int y, int x, int s)
{
    rep(i, s){
        rep(j, i?4:5){
            int py = y + dy[i][j];
            int px = x + dx[i][j];
            if(dye[py][px] == 0) return false;
        }
    }
    
    return true;
}

void put(int dye[10][10], int y, int x, int s, bool minus)
{
    rep(i, s){
        rep(j, i?4:5){
            int py = y + dy[i][j];
            int px = x + dx[i][j];
            dye[py][px] += minus ? -1 : 1;
        }
    }
}

bool prune(int dye[10][10], int num[])
{
    int tmp[10][10];
    rep(i, 10) rep(j, 10) tmp[i][j] = dye[i][j] > 0;
    
    rep(i, 3){
        if(num[i] > 0){
            int s = 3 - i;
            int o = s == 3 ? 2 : 1;
            reps(y, o, 10-o){
                reps(x, o, 10-o){
                    if(puttable(dye, y, x, s)){
                        put(tmp, y, x, s, true);
                    }
                }
            }
        }
    }
    
    rep(i, 10) rep(j, 10){
        if(tmp[i][j] > 0) return true;
    }
    
    return false;
}

bool search(int dye[10][10], int num[])
{
    if(prune(dye, num)){
        return false;
    }
    
    rep(i, 3){
        if(num[i] > 0){
            num[i]--;
            int s = 3 - i;
            int o = s == 3 ? 2 : 1;
            reps(y, o, 10-o){
                reps(x, o, 10-o){
                    if(puttable(dye, y, x, s)){
                        put(dye, y, x, s, true);
                        if(search(dye, num)){
                            cout << x << ' ' << y << ' ' << s << endl;
                            return true;
                        }
                        put(dye, y, x, s, false);
                    }
                }
            }
            num[i]++;
            return false;
        }
    }
    
    return true;
}

int main()
{
    int n;
    cin >> n;
    
    int dye[10][10];
    int a = 0;
    rep(i, 10) rep(j, 10){
        cin >> dye[i][j];
        a += dye[i][j];
    }
    
    int m = (a - n) / 4;
    vector<array<int, 3>> data;
    for(int x=0;; ++x){
        int y = -a + 5*m - 2*x;
        int z = 2*a - 9*m + x;
        if(z<0) continue;
        if(y<0) break;
        data.push_back({{x, y, z}});
    }
    
    for(int i=data.size()-1; i>=0; --i){
        int num[] = {data[i][0], data[i][1], data[i][2]};
        if(search(dye, num)){
            break;
        }
    }
}

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


int main(){
    int N, K; cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int ans = 0;
    rep(i,N){
        if(a[i] >= K) ans++;
    }
    cout << ans << endl;
}

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

int main(){

  int H,W;
  cin >> H >> W;
  char inp[H][W];
  char temp;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> temp;
      inp[i][j]= temp;
    
    }
  }
  long long int dp[H][W];
  dp[H-1][W-1]=1;
  for(int i=H-1;i>=0;i--){
    for(int j=W-1;j>=0;j--){
      
      if(i==H-1 && j==W-1) continue;
      if(inp[i][j]=='#') continue;
      dp[i][j] = 0;
      if(i+1<=H-1 && inp[i+1][j] == '.') dp[i][j] +=dp[i+1][j];
      if(j+1<=W-1 && inp[i][j+1] == '.') dp[i][j] +=dp[i][j+1];
      dp[i][j]=(dp[i][j])%(long long int)(pow(10,9)+7);
    }
  }
  //long long int ans;
  //ans =dp[0][0];
  cout << dp[0][0];
  return 0;
  
}

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

#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;


void solve() 
{
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,0,n){
		cin>>v[i];
	}
	ll sum=0;
	ll ans=0;
	ll MOD=1e9+7;
	for(int i=n-1;i>=0;i--){
		ans=(ans+(sum*v[i]))%MOD;
		sum=(sum+v[i])%MOD;
	}
	cout<<ans;
}

int  main(){
ll t;
t=1;
//cin>>t;
while(t--){
	
		solve();
		cout<<endl;

}
	
	
			
}

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

ll f(ll a){
	if(a==1){
      return 1;
    }else{
      return 2*f(a/2)+1;
    }
}
int main(){
  ll h;
  cin >> h;
  ll ans;
  ans = f(h);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,b,f,r,v;
    int building[4][3][10]; //1フロア10部屋、3階建の公舎4棟の入居者数
    
    //配列の初期化
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 3;j++){
            for(int k = 0;k < 10;k++){
                building[i][j][k] = 0;
            }
        }
    }
    
    scanf("%d",&n);
    
    for(int i = 1;i <= n ;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        building[b - 1][f - 1][r - 1] += v;
    }
    
    //出力
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 3;j++){
            for(int k = 0;k < 10;k++){
                printf(" %d",building[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3){
            printf("####################\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 2140
n=int(input())
a,b,c,d=0,0,0,0
for i in range(n):
    s=input()
    if len(s)>1:
        for j in range(1,len(s)):
            if s[j-1]+s[j]=="AB":
                d+=1
    if s[0]=="B"and s[-1]=="A":
        b+=1
    elif s[-1]=="A":
        a+=1
    elif s[0]=="B":
        c+=1
if a+c!=0:
    print(d+b+min(a,c))
else:
    print(d+max(0,b-1))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = 0;
		int b = 0;
		int t = 0;
		
		a = sc.nextInt();
		b = sc.nextInt();
		t = sc.nextInt();

		System.out.println(t / a * b);

	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
double sum[200001]={0},b=0.00,maxn=-99999999.999999;
int k,n;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		double a;
		cin>>a;
		sum[i+1]=(a*(a+1)/2)/a+b;
		b=sum[i+1];
	}
	for(int i=0;i<=n-k;i++)
		if(sum[i+k]-sum[i]>maxn)
			maxn=sum[i+k]-sum[i];
	printf("%.15f",maxn);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.*;

public class Main{

         public static void main(String[] args) {

                Scanner scan = new Scanner(System.in);
                int N = scan.nextInt();
                int array[] = new int[N+1];
                int result=0;

                for(int i=0 ; i < N ; i++){
                        array[i]=scan.nextInt();
                }
                array[N]=0;

                for(int i=N ; i > 0 ; i--){
                        if(array[i]<array[i-1]){
                                result+=array[i-1]-array[i];
                        }
                }

                System.out.println(result);
         }
}

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

using namespace std;

struct SegTree{
    int n;
    vector<int> data;
    SegTree(int N){
        n = 1;
        while(n < N) n *= 2;
        data.assign(2 * n - 1, 0);
    }
    void add(int k, int x){
        k += n - 1;
        data[k] += x;
        while(k > 0){
            k = (k - 1) / 2;
            data[k] = data[2 * k + 1] + data[2 * k + 2];
        }
    }
    int query(int a, int b){
        return query(a, b, 0, 0, n);
    }
    int query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) {
            return 0;
        } else if(a <= l && r <= b) {
            return data[k];
        } else {
            int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return vl + vr;
        }
    }
};

int main(){
    int n, q;
    while(cin >> n >> q){
        SegTree tree(n);
        REP(i, q){
            int com;
            cin >> com;
            if(com == 0){
                int k, x;
                cin >> k >> x;
                k--;
                tree.add(k, x);
            }else{
                int a, b;
                cin >> a >> b;
                a--; b--;
                cout << tree.query(a, b + 1) << endl;
            }
        }
    }
    return 0;
}

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

int days(int Y,int M, int D){
    return 20*10*((Y-1) / 3) + (20*10-10/2)*((Y-1) - (Y-1)/3) + 20*(M-1) - (Y%3 ? (M-1)/2 : 0) + D;
}

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int Y,M,D;
        cin >> Y >> M >> D;
        int mil = days(1000, 1, 1);
        cout << mil - days(Y, M, D) << endl;
    }
}


Measured memory_bytes: 2996
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  int N; cin >> N;
  if (N % 1000 == 0) cout << 0 << endl;
  else cout << 1000 - (N % 1000) << endl;
  return 0;
}


Measured memory_bytes: 3636
// =====================================================================================
// 
//       Filename:  C.cpp
//        Created:  2017년 09월 08일 04시 58분 41초
//       Compiler:  g++ -O2 -std=c++14
//         Author:  baactree ,  bsj0206@naver.com
//        Company:  Chonnam National University
// 
// =====================================================================================

#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> arr[200005];
const double pi=acos(-1);
bool inner(int x1, int y1, int x2, int y2, pair<int, int> x){
	return x.first>=x1&&x.first<=x2&&x.second>=y1&&x.second<=y2;
}
int main(){
	int x1, x2, y1, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	scanf("%d", &n);
	for(int i=0;i<n;i++)
		scanf("%d%d", &arr[i].first, &arr[i].second);
	if(x1==x2){
		if(y1>y2)
			swap(y1, y2);
		bool flag=false;
		for(int i=0;i<n;i++)
			if(arr[i].first==x1&&arr[i].second>y1&&arr[i].second<y2)
				flag=true;
		printf("%.15lf\n", (y2-y1)*100.0+(flag?pi*10-20:0));
		return 0;
	}
	if(y1==y2){
		if(x1>x2)
			swap(x1, x2);
		bool flag=false;
		for(int i=0;i<n;i++)
			if(arr[i].second==y1&&arr[i].first>x1&&arr[i].first<x2)
				flag=true;
		printf("%.15lf\n", (x2-x1)*100.0+(flag?pi*10-20:0));
		return 0;
	}
	if(x1>x2){
		swap(x1, x2);
		swap(y1, y2);
	}
	if(y1<y2){
		vector<pair<int, int> > vec;
		for(int i=0;i<n;i++){
			if(inner(x1, y1, x2, y2, arr[i]))
				vec.push_back(arr[i]);
		}
		sort(vec.begin(), vec.end());
		vector<int> lis;
		for(int i=0;i<vec.size();i++){
			auto it=lower_bound(lis.begin(), lis.end(), vec[i].second);
			if(it==lis.end())
				lis.push_back(vec[i].second);
			else
				*it=vec[i].second;
		}
		int len=lis.size();
		if(len==min(y2-y1, x2-x1)+1)
			printf("%.15lf\n", (x2-x1+y2-y1)*100.0+(len-1)*(5*pi-20)+pi*10-20);
		else
			printf("%.15lf\n", (x2-x1+y2-y1)*100.0+len*(5*pi-20));
		return 0;
	}
	vector<pair<int, int> > vec;
	for(int i=0;i<n;i++){
		if(inner(x1, y2, x2, y1, arr[i]))
			vec.push_back({arr[i].first, 1e8-arr[i].second});
	}
	sort(vec.begin(), vec.end());
	vector<int> lis;
	for(int i=0;i<vec.size();i++){
		auto it=lower_bound(lis.begin(), lis.end(), vec[i].second);
		if(it==lis.end())
			lis.push_back(vec[i].second);
		else
			*it=vec[i].second;
	}
	int len=lis.size();
	if(len==min(y1-y2, x2-x1)+1)
		printf("%.15lf\n", (x2-x1+y1-y2)*100.0+(len-1)*(5*pi-20)+pi*10-20);
	else
		printf("%.15lf\n", (x2-x1+y1-y2)*100.0+len*(5*pi-20));
	return 0;
}



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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int h,w,m;
    cin >> h >> w >> m;
    set<P> st;
    vector<int> cntx(3e5,0),cnty(3e5,0);
    for (int i = 0;i < m;++i) {
        int x,y;cin >> x >> y;
        x--;y--;
        cntx[x]++;
        cnty[y]++;
        st.insert({x,y});
    }
    int mxx = *max_element(cntx.begin(),cntx.end()),mxy = *max_element(cnty.begin(),cnty.end()),ans = 0;
    vector<int> lsy;
    for (int i = 0;i < 3e5;++i) if (cnty[i] == mxy) lsy.push_back(i);
    bool f = true;
    for (int i = 0;i < 3e5;++i) if (f && cntx[i] == mxx) {
        for (int j : lsy) {
            if (st.find({i,j}) == st.end()) {
                ans = mxx+mxy;
                f = false;
            } else {
                ans = max(ans,mxx+mxy-1);
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;

mt19937 mt(736);


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int w, h, n;

	cin >> w >> h >> n;

	w = max(w, h);

	cout << (n + w - 1) / w << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	solve(fin);

	cout << "clock: " << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<tuple<string,int,int>> v;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    v.emplace_back(s,-p,i);
  }
  sort(v.begin(),v.end());
  for(auto x:v) cout<<get<2>(x)<<endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * j.cc: J - Segment Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_E2 = 1 << 19; // = 524288

/* typedef */

template <typename T, const int MAX_E2>
struct SegTreeMax {
  int e2;
  T nodes[MAX_E2], defv;
  SegTreeMax() {}

  void init(int n, T _defv) {
    defv = _defv;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(nodes, nodes + MAX_E2, defv);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }
  void seti(int i, T v) { get(i) = v; }

  void setall() {
    for (int j = e2 - 2; j >= 0; j--)
      nodes[j] = max(nodes[j * 2 + 1], nodes[j * 2 + 2]);
  }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = max(nodes[j * 2 + 1], nodes[j * 2 + 2]);
    }
  }

  T max_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return defv;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = max_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = max_range(r0, r1, k * 2 + 2, im, i1);
    return max(v0, v1);
  }
  T max_range(int r0, int r1) { return max_range(r0, r1, 0, 0, e2); }
};

/* global variables */

SegTreeMax<int,MAX_E2> st;

/* subroutines */

/* main */

int main() {
  int n, q;
  scanf("%d%d", &n, &q);

  st.init(n, 0);

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    st.seti(i, ai);
  }
  st.setall();

  while (q--) {
    int op, x, v;
    scanf("%d%d%d", &op, &x, &v);
    x--;

    if (op == 1) {
      st.set(x, v);
    }
    else if (op == 2) {
      int ma = st.max_range(x, v);
      printf("%d\n", ma);
    }
    else {
      int l = x, r = n;
      if (st.max_range(l, r) < v) printf("%d\n", n + 1);
      else {
	while (l + 1 < r) {
	  int m = (l + r) / 2;
	  if (st.max_range(l, m) >= v) r = m;
	  else l = m;
	}
	printf("%d\n", l + 1);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 5900
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
vector<pii > v;
void Solve() {
    read(N);
    if(N & 1) {
        for(int i = 1 ; i < N ; ++i) {
            v.pb(mp(i,N));
        }
        --N;
    }
    for(int i = 1 ; i <= N ; ++i) {
        for(int j = i + 1 ; j <= N ; ++j) {
            if(i + j != N + 1) v.pb(mp(i,j));
        }
    }
    out(v.size());enter;
    for(auto t : v) {
        out(t.fi);space;out(t.se);enter;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(a);
  rep(i,a)
    cin>>c[i];
  int d=abs(c[0]-b);
  rep(i,a){
  d=__gcd(d,abs(c[i]-b));
  }
          cout<<d<<endl;
}

Measured memory_bytes: 1024
n = int(input())
p = list(map(int, input().split()))
min_p = p[0]
ans = 0
if n == 1:
    ans += 1
else:
    for i in range(n-1):
        if p[i] <= min_p:
            ans += 1
        min_p = min(min_p, p[i+1])
    if p[-1] <= min_p:
        ans += 1
print(ans)


Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;++i){
    cin>>s[i];
  }
  for(int i=0;i<w+2;++i){
    cout<<"#";
  }
  cout<<endl;
  for(int i=0;i<h;++i){
    cout<<"#";
    cout<<s[i];
    cout<<"#"<<endl;
  }
  for(int i=0;i<w+2;++i){
    cout<<"#";
  }
  return 0;
}


Measured memory_bytes: 256
import fileinput
a_dict = {chr(c): 0 for c in range(97, 123)}
for line in fileinput.input():
    line = line.lower()
    for c in line:
        if c in a_dict:
            a_dict[c] += 1

for k, v in a_dict.items():
    print('{0} : {1}'.format(k, v))



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

bool used[200000];

int main()
{
	int n;
	cin >> n;
	if (n == 3) {
		cout << "2 5 63\n";
		exit(0);
	}
	int sum = 0;
	int cur = 2;
	for (int i = 0; i < n - 2; ++i) {
		while ((cur % 2 != 0) && (cur % 3 != 0)) ++cur;
		cout << cur << " ";
		used[cur] = true;
		sum += cur++;
	}
	for (int i = cur; i <= 30000; ++i) {
		if ((i % 2 != 0) && (i % 3 != 0)) continue;
		if (used[i]) continue;
		for (int j = i + 1; j <= 30000; ++j) {
			if ((j % 2 != 0) && (j % 3 != 0)) continue;
			if ((sum + i + j) % 6 == 0) {
				cout << i << " " << j << "\n";
				exit(0);
			}
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
int n,m;
cin>>n>>m;
int x[m];
for(int i=0;i<m;i++)cin>>x[i];
if(n>=m){
    cout<<0;
    return 0;
}
sort(x,x+m);
int y[m-1];
for(int i=1;i<m;i++)y[i-1]=x[i]-x[i-1];
sort(y,y+m-1);int ans=0;
for(int i=0;i<m-n;i++){
    ans+=y[i];
}
cout<<ans;

return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
char s[200005];
int main() {
    scanf("%s",s);
    int ans=0,l=strlen(s);
    for(int i=0;i<l;i++) ans+=s[i]-'0';
    if(ans%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

long long n, ans[3] = {0};

void solve();

int main() {
  cin >> n;
  solve();
  cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
  return 0;
}

void solve() {
  for(long long i = 1; i <= 3500; ++i)
    for(long long j = 1; j <= 3500; ++j) {
      long long hn4, Nn, Nh, Nhn, now = 0;
      hn4 = i * j * 4;
      Nn = n * i;
      Nh = n * j;
      Nhn = i * j * n;
      if((hn4 - Nn - Nh) != 0 &&
         Nhn % (hn4 - Nn - Nh) == 0) {
        now = Nhn / (hn4 - Nn - Nh);
        if(now > 0 && now <= 3500) {
          ans[0] = i;
          ans[1] = j;
          ans[2] = now;
          return;
        }
      }
    }
}

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

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

    if (x == 0)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3520
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)

def main():
    s,t = input().split()
    a,b = map(int,input().split())
    u = input()
    if s == u:
        a -= 1
    else:
        b -= 1
    print(a,b)
    return

if __name__=='__main__':
    main()


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

using namespace std;

int a, b, h, m;
pair<double, double> p, q;

double dis(pair<double, double> p, pair<double, double> q){
	double s = (p.first-q.first), t = (p.second-q.second);
	return sqrt(s*s+t*t);
}

double rad(double degree){
	return degree*acos(-1)/180;
}

int main(){
	cin >> a >> b >> h >> m;
	
	p = make_pair(a*cos(rad( 30.0*h + 1.0/2*m )), a*sin(rad( 30.0*h + 1.0/2*m )));
	q = make_pair(b*cos(rad( 6.0*m )), b*sin(rad( 6.0*m )));
	
	printf("%.18f\n", dis(p, q));
}

Measured memory_bytes: 4080
#include<stdio.h>
int main()
{
    int i;
    char str;
    // 文字
    scanf("%c", &str);
  
	if((str>= 'a') && (str<='z')){
    printf("a\n");
  }
  	else if((str>= 'A') && (str<='Z')){
    printf("A\n");
  }
  
    return 0;
}

Measured memory_bytes: 1596
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a) (0<=(a)&&(a)<9)
int di[]={-3,-1,1,3};
int main(){
	int n,s,t,b; char cs,ct,cb;
	while(scanf("%d",&n),n){
		scanf(" %c %c %c",&cs,&ct,&cb); s=cs-'A', t=ct-'A', b=cb-'A';
		double p[9]={0}; p[s]=1;
		
		while(n--){
			double q[9]={0};
			rep(i,9)rep(d,4){
				if(ck(i+di[d])&&!(i%3==0&&di[d]==-1)&&!(i%3==2&&di[d]==1)&&i+di[d]!=b)q[i+di[d]]+=p[i]/4;
				else q[i]+=p[i]/4;
			}
			rep(i,9)p[i]=q[i];
		}
		
		printf("%.8f\n",p[t]);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
from fractions import gcd
def lcm(a, b):
    return a*b // gcd(a, b)
def group(s, t, u):
    su = (s - 1) // u
    tu = t // u
    return  tu - su

A, B, C, D = map(int, input().split())
ABC = group(A, B, C)
ABD = group(A, B, D)
ABCD = group(A, B, lcm(C,D))
U = B - A + 1
print(U-(ABC+ABD-ABCD))

Measured memory_bytes: 66308
#include<stdio.h>

int main(){
int i,j;
char s[101],t[101];
scanf("%s %s",s,t);
for(i=0;s[i]!=0;i++){
for(j=0;j<i;j++){
if(s[i]<s[j]){
char tmp=s[i];
s[i]=s[j];
s[j]=tmp;
}
}
}

for(i=0;t[i]!=0;i++){
for(j=0;j<i;j++){
if(t[i]>t[j]){
char tmp=t[i];
t[i]=t[j];
t[j]=tmp;
}
}
}
i=0;
while(s[i]!=0&&t[i]!=0){
if(s[i]<t[i]){
puts("Yes");
return 0;
}
if(s[i]>t[i]){
puts("No");
return 0;
}i++;
}
for(i=0;s[i]!=0;i++);
for(j=0;t[j]!=0;j++);
if(i<j)puts("Yes");
else puts("No");
return 0;
}

Measured memory_bytes: 128
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	

	long long N,Q;
	cin>>N>>Q;
	multiset<pair<long long,pair<long long,long long>>> W;
	for (long long i = 0; i < N; ++i)
	{
		long long S,T,X;
		cin>>S>>T>>X;
		W.insert({X,{2*S-2*X-1,2*T-2*X-1}});
	}
	multiset<pair<long long,long long>> D;
	for (long long i = 0; i < Q; ++i)
	{
		long long d;
		cin>>d;
		D.insert({2*d,i});
	}
	long long ans[Q]={0};
	for (auto w:W)
	{
		auto it=D.lower_bound({(w.second).first,LONG_MIN});
		while((*it).first<(w.second).second && it!=D.end())
		{
			ans[(*it).second]=w.first;
			it=D.erase(it);
		}
	}
	for (long long i = 0; i < Q; ++i)
	{
		if(ans[i]==0)
		{
			ans[i]=-1;
		}
		cout<<ans[i]<<endl;
	}


	return 0;
}

Measured memory_bytes: 28928
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
P = tuple(lr())
Q = tuple(lr())
a = -1; b = -1
for i, x in enumerate(itertools.permutations(range(1, N+1), N)):
    if x == P:
        a = i
    if x == Q:
        b = i

answer = abs(a-b)
print(answer)


Measured memory_bytes: 3064
from itertools import *
f=lambda:map(int,input().split())
g=lambda:[0]+[*accumulate(f())]
n,m,k=f()
A,B=g(),g()
a,j=0,m
for i in range(n+1):
  while j and B[j]>k-A[i]: j-=1
  if A[i]+B[j]<=k: a=max(a,i+j)
print(a)

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

using namespace std;

int main(){
	string s3;
	cin>>s3;
	string s2=s3;
	string s1=s3;
	for(int i=0;i<s3.size();i++){
		s1[i]=s3[s3.size()-i-1];
	}
	for(int i=0;i<s1.size();i++){
		if(s1[i]=='q'){
			s1[i]='p';
			continue;
		}
		if(s1[i]=='b'){
			s1[i]='d';
			continue;
		}
		if(s1[i]=='p'){
			s1[i]='q';
			continue;
		}
		if(s1[i]=='d'){
			s1[i]='b';
			continue;
		}
	}
	if(s1==s2){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 512
s = input()
aa = int(s[:2])
bb = int(s[2:])

if 0<aa and aa<=12:
  if 0<bb and bb<=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<bb and bb<=12:
    print('YYMM')
  else:
    print('NA')

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 999999999

    /*Solve*/
int main(){
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans=0;
    rep(i,n){
        if(a[i]==b[i] && a[i]==c[i]){
        }else if(a[i]==b[i] && a[i]!=c[i]){
            ans++;
        }else if(b[i]==c[i] && b[i]!=a[i]){
            ans++;
        }else if(c[i]==a[i] && c[i]!=b[i]){
            ans++;
        }else{
            ans+=2;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
n = int(input())
txy = [[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]

def distance(x1,y1,x2,y2):
    return(abs(x1-x2)+abs(y1-y2))
flag = True
for  i in range(1,n+1):
    dis = distance(txy[i][1],txy[i][2],txy[i-1][1],txy[i-1][2])
    if  not (dis <= txy[i][0]-txy[i-1][0] and (txy[i][0]-txy[i-1][0] - dis)%2==0):
        flag=False
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 28092
al=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
n=int(input())
S=list(input())
for s in S:
    i=al.index(s)
    #print(i)
    print(al[(i+n)%26],end="")

Measured memory_bytes: 4596
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        int N, M;
        in>>N>>M;
        vvc<int> G(N);
        REP(i, M){
            int a, b;
            in>>a>>b;
            a--, b--;
            G[a].pb(b);
            G[b].pb(a);
        }
        vvc<int> dp(1<<N, vc<int>(N, 0));
        dp[1][0] = 1;
        FOR(mask, 1, 1<<N) REP(j, N){
            if(not dp[mask][j]) continue;
            for(auto& u : G[j]){
                if((mask>>u&1)==0){
                    dp[mask|1<<u][u] += dp[mask][j];
                }
            }
        }
        int ans = 0;
        REP(j, N) ans += dp[(1<<N)-1][j];
        out<<ans<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        ll n[9];
        for (int j = 0; j < 9; j++) {
            string s;
            cin >> s;
            n[j] = stol(s, nullptr, 16);
        }
        uint ans = 0;
        ll over = 0;
        for (int j = 0; j < 32; j++) {
            int num = 0;
            for (int k = 0; k < 8; k++) {
                if (n[k] & (1 << j)) {
                    num++;
                }
            }
            over += num;
            if ((over % 2 == 0 && (n[8] & (1 << j))) || (over % 2 == 1 && !(n[8] & (1 << j)))) {
                ans += (1 << j);
                //cout << j << " " << num << " " << over << endl;
                over -= num;
                over += (8 - num);
            }
            over = over / 2;
        }
        cout << hex << ans << endl;
    }
}



Measured memory_bytes: 3048
def cityroadcount(n , m , a):
    reans = []
    for i in range(1 , n + 1):
        count = 0
        for w in range(m):
            count += int(a[w].count(i))
        reans.append(count)

    return reans

def main():
    n , m = map(int, input().split())
    a = [list(map(int,input().split())) for i in range(m)]

    ans = cityroadcount(n , m , a)
    for i in range(n):
        print(ans[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 38608