akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p){int res = 1; x = x % p;while (y > 0){    if (y & 1)        res = (res * x) % p;y = y >> 1;    x = (x * x) % p; } return res % p;}
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        int n;
        cin >> n;
        int l, r;
        cin >> l >> r;
        if(l%n==0){
            cout << "OK" << endl;
        }
        else{
            int f = l / n;
            f++;
            f *= n;
            if(f<=r){
                cout << "OK" << endl;
            }
            else{
                cout << "NG" << endl;
            }
        }
    }

    return 0;
}

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

typedef unsigned long long ullong;

ullong gcd(ullong a, ullong b){ return b==0?a: gcd(b, a%b);}
ullong lcm(ullong a, ullong b){ return a*(b/gcd(a, b));}

bool isRP(int x){
  if (  x == 13 || x == 17 || x == 19 || x == 23 ) return true;
  return false;
}

main(){
  int N;
  ullong D[100], S[100], T[100][24];
  ullong lcm1, lcm2, max1, max2;

  while(1){
    cin >> N;
    if ( N == 0 ) break;
    lcm1 = lcm2 = 1;
    max1 = max2 = 0;

    for ( int i = 0; i < N; i++ ){
      cin >> D[i] >> S[i];
      for ( int j = 0; j < D[i]; j++ ) cin >> T[i][j];
      if ( isRP(D[i])) {
	lcm2 = lcm(lcm2, D[i]);
      } else {
	lcm1 = lcm(lcm1, D[i]);
      }
    }

    for ( int j = 0; j < lcm1; j++ ){
      ullong sum = 0;
      for ( int i = 0; i < N; i++ ){
	if ( isRP(D[i]) ) continue;      
	sum += T[i][(j+S[i])%D[i]];
      }
      max1 = max(max1, sum);
    }

    for ( int j = 0; j < lcm2; j++ ){
      ullong sum = 0;
      for ( int i = 0; i < N; i++ ){
	if ( !isRP(D[i]) ) continue;      
	sum += T[i][(j+S[i])%D[i]];
      }
      max2 = max(max2, sum);
    }

    cout << max1 + max2 << endl;
  }
}

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

int main(){
string s,t;
  cin>>s>>t;
  bool a=false;
for(int i=0;i<s.size();i++){
if(s.at(i)!=t.at(i)){
a=true;
  break;
}
}
  if(a==true){
cout<<"No"<<endl;
  }
else{
cout<<"Yes"<<endl;
}
}
    

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	long M = 1000000007;
	long[] fac = new long[300001];
	long[] ifac = new long[300001];
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		//long n = Long.parseLong(sc.next());
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		//long a = Long.parseLong(sc.next());
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//ArrayList<Str_4> lists = new ArrayList<Str_4>();
		//lists = new ArrayList;
	    fac[0] = 1;
	    ifac[0] = 1;
	    for(int i = 0; i<300000; i++){
	        fac[i+1] = fac[i]*(i+1) % M;
	        ifac[i+1] = ifac[i]*mpow((long)(i+1), M-2l) % M; 
	    }
		PrintWriter out = new PrintWriter(System.out);
		for(int i =1; i <= k; i++)
		{
			long ans0 = comb(n-k+1, i);
			long ans1 = comb(k-i+i-1, i-1);
			out.println((ans0*ans1)%M);
		}
		
		out.flush();
    }
    long mpow(long x, long n){
        long ans = 1;
        while(n != 0){
            if(n%2==1) ans = ans*x % M;
            x = x*x % M;
            n = n >> 1;
        }
        return ans;
    }
    long comb(long a, long b){ //aCbをmod計算
        if(a == 0 && b == 0)return 1;
        if(a < b || a < 0)return 0;
        long tmp = ifac[(int)(a-b)]* ifac[(int)b] % M;
        return tmp * fac[(int)a] % M;
    }
    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }


}

Measured memory_bytes: 29012
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

int main() {
	ll a, b; cin >> a >> b;
	if (!(a + b & 1)) {
		cout << (a + b) / 2 << endl;
		return 0;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}


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

string X, Y;
int lc[1005][1005];

int getLCS(int m, int n) {
	if (m < 0 || n < 0)
		return 0;
	if (lc[m][n] != -1)
		return lc[m][n];
	if (X[m] == Y[n]) 
		return lc[m][n] = getLCS(m - 1, n - 1) + 1;
	else
		return lc[m][n] = max(getLCS(m, n - 1), getLCS(m - 1, n));
}

int main(void) {
	int i, j;
	int nu;
	cin >> nu;
	while (nu--) {
		for (i = 0; i < 1005; i++) 
			for (j = 0; j < 1005; j++) 
				lc[i][j] = -1;
		cin >> X >> Y;
		int m = X.length() - 1, n = Y.length() - 1;
		int lcs = getLCS(m, n);
		cout << lcs << endl;
	}
}


Measured memory_bytes: 7220
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 4e5+6;
const ll inf =1e18;
 
 



ll h[MAX],a[MAX];
map<ll,ll> m;
int main(){
	fastio;
	ll k,n,x,b,u,v,ans=0;
	cin>>n;
	f(i,1,n+1){
		cin>>h[i];
		a[i]=h[i]+i;
	}
	f(i,1,n+1){
		ans+=m[(i-h[i])];
		m[i+h[i]]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 29400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << ": " << x << '\n';

ll combo(ll n, ll r) {
  ll rtn = 1;
  for (ll i = n-r; i <= n; i++) {
    rtn *= i;
  }
  for (ll i = 1; i <= n - r; i++) {
    rtn /= i;
  }
  return rtn;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n;
  vector<ll> vec(n);
  ll a, b;
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    a = max(a, vec[i]);
  }

  for (int i = 0; i < n; i++) {
    if (vec[i] != a && min(k, a-k) <= min(vec[i], a-vec[i])) {
      k = vec[i];
    }
  }
  cout << a << " " << k << '\n';
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

int main() {
  	std::vector<int> v(5, 0);
    int dis;
	std::cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> dis;
    for (int i = 0; i < 5; ++i) {
    	for (int j = i + 1; j < 5; ++j) {
        	if (std::abs(v[i] - v[j]) > dis) {
            	std::cout << ":(" << std::endl;
                return 0;
            }
        } 
    }
  
  	std::cout << "Yay!" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>

using namespace std;
int n, m;
int a[200000];
int b[200000];
int vstd[200000];
int main(void) {
	cin >> n;

	int t;
	set<int> s;
	int cnt = 0;
	rep(i, n) {
		cin >> t;
		if (t >= 1 && t <= 399) {
			s.insert(1);
		}
		else if (t >= 400 && t <= 799) {
			s.insert(2);
		}
		else if (t >= 800 && t <= 1199) {
			s.insert(3);
		}
		else if (t >= 1200 && t <= 1599) {
			s.insert(4);
		}
		else if (t >= 1600 && t <= 1999) {
			s.insert(5);
		}
		else if (t >= 2000 && t <= 2399) {
			s.insert(6);
		}
		else if (t >= 2400 && t <= 2799) {
			s.insert(7);
		}
		else if (t >= 2800 && t <= 3199) {
			s.insert(8);
		}
		else {
			cnt++;
		}
	}
	int mn = s.size();
	if (s.size() == 0) {
		mn = 1;
	}
	cout << mn << " " << s.size() + cnt << endl;
	return 0;
}

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

int N, MOD;
const int MAX = 210000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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


int main() {
    cin >> N >> MOD;
    COMinit();
    long long res = 0;
    for (int R = 0; R <= N; ++R) {
        int B = N-R;
        
        // 包除原理
        long long tmp = 0;
        for (int r = 0; r <= R; ++r) {
            long long tmp2 = COM(R, r) * modpow((modpow(2LL, R-r, MOD) - 1 + MOD) % MOD, B, MOD) % MOD;
            if (r & 1) tmp = (tmp - tmp2 + MOD) % MOD;
            else tmp = (tmp + tmp2) % MOD;
        }
        
        // 自由度
        long long fac = COM(N, R) * modpow(2LL, R*(R-1)/2 + B*(B-1)/2, MOD) % MOD;
        tmp = (tmp * fac) % MOD;
        
        // 合計
        res = (res + tmp) % MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 8004
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int a,b;
	cin>>a>>b;
	int dif=b-a;
	cout<<dif*(dif+1)/2-b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b, c, d, e, k;

    cin >> a >> b >> c >> d >> e >> k;
    if((b-a)<=k&&(c-a)<=k&&(d-a)<=k&&(e-a)<=k&&(c-b)<=k&&(d-b)<=k&&(e-b)<=k&&(d-c)<=k&&(e-c)<=k&&(e-d)<=k){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum[105];
	cin>>n;
	sum[0]=0;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		sum[i]=sum[i-1]+a;
	}
	int ans=INT_MAX;
	for(int i=1;i<=n;i++)
	{
		int tmp;
		tmp=(sum[n]-2*sum[i])>0?(sum[n]-2*sum[i]):(-sum[n]+2*sum[i]);
		ans=min(ans,tmp);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)



int main(void){
  string a,b,c;cin>>a>>b>>c;


  int flag=1;
  char turn=a[0];
  a.erase(0,1);
  while(flag==1){
    if(turn == 'a'){
      if (a.size()==0){
        cout<<"A"<<endl;
        flag=0;
      }else{
        turn=a[0];
        a.erase(0,1);
      }
    }else if(turn =='b'){
      if(b.size()==0){
        cout<<"B"<<endl;
        flag=0;
      }else{
        turn=b[0];
        b.erase(0,1);
      }

    }else if(turn =='c'){
      if(c.size()==0){
        cout<<"C"<<endl;
        flag=0;
      }else{
        turn=c[0];
        c.erase(0,1);
      }
    }
  }
}


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

const int Maxn = 100005;

int n;
string S[Maxn];
int A, B, BA;
int res;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        cin >> S[i];
        for (int j = 0; j + 1 < S[i].length(); j++)
            if (S[i][j] == 'A' && S[i][j + 1] == 'B')
                res++;
        if (S[i][0] == 'B')
            if (S[i][int(S[i].length()) - 1] == 'A') BA++;
            else B++;
        else if (S[i][int(S[i].length()) - 1] == 'A') A++;
    }
    if (A == 0 && B == 0)
        res += max(0, BA - 1);
    else res += min(A, B) + BA;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define ALL(v) (v).begin(),(v).end()
#define FOR(i, n) for(ll (i)=0; (i)<(n); (i)++)
#define RFOR(i, n) for(ll (i)=(n)-1; (i)>=0; (i)--)
#define REP(i, x, n) for(ll (i)=(x); (i)<(n); (i)++)
#define RREP(i, x, n) for(ll (i)=(n)-1; (i)>=x; (i)--)

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

        ll N;
        string ans = "";
        cin >> N;
        while (0 < N) {
                char c = (char)('a' + (int)(N % 26 - 1));
                if (c == '`') {
                        c = 'z';
                        N -= 1;
                }
                ans = c + ans;
                N /= 26;
        }
        cout << ans << endl;

        return 0;
}

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

					#define M 1000000007
					using namespace std;
					typedef long long ll;
					ll n;
					ll mw(ll a, ll b)
					{
						if(!b)
							return 1;
						ll u = mw(a, b/2);
						u = (u*u) % M;
						if(b & 1)
							u = (u*a) % M;
						return u;		
					}
					ll c(ll n, ll k)
					{
						ll z = 1;
						for(ll i = n; i >= n - k + 1; i--) 
							z = (z * i) % M;
						for(ll i = 1; i <= k; i++) 
							z = (z * mw(i, M - 2)) % M;
						return z;
					}
					int main()
					{
						ll a, b, k = 1, p = 1, t;
						cin >> n >> a >> b;
						t = mw(2, n) - 1 - c(n, a) - c(n, b);
						cout << (t + 2*M) % M;
					}

Measured memory_bytes: 256
def resolve():
    a, b = map(int, input().split())
    s = input()
    if s.count("-") != 1:
        print("No")
        return

    c = s.split("-")
    if len(c) != 2:
        print("No")
        return
    if len(c[0]) == a and len(c[1]) == b:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void) {
	int num, odd = 0, a, i;
	cin >> num;
	for (i = 0; i < num; i++) {
		scanf("%d", &a);
		if (a & 1)
			odd++;
	}
	if (odd & 1)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
for i in range(0,n):
    s.append(int(input()))
sum = 0
s.sort()
for i in range(0,n):
    sum += s[i]

if sum%10==0:
    for i in range(0,n):
        if s[i]%10==0:
            continue
        else:
            sum -= s[i]
            break
if sum%10==0:
    print(0)
else:
    print(sum)


Measured memory_bytes: 3060
import itertools
import math

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

P = math.factorial(N)

paterns = list(itertools.permutations(A))
sum = 0

for _patern in paterns:
    patern = list(_patern)
    last = patern.pop(0)
    for point in patern:
        d = ((last[0] - point[0])**2 + (last[1] - point[1])**2)**0.5 / P
        sum = sum + d
        last = point

print(sum)


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

template<int MOD>
class mod_int {
	unsigned x;
public:
	mod_int() : x(0) { }
	mod_int(int sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	mod_int(long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	mod_int &operator+=(mod_int that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator-=(mod_int that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator*=(mod_int that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	mod_int &operator/=(mod_int that) { return *this *= that.inverse(); }

	mod_int operator+(mod_int that) const { return mod_int(*this) += that; }
	mod_int operator-(mod_int that) const { return mod_int(*this) -= that; }
	mod_int operator*(mod_int that) const { return mod_int(*this) *= that; }
	mod_int operator/(mod_int that) const { return mod_int(*this) /= that; }

	bool operator==(const mod_int& that) const { return x == that.x; }

	mod_int inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		return mod_int(u);
	}
};

template<int MOD>
istream& operator >> (istream& is, mod_int<MOD>& val) {
	long long x;
	is >> x; val = x;
	return is;
}

template<int MOD>
ostream& operator << (ostream& os, const mod_int<MOD>& val) {
	os << val.get();
	return os;
}

const int mod = 1e9 + 7;
using mint = mod_int<mod>;

const int X = 63;
mint dp[X + 1][2][2];

int main()
{
	ll N;
	cin >> N;
	dp[0][0][0] = 1;
	for (ll i = 0; i < X; i++) {
		for (int a = 0; a < 2; a++) {
			int lim = a ? 1 : (N >> (X - 1 - i)) & 1;
			for (int b = 0; b <= lim; b++) {
				int ta = a || b < lim;
				if (b) {
					dp[i + 1][ta][0] += dp[i][a][0];
					dp[i + 1][ta][1] += dp[i][a][0];
					dp[i + 1][ta][1] += dp[i][a][1];
				}
				else {
					dp[i + 1][ta][0] += dp[i][a][0];
					dp[i + 1][ta][0] += dp[i][a][1];
					dp[i + 1][ta][1] += dp[i][a][1];
				}
			}
		}
	}
	cout << dp[X][0][0] + dp[X][1][0] << endl;
	return 0;
}


Measured memory_bytes: 384
import collections
def f(mat):
	q,vis = collections.deque([((0,0), 1)]), set([(0,0)])
	while(q):
		u,d = q.popleft()
		if u == (len(mat)-1, len(mat[0])-1): return collections.Counter(reduce(lambda x,y:x+y, mat))['.'] - d
		for v in [(u[0]+1,u[1]), (u[0]-1,u[1]), (u[0],u[1]+1),(u[0],u[1]-1)]:
			if 0 <= v[0] < len(mat) and 0 <= v[1] < len(mat[0]) and (v not in vis) and mat[v[0]][v[1]] == '.':
				vis.add(v)
				q.append((v, d+1))
	return -1
print f([list(raw_input()) for l in range(map(int, raw_input().split())[0])])

Measured memory_bytes: 85936
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N;
    cin>>N;
    ll ans = 0;
    rep(i,1,N+1){
        if(i%3 == 0 || i % 5 == 0)continue;
        ans += i;
    }
    cout<<ans;
    return 0;
}   

Measured memory_bytes: 3572
// AOJ 0604: Take the 'IOI' train
// 2017.12.5 bal4u@uu

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

char s[2002], t[2002];
int dp[2][2002][2002];

int main()
{
	int n, m, i, j, ans;
	char *p;

	fgets(s, 20, stdin);
	sscanf(s, "%d%d", &m, &n);
	fgets(s, 2002, stdin);
	fgets(t, 2002, stdin);

	for (p = s; *p > ' '; p++) *p = (*p >> 1) & 1;
	for (p = t; *p > ' '; p++) *p = (*p >> 1) & 1;

	ans = 0;
	memset(dp[0], -1, sizeof(dp[0]));

	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			if (dp[s[i]][i+1][j] < dp[1-s[i]][i][j] + 1)
				dp[s[i]][i+1][j] = dp[1-s[i]][i][j] + 1;

			if (dp[t[j]][i][j+1] < dp[1-t[j]][i][j] + 1)
				dp[t[j]][i][j+1] = dp[1-t[j]][i][j] + 1;

			if (ans < dp[0][i][j]) ans = dp[0][i][j];
		}
		if (dp[s[i]][i+1][n] < dp[1-s[i]][i][n] + 1)
			dp[s[i]][i+1][n] = dp[1-s[i]][i][n] + 1;
		if (ans < dp[0][i][n]) ans = dp[0][i][n];
	}
	for (j = 0; j < n; j++) {
		if (dp[t[j]][m][j+1] < dp[1-t[j]][m][j] + 1)
			dp[t[j]][m][j+1] = dp[1-t[j]][m][j] + 1;
		if (ans < dp[0][m][j]) ans = dp[0][m][j];
	}
	if (ans < dp[0][m][n]) ans = dp[0][m][n];

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 33168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int minv=0,x,y,z;
	x=a+b;
	y=a-b;
	z=a*b;
	if(x>=y&&x>=z)
	minv=x;
	else if(z>x&&z>y)
	minv=z;
	else
	minv=y;
	cout<<minv;
	return 0;
}

Measured memory_bytes: 256
N,MA,MB = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

INF = 10**9
MAX = 401
dp = [[INF] * MAX for i in range(MAX)]
dp[0][0] = 0
amax = bmax = 0
for a,b,n in src:
    for i in reversed(range(bmax+1)):
        for j in range(amax+1):
            if dp[i][j] == INF: continue
            dp[i+b][j+a] = min(dp[i+b][j+a], dp[i][j] + n)
    amax += a
    bmax += b

ans = INF
for i in range(1,MAX):
    if i*MA >= MAX or i*MB >= MAX: break
    ans = min(ans, dp[i*MB][i*MA])
print(-1 if ans == INF else ans)

Measured memory_bytes: 4852
#include <iostream>

using namespace std;

int main(void){
  long long int x, y, mod, min = 1000, sum;
  cin >> x;
  y = x;
  while(y >= 100){
    mod = y % 1000;
    sum = abs(mod - 753);
    if(min > sum){
      min = sum;
    }
    y /= 10;
  }
  cout << min << endl;
  return 0;
}

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

int main()
{
    string t;
    cin >> t;

    rep(i,t.size())
    {
        if(t[i] != '?') continue;
        if(i == t.size()-1) t[i] = 'D';
        else if(i != 0 && t[i-1] == 'P') t[i] = 'D';
        else if(t[i+1] == 'D') t[i] = 'P';
        else t[i] = 'D';
    }
    cout << t << endl;
}


Measured memory_bytes: 3760
import java.util.Scanner;

class Main{

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();
        int f1,f2;
        double f3;
        f1 = a / b;
        f2 = a % b;
        f3 = (double)a / (double)b;
        
        System.out.println(f1);
        System.out.println(f2);
        System.out.println(String.format("%.5f",f3));

        
    }
}


Measured memory_bytes: 26440
#include <iostream>

using namespace std;

bool start[210000];
bool goal[210000];

int main()
{
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		if(a == 1) start[b] = true;
		if(b == N) goal[a] = true;
	}

	for(int i = 0; i < N; i++) {
		if(start[i] && goal[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll solve(string s, ll k)
{
    ll d = 0, c = 0, m = 0, mc = 0;
    vll m1(s.size(), 0);
    for(ll i = 0; i < k; i++)
    {
        if(s[i] == 'D')
            d++;
        else if(s[i] == 'M')
            m += d, m1[i] = d, mc++;
        else if(s[i] == 'C')
            c += m;
    }
    for(ll i = k; i < s.size(); i++)
    {
        if(s[i - k] == 'D')
        {
            m -= mc;
            d--;
        }
        else if(s[i - k] == 'M')
            mc--;
        if(s[i] == 'D')
            d++;
        else if(s[i] == 'M')
            m += d, mc++, m1[i] = d;
        else if(s[i] == 'C')
            c += m;
    }
    return c;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    string s;
    ll n, q, i;
    cin >> n >> s >> q;
    vll k(q);
    for(i = 0; i < q; i++)  
        cin >> k[i];
    for(auto x : k)
        cout << solve(s, x) << endl;
    return 0;
}

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

struct Problem {

    void Solve() {
        UL N, L, R; cin >> N >> L >> R;
        cout << (((L - 1) / N < R / N) ? "OK" : "NG") << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3600
// In the name of Aadi Shakti
    // We are nothing and you are everything
    // Jai Mata Di
     
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        long long n ;
        cin >> n ;
        long long last = n % 10 ;
        if ( last == 2 or last == 4 or last == 5 or last == 7 or last == 9) 
            cout << "hon" << endl ;
        else if (last == 0 or last == 1 or last == 6 or last == 8)
            cout << "pon" << endl; 
        else if(last == 3)
            cout << "bon" << endl ;
        return 0 ;
    }

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

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

    int n,k,mx = 0,gc;
    bool pos = false;

    cin >> n >> k;

    vector<int> a(n);

    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        mx = max(mx,a[i]);
        if(a[i]==k) pos = true;
        if(i==0) gc = a[i];
        else gc = __gcd(gc,a[i]);
    }

    if(pos){ cout << "POSSIBLE"; return 0; }
    if(mx<k or n==1){ cout << "IMPOSSIBLE"; return 0; }

    if(k%gc==0){ cout << "POSSIBLE"; return 0; }
    else cout << "IMPOSSIBLE";
}


Measured memory_bytes: 640
N,M,Q=map(int,input().split())

al=list()

for i in range(Q): 
    a,b,c,d=map(int,input().split())
    al.append([a,b,c,d])


Sum=0
Summax=0
cnt=0
for i1 in range(1,M+1): 
    for i2 in range(i1,M+1): 
        for i3 in range(i2,M+1): 
            for i4 in range(i3,M+1): 
                for i5 in range(i4,M+1): 
                    for i6 in range(i5,M+1): 
                        for i7 in range(i6,M+1): 
                            for i8 in range(i7,M+1): 
                                for i9 in range(i8,M+1): 
                                    for i10 in range(i9,M+1): 
                                        cnt+=1
                                        Al=[i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        Sum=0
                                        for i in range(Q): 
                                            if(Al[al[i][1]-1]-Al[al[i][0]-1]==al[i][2]):
                                                Sum+=al[i][3]
                                        if(Summax<Sum):
                                            Summax=Sum

print(Summax)    
#print(cnt)

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

int main(void) {
  int N;
  cin >> N;
  vector<string> ss(N);

  for(int i=0;i<N;i++) {
    cin >> ss.at(i);
    sort(ss.at(i).begin(), ss.at(i).end());
  }
  sort(ss.begin(), ss.end());

  llong ans = 0, tmp = 1;
  for(int i=0;i<N-1;i++) {
    if(ss.at(i)==ss.at(i+1)) { 
      tmp++;
      if(i==N-2) {
        ans += tmp*(tmp-1)/2;
      }
    }
    else { 
      ans += tmp*(tmp-1)/2;
      tmp = 1;
    }
  }

  cout << ans << endl;

  return (0);
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    string S;
    ll K;
    cin >> S >> K;

    char ans = 'X';
    for (ll i = 0; i < (int)S.size(); i++) {
        if ((S[i] == '1' && i == K-1) || (S[i] >= '2')) {
            ans = S[i];
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
need=[tuple(map(int,input().split())) for i in range(M)]
ans=0
need.sort(key=lambda x:x[1])
bef=1
for a,b in need:
    if a<bef:
        continue
    else:
        ans+=1
        bef=b
print(ans)

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

constexpr int INF = 1e9;

struct edge {
    int to, weight;
};

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<vector<edge>> es(n);
        for(int i=0; i<m; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            es[a].emplace_back((edge){b, c});
            es[b].emplace_back((edge){a, c});
        }

        vector<vector<int>> d(n, vector<int>(3, INF));
        using state = tuple<int, int, int>;
        priority_queue<state, vector<state>, greater<state>> que;
        que.push(make_tuple(0, 0, 0));
        d[0][0] = 0;
        while(!que.empty()) {
            int cd, v, flag;
            tie(cd, v, flag) = que.top();
            que.pop();
            if(d[v][flag] < cd) {
                continue;
            }
            for(auto& e : es[v]) {
                if(flag < 2 && d[e.to][flag+1] > d[v][flag]) {
                    d[e.to][flag+1] = d[v][flag];
                    que.push(make_tuple(d[e.to][flag+1], e.to, flag+1));
                }
                if(flag != 1 && d[e.to][flag] > d[v][flag] + e.weight) {
                    d[e.to][flag] = d[v][flag] + e.weight;
                    que.push(make_tuple(d[e.to][flag], e.to, flag));
                }
            }
        }
        cout << d[n-1][2] << endl;
    }
}


Measured memory_bytes: 3128
#include<iostream>
#include<cmath>
#include<numeric>
#include<array>
#include<vector>
#include<sstream>
using namespace std;

int main(){
	int H,W,h,w;
	cin >> H >> W >> h >> w;
	cout << H*W - h*W - w*H + h*w << endl;
	return 0;
}

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

int main(){
  int a,b,wid;
  while(cin>>a){
    b=0;
    wid= 600/a;
    for (int i=0;i<wid;i++){
      b += i*a*i*a*a;
    }
    cout << b << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>

int n=6,i,j,x[6],up,t;

void N(){
    t = x[1];
    x[1] = x[2];
    x[2] = x[6];
    x[6] = x[5];
    x[5] = t;
}

void S(){
    t = x[1];
    x[1] = x[5];
    x[5] = x[6];
    x[6] = x[2];
    x[2] = t;
}

void W(){
    t = x[1];
    x[1] = x[3];
    x[3] = x[6];
    x[6] = x[4];
    x[4] = t;
}

void E(){
    t = x[1];
    x[1] = x[4];
    x[4] = x[6];
    x[6] = x[3];
    x[3] = t;
}

int main(void){
    char ord[100];

    
    for(i = 1;i <= n;i++) scanf("%d",&x[i]);
    scanf("%s",ord);
    for(j=0;j<strlen(ord);j++){
        if(ord[j] == 'N'){
            N();
        }else if(ord[j] == 'S'){
            S();
        }else if(ord[j] == 'W'){
            W();
        }else if(ord[j] == 'E'){
            E();
        }
    }
    printf("%d\n",x[1]);
}



Measured memory_bytes: 1848
import scala.io.StdIn

object Main {
  def main(args: Array[String]) {
    var arr: Array[String] = StdIn.readLine().split(" ")
    var stack: Array[String] = Array.empty
    for(v <- arr) {
      stack = calc(stack, v)
    }
    println(stack(0))
  }

  def calc(stack: Array[String], v: String): Array[String] = {
    var ret = stack.clone()
    if(v != "+" && v != "-" && v != "*") return ret :+ v

    val y = ret.last.toInt
    ret = ret.dropRight(1)
    val x = ret.last.toInt
    ret = ret.dropRight(1)

    if(v == "+") {
      return ret :+ (x + y).toString
    } else if(v == "-") {
      return ret :+ (x - y).toString
    } else {
      return ret :+ (x * y).toString
    }
  }
}

Measured memory_bytes: 43604
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<algorithm>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define ll long long 
#define mod 998244353
using namespace std;



int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    _cin;

    char a;
    cin>>a;
    if(a <='Z' && a>= 'A')cout<<'A';
    else cout<<'a';
    

}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

void Yes(){
	cout<<"Yay!"<<endl;
}
void No(){
	cout<<":("<<endl;
}

signed main(){

	lli t1,t2;
	cin>>t1>>t2;

	lli a1,a2,b1,b2;
	cin>>a1>>a2>>b1>>b2;

	//1周期で距離が離れない場合はinfinity

	lli v1,v2;
	v1 = t1*a1 + t2*a2;
	v2 = t1*b1+t2*b2;

	if(DEBUG)cout<<"v1="<<v1<<" v2="<<v2<<endl;

	if(v1==v2){
		cout<<"infinity"<<endl;
		return 0;
	}

	lli diff1 = t1*a1-t1*b1;
	lli diff2 = t1*a1+t2*a2 - (t1*b1+t2*b2);
	if(DEBUG)cout<<"diff1="<<diff1<<"diff2="<<diff2<<endl;

	if( ((diff1 < 0) && (diff2<0)) || ((diff1>0) && (diff2>0))){
		cout<<0<<endl;
		return 0;
	}

	if(abs(diff1) == abs(diff2)){
		cout<<"infinity"<<endl;
		return 0;
	}

/*
	lli div = abs(abs(diff1)-abs(diff2));
	lli target = min(abs(diff1),abs(diff2));
	*/
	diff1 = abs(diff1);
	diff2 = abs(diff2);
	lli target = diff2-diff1;

	if(DEBUG)cout<<" target="<<target<<endl;
	if(DEBUG)cout<<"diff1 diff2="<<(diff1%diff2)<<endl;
	cout<<(1+2*(diff1/diff2)+ ((diff1%diff2==0)?-1:0))<<endl;
	
	return 0;
}

Measured memory_bytes: 256
s = input()
 
res = True
for i in range(len(s)):
  if i % 2 == 0 and s[i] == 'L':
    res = False
    break
  if i % 2 == 1 and s[i] == 'R':
    res = False
    break
 
if res:
  print("Yes")
else:
  print("No")

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

const ll MOD = 1000000007;

int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> S(N), T(M);
  for (int i = 0; i < N; i++) cin >> S[i];
  for (int i = 0; i < M; i++) cin >> T[i];

  vector<vector<ll>> dp(N, vector<ll>(M)), sum(N, vector<ll>(M));
  dp[0][0] = sum[0][0] = (S[0] == T[0]);
  for (int i = 1; i < N; i++) {
    dp[i][0] = (S[i] == T[0]);
    sum[i][0] = sum[i - 1][0] + dp[i][0];
  }
  for (int j = 1; j < M; j++) {
    dp[0][j] = (S[0] == T[j]);
    sum[0][j] = sum[0][j - 1] + dp[0][j];
  }
  for (int i = 1; i < N; i++) {
    for (int j = 1; j < M; j++) {
      dp[i][j] = S[i] == T[j] ? sum[i - 1][j - 1] + 1 : 0;
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + dp[i][j];
      sum[i][j] = (sum[i][j] + MOD) % MOD;
    }
  }
  cout << (sum[N - 1][M - 1] + 1) % MOD << endl;
}

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

int main()
{
    int n,a[51]= {};
    cin>>n;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    int j;
    for(int i = 0; i < n; i++)
    {
        for( j = i+1; j <n; j++)
        {
            if(i!=j)
                sum += a[i]*a[j];
        }
    }
    cout <<sum;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
  int i,j;
  int n;
  int max=1;
  int f;
  int ans=1;
  scanf("%d",&n);
  j=(int)sqrt(n);
  for(i=2;i<=n;i++){
    max =1;
    f=0;
    while(max*i<=n){
      max *= i;
      f++;
    }
    if(max>ans && f>1){
      ans=max;
    }
  }
  printf("%d\n",ans);
  return 0;
}


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

int main(){
  int N ;
  cin >> N ;
  int sum = 0 ;
  int ans1 = 0 ;
  int ans2 =0;
  vector<int> A(110) ;
  for(int i=0;i<N;i++){
   cin >> A[i] ;
    sum += A[i] ;
  }
   sum /= N ;
  
  for(int i=0;i<N;i++){
    ans1 += (A[i]-sum)*(A[i]-sum);
  }
  for(int i=0;i<N;i++){
    ans2 += (A[i]-sum-1)*(A[i]-sum-1);
  }
  cout << min(ans1,ans2) << endl;
  
}
  


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{

	const double pi = 3.14159265358979323846;
	double r;
	cin >> r;
	cout <<setprecision(17)<< r* r *pi << " " <<setprecision(17)<< 2 * r*pi << endl;
	return 0;
}
/*
*/

/*
	int n;
	cin >> n;
	VEC nums(n);
	int sum=0;
	loop(i, n)
	{
		cin >> nums[i];
		sum += nums[i];
	}
	sort(nums.begin(), nums.end());
	cout << nums[0] << " " << nums[n - 1] << " " << sum << endl;
*/


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

int main() {
  int n;
  cin >> n;
  std::vector<int> vec(n-1);
  rep(i,n-1) cin >> vec.at(i);
  vec.push_back(1e5);
  int total = vec.at(0);
  rep(i,n-1) {
    total += min(vec.at(i), vec.at(i+1));
  }
  cout << total << endl;

}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
using namespace std;
int main(){
	int b[4], c[4];
	for (int i = 0; i < 4; i++){
		cin  >> b[i] >> c[i];
	}
	for (int i = 0; i < 4; i++){
		if (b[i] == 1){ cout << 6000 * c[i] << endl; }
		else
		{cout << (6-b[i])*1000 * c[i] << endl;}
	}
	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <iterator>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, a;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		if (!(a%2) && a%3 && a%5){
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
ds = dict()
dt = dict()
ni = 1
for i in range(len(s)):
    si = s[i]
    ti = t[i]
    if not si in ds:
        ds[si] = ni
        if ti in dt:
            print("No")
            exit()
        else:
            dt[ti] = ni
            ni += 1
    elif (not ti in dt) or (not ds[si] == dt[ti]):
        print("No")
        exit()

print("Yes")


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

using namespace std;

vector<pair<int, int> > v[15];
int n;

bool check(int mask)
{
    int ok[15];
    memset(ok, -1, sizeof ok);
    for(int i=0; i<n; i++){
        if(mask&(1<<i)){
            ok[i] = 1;
        }
        else ok[i] = 0;
    }
    for(int i=0; i<n; i++){
        if(ok[i] == 0) continue;
        for(int j=0; j<v[i].size(); j++){
            int id = v[i][j].first, x = v[i][j].second;
            if(ok[id] != x) return false;
        }
    }
    return true;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        int x;
        scanf("%d", &x);
        for(int j=0; j<x; j++){
            int a, b;
            scanf("%d %d", &a, &b);
            a--;
            v[i].push_back(make_pair(a, b));
        }
    }
    int maxs = 0;
    for(int mask = 0; mask < (1<<n); mask++){
        if(check(mask)){
            int cnt = __builtin_popcount(mask);
            maxs = max(maxs, cnt);
        }
    }
    cout << maxs;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <bitset>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll sqrt_n = 750;
ll n_sqrt_n = 268;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M;
    cin >> N >> M;
    vector<ll> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    sort(all(A));
    vector<ll> C(sqrt_n + 1);
    for(ll i = 1; i <= sqrt_n; i++) {
        rep(j, N) {
            C[i] += A[j] % i;
        }
    }
    
    vector<ll> sum(N + 1);
    rep(i, N) {
        sum[i + 1] = sum[i] + A[i];
    }
    ll ans = 0;
    rep(i, M) {
        if(B[i] <= sqrt_n) {
            ans += C[B[i]];
        }
        else {
            vector<long> T(n_sqrt_n + 2);
            auto it = A.begin();
            for(ll j = 0; j < n_sqrt_n + 2; j++) {
                it = lower_bound(it, A.end(), j * B[i]);
                T[j] = it - A.begin();
            }
            
            for(ll j = 0; j <= n_sqrt_n; j++) {
                if(T[j + 1] > T[j]) {
                    ans += sum[T[j + 1]] - sum[T[j]] - (B[i] * j * (T[j + 1] - T[j]));
                }
            }
           
        }
    }
    output(ans);
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 7600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

int H, W;
vector<string> fi;
int Left[2020][2020],Right[2020][2020],Up[2020][2020],Down[2020][2020];



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

cin >> H >> W;
fi.resize(H);
rep(h,H) cin >> fi[h];


rep(h,H) {
    int cur = 0;
    rep(w,W) {
        if(fi[h][w] == '#') cur = 0;
        else cur++;
        Left[h][w] = cur;
    }
}

rep(h,H) {
    int cur = 0;
    drep(w,W) {
        if(fi[h][w] == '#') cur = 0;
        else cur++;
        Right[h][w] = cur;
    }
}

rep(w,W) {
    int cur = 0;
    rep(h,H) {
        if(fi[h][w] == '#') cur = 0;
        else cur++;
        Up[h][w] = cur;
    }
}

rep(w,W) {
    int cur = 0;
    drep(h,H) {
        if(fi[h][w] == '#') cur = 0;
        else cur++;
        Down[h][w] = cur;
    }
}

vvi Total(H,vi(W));
int ans = 0;

rep(h,H) rep(w,W) {
    Total[h][w] = Left[h][w] + Right[h][w] + Up[h][w] + Down[h][w] - 3;
    ans = max(ans ,Total[h][w]);
}

cout << ans << endl;


return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int k = 1 << M;
	ll sum = 100 * (N-M) + 1900 * M;
	cout << sum*k << endl;


	return 0;
}

Measured memory_bytes: 256
//3で割り切れる：6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96
//5で割り切れる：10,20.30,40,50,60,70,80,90,100

import java.util.*;
class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] array = new int[n];
        
        for(int i=0 ; i<n ; i++){
            array[i] = sc.nextInt();
        }
        
        for(int i=0 ; i<n ; i++){
            if(array[i]%2==0){
                if((array[i]%3!=0)&&(array[i]%5!=0)){
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        
        System.out.println("APPROVED");
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, K;
    cin >> N >> K;
    vector<int> pos, neg;
    rep(i, N) {
        int a;
        cin >> a;
        if(a >= 0) pos.pb(a);
        else neg.pb(-a);
    }
    
    reverse(all(neg));
    int ans = inf;
    if(pos.size() >= K) {
        ans = min(ans, pos[K - 1]);
    }
    if(neg.size() >= K) {
        ans = min(ans, neg[K - 1]);
    }
    for(int i = 0; i < K; i++) {
        if(i >= pos.size()) continue;
        if(K - i - 2 >= neg.size()) continue;
        int p = pos[i];
        int n = neg[K - i - 2];
        ans = min(ans, min(p, n) + p + n);
    }
    
    
    output(ans);
    
    return 0;
}


Measured memory_bytes: 1020