akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll N, C;
    cin >> N >> C;

    vector<ll> x(N);
    vector<ll> v(N);

    for(int i = 0; i < N; i++) cin >> x[i] >> v[i];

    //原点から時計回りに回った時に得られる量の最大値

    vector<ll> sumCW(N);
    ll sum = 0;
    for(int i = 0; i < N; i++){
        sum+= v[i];
        sumCW[i] = sum - x[i];
    }

    vector<ll> limitCW(N);
    ll curMaxCW = 0;
    for(int i = 0; i <N; i++){
        if(curMaxCW < sumCW[i]){
            limitCW[i]= sumCW[i];
            curMaxCW = sumCW[i];
        } else {
            limitCW[i]= curMaxCW;
        }
    }


    vector<ll> sumCCW(N);
    sum = 0;
    for(int i = N-1; i >= 0; i--){
        sum+= v[i];
        sumCCW[i] = sum - (C - x[i]);
    }

    vector<ll> limitCCW(N);
    ll curMaxCCW = 0;
    for(int i = N-1; i >=0; i--){
        if(curMaxCCW < sumCCW[i]){
            limitCCW[i]= sumCCW[i];
            curMaxCCW = sumCCW[i];
        } else {
            limitCCW[i]= curMaxCCW;
        }
    }

    ll ans = max(curMaxCW, curMaxCCW);

    for(int i = 0; i < N-1; i++){
        ll tmp = sumCW[i] + limitCCW[i+1] - x[i];
        ans = max(ans, tmp);
    }

    for(int i = N-1; i > 0; i--){
        ll tmp = sumCCW[i] + limitCW[i-1] -(C - x[i]);
        ans = max(ans, tmp);
    }

    if(ans > 0) cout << ans << endl;
    else cout << 0 << endl;
    
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(){
    const int eightdivisors_nums[] = {195, 189, 165, 135, 105};
    int N;
    cin >> N;
    for (int i = 0; i < 5; i++){
        if (N >= eightdivisors_nums[i]){
            cout << 5 - i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
string S[200001];
int main(){
	int N;

	map<string,int> cnt;
	int cntmax=0;
	scan(N);
	rep(i,N){
		scan(S[i]);
		cnt[S[i]]++;
		cntmax=max(cntmax,cnt[S[i]]);
	}
	for(auto x:cnt){
		if(x.second==cntmax) prin(x.first);
	}
	return 0;
}


Measured memory_bytes: 26752
// written by IftekharMd.Shishir   :)   12.4.2020

#include<bits/stdc++.h>

#define ll          long long int
#define ull         unsigned long long int
#define f(i,n)      for(i=0;i<n;i++)
#define F(i,n)      for(i=n;i>=0;i--)
#define fa(i,a,b)   for(i=a;i<b;i++)
#define Fa(i,a,b)   for(i=a;i>=b;i--)
#define vec         vector<long long int>
#define que         queue<long long int>        //a.push(x)   a.pop()    a.back()    a.front()
#define pb(x)       push_back(x)
#define pob()       pop_back()
#define sor(a)      sort(a.begin(),a.end())
#define rev(a)      reverse(a.begin(),a.end())  // string or array reverse
#define ins(a,x)    insert(a.begin(),x)         // push in front
#define points(x)   fixed<<setprecision(x)
#define done        return 0

/*----------[ string to integer ]--------------
string str;  int x=0;
stringstream demo(str);
demo >> x;
cout<< x <<endl;
*/

/*----------[ integer to string ]--------------
string name;  int x=345;
stringstream demo;
demo << x;
name=demo.str();
cout<< name <<endl;
*/
using namespace std;

int main()
{
    ll i;
    string a;
    cin>>a;
    f(i,a.size()){
        if(a[i]=='7'){cout<<"Yes"<<endl; done;}
    }
    cout<<"No"<<endl;
    done;
}






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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m;cin>>n;
    int arr[n];
    int s=0;
    for (int i=0;i<n;i++){
        cin>>arr[i];
        s+=arr[i];
    }cin>>m;
    int d1[m],d2[m];
    for (int i=0;i<m;i++){
        cin>>d1[i]>>d2[i];
        cout<<s-arr[d1[i]-1]+d2[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
    public static void main(String []args)
    {
        Scanner scan = new Scanner(System.in);
        int N,R;
        N = scan.nextInt();
        R = scan.nextInt();
        int IR;
        if(N>=10)
        {
            IR = R;
        }
        else
        {
            IR = R + 100*(10-N);
        }
        System.out.println(IR);
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double EPS = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in(){int x;std::cin>>x;return x;}

using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int> >;
using vl = vector<long long>;
using vp = vector<pint>;

template <typename T> void print(T x) { std::cout << x << '\n'; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T*)array, (T*)(array + N), val);
}
signed main(){
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<a+b<<endl;
  }else{
    a = a < b? b:a;
    print(a+a-1);
  }
  return 0;
}


Measured memory_bytes: 256
#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);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 vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%3d", arr[i][j]); } cout << endl; }

using namespace std;

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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int n, m, k[10];
int p[10];
vector<int> s[10];

int main() {
    int st;
    cin >> n >> m;
    rep(i, m) {
        cin >> k[i];
        rep(j, k[i]) {
            cin >> st;
            s[i].push_back(st - 1);
        }
    }
    int ans = 0;
    rep(i, m)
        cin >> p[i];
    rep(i, 1 << n) {// all possible way to turn on/off
        vector<int> dp(n); // hold the state for each switch
        int onN = 0;
        rep(j, n) {
            dp[j] = (i >> j) & 1 == 1; //ith state is 1 if ith switch is on
        }
        rep(j, m) {
            int on = 0;
            rep(l, s[j].size()) {
                on += dp[s[j][l]];
            }
            if (on % 2 == p[j])onN++;
        }
        if(onN == m){
            ans++;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	int ret=h+w;
	for(int i=0;i<=h;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i*w+j*h-i*j>=n) ret=min(ret,i+j);
		}
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 256
s = input()

i, j = 0, len(s)-1
ans = 0
while i < j:
    if s[i] == s[j]:
        i, j = i+1, j-1
    elif s[i] == 'x':
        i += 1
        ans += 1
    elif s[j] == 'x':
        j -= 1
        ans += 1
    else:
        ans = -1
        break

print(ans)

Measured memory_bytes: 3316
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
typedef pair<int, int> pii;
const int maxn = 1000005;
vector<pii> ver, line[maxn];
vector<int> g[maxn];
int n, m, fa[maxn], cur, was[maxn], newn, dis[maxn];
int getfa(int u) {
    return fa[u] == u ? u : fa[u] = getfa(fa[u]);
}
void merge(int u, int v) {
    if (was[u] != cur) {
        was[u] = cur;
        ver.pb(pii(0, u));
        fa[u] = u;
    }
    if (was[v] != cur) {
        was[v] = cur;
        ver.pb(pii(0, v));
        fa[v] = v;
    }
    fa[getfa(u)] = getfa(v);
}
int main() {
	//freopen("trip.in","r",stdin);
	//freopen("trip.out","w",stdout);
    scanf("%d %d", &n, &m), newn = n;
    for (int u, v, w, i = 1; i <= m; i++) {
        scanf("%d %d %d", &u, &v, &w);
        line[w].pb(pii(u, v));
    }
    for (int i = 1; i <= 1000000; i++) {
        ver.clear(), ++cur;
        for (int j = 0; j < line[i].size(); j++) {
            merge(line[i][j].x, line[i][j].y);
        }
        for (int j = 0; j < ver.size(); j++) {
            ver[j].x = getfa(ver[j].y);
        }
        sort(ver.begin(), ver.end());
        for (int j = 0, k = 0; j < ver.size(); j = k) {
            ++newn;
            while (k < ver.size() && ver[j].x == ver[k].x) {
                g[newn].pb(ver[k].y);
                g[ver[k++].y].pb(newn);
            }
        }
    }
    queue<int> que;
    que.push(1);
    for (int i = 2; i <= newn; i++) {
        dis[i] = -2;
    }
    dis[1] = 0;
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (int i = 0; i < g[u].size(); i++) {
            int v = g[u][i];
            if (dis[v] == -2) {
                dis[v] = dis[u] + 1;
                que.push(v);
            }
        }
    }
    printf("%d\n", dis[n] >> 1);
    return 0;
}


Measured memory_bytes: 73984
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [10**9]*N
dp[0] = 0
for i in range(1, N):
  for j in range(1, K+1):
    if i >= j:
      dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))

print(dp[N-1])

Measured memory_bytes: 52448
N = int(input())
L = list(map(int, input().split()))
L.sort()
#print(L)
ans = 0
def find(x, arr):
  a = len(arr)//2
  cur = a
  while True:
    a //= 2
    if arr[cur] < x:
      if cur == len(arr)-1:
        return cur+1
      elif arr[cur+1] >=x:
        return cur+1
      else:
        cur += max(1,a)
    else:
      if cur == 0:
        return 0
      else:
        cur -= max(1, a)
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += find(L[i] + L[j], L)-j-1
print(ans)

Measured memory_bytes: 48668
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
signed main() {
	ll n = 0, k, a, mae = 0, ans = 0; cin >> n >> k;
	vector<ll> v(n);
	for (int h = 0; h < n; h++) {
		cin >> v[h];
	}
	sort(v.begin(), v.end());
	ans = abs(k - v[0]);
	for (int h = 1; h < n; h++) {
		ans = gcd(ans, v[h] - v[h - 1]);
	}
	cout << ans << endl;
	cin >> n; return 0;
}

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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    string s;
    cin >> s;
    int ans = 0;
    if(s == "RRR") {
        ans = 3;
    } else if(s[1] == 'R' && (s[0] == 'R' || s[2] == 'R')) {
        ans = 2;
    } else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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

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


Measured memory_bytes: 3616
x,y = map(int,input().split())
# al = list(map(int,input().split()))

a =[1,3,5,7,8,10,12]
b = [4, 6,9,11]
c = [2]

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x in c and y in c:
    print('Yes')
else:
    print('No')


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

const long double PI = acos(-1);
const long double EPS = 0.0000000001;

long double a,b,x;

void input(){
    cin >> a >> b >> x;
}
long double f(long double a,long double b,long double theta){
    if(theta >PI/2.0-EPS){
        return 0.0;
    }
    long double ret;
    if(a*tan(theta)<=b){
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    }else{
        ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}
void solve(){
    input();
    long double ok = PI / 2.0;
    long double ng = 0.0;
    for (int _ = 1; _ <= 10000;_++){
        long double mid = (ok + ng) / 2.0;
        if(f(a,b,mid)<x)
            ok = mid;
        else
            ng = mid;
    }
    cout << fixed << setprecision(10) << ok / PI * 180 << endl;
    return;
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])

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

using namespace std;
int dp[1001][1001];
char ch[1001][1001];
int main()
{
    int n,m;
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            cin >> ch[i][j];
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            if(ch[i][j] == '#')
                dp[i][j] = 0;
            dp[1][1] = 1;
          dp[i][j] %= 1000000007;
        }
    }
    cout << dp[n][m] << "\n";
    return 0;
}


Measured memory_bytes: 5120
# https://atcoder.jp/contests/abc093/tasks/arc094_a


A, B, C = gets.split.map(&:to_i)

x = [A, B, C]
  .group_by { |v| v % 2 }
  .map { |_k, vs| vs.size == 2 ? vs.map(&:succ) : vs }
  .flatten
  .max
ans = (x * 3 - A - B - C) / 2

puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5 ;
const int INF = 1e9 + 1e5 + 2;
const int mod= 1e9+7;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
#define eps 1e-15
#define F first
#define S second
typedef long long ll;
ll fib[100006];
int main()
{
    fastIO
    string s;
    cin>>s;
    int a=s[0]-'0';
    int b=s[1]-'0';
    int c=s[2]-'0';
    int d=s[3]-'0';
    if (a+b+c+d==7)
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7;
    else if (a-b-c-d==7)
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7;
    else if (a-b+c+d==7)
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7;
    else if (a+b-c+d==7)
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7;
    else if (a+b+c-d==7)
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7;
    else if (a-b-c+d==7)
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7;
    else if (a-b+c-d==7)
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7;
    else  if (a+b-c-d==7)
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7;




}


Measured memory_bytes: 3628
i=require("fs").readFileSync("/dev/stdin","utf8").split('\n'),w=+i[0],a=[];for(;a[w]=w--;);i.map(function(j){k=j.split(','),l=+k[0],m=+k[1];if(m)t=a[l],a[l]=a[m],a[m]=t});console.log(a.slice(1).join('\n'))

Measured memory_bytes: 7380
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//int x=Integer.parseInt(args[0]);
Scanner sc = new Scanner(System.in);
 int x = sc.nextInt();
 int answer =1;
 for(int i=0;i<3;i++){
	 answer=answer*x;
 }
System.out.println(answer);
}}

Measured memory_bytes: 17172
# coding: utf-8
N = int(input())

k = N//3
l = N //5
h = N //15

sum3 = (3 * k + 3) * k // 2
sum5 = (5 * l + 5) * l // 2
sum15 = (15 * h + 15) * h // 2
sum = N * (N + 1) // 2
print(sum-sum3-sum5+sum15)

Measured memory_bytes: 9184
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


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

    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
        --A[i];
    }

    vector<int> pos;
    vector<bool> visited(N, false);
    pos.push_back(0);
    visited[0] = true;

    int x = A[0];

    while (true)
    {
        if (visited[x]) break;

        visited[x] = true;
        pos.push_back(x);
        x = A[x];
    }

    int cnt = 0;
    for(int i = pos.size() - 1;i>=0;i--)
    {
        cnt++;
        if (pos[i] == x) break;
    }

    if (K < pos.size())
    {
        cout << pos[K] + 1 << endl;
        return 0;
    }

    ll repeat = cnt;
    ll head = pos.size() - cnt;
    
    ll step = (K - head) % repeat;

    cout << pos[head + step] + 1 << endl;

    return 0;
}

Measured memory_bytes: 5116
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        
        // 変数の宣言
        int x = 0;
        int y = 0;
        int z = 0;
        int tmp = 0;
        
        x = sn.nextInt();
        y = sn.nextInt();
        z = sn.nextInt();
        
        // ABを入れ替える
        tmp = x;
        x = y;
        y = tmp;
        
        // ACを入れ替える
        tmp = x;
        x = z;
        z = tmp;
        
        System.out.print(x + " " + y + " " + z);
    }
}


Measured memory_bytes: 23892
from collections import defaultdict,Counter
import queue

N=int(input())
ab=defaultdict(list)
for i in range(N-1):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)

q1=queue.Queue()
qN=queue.Queue()

dist=[None for i in range(N)]
dist[0]=1
dist[N-1]=-1

phase=1
for i in ab[1]:
    q1.put((i,phase))
for g in ab[N]:
    qN.put((g,phase))

while not (q1.empty() and qN.empty()):
    while True:
        if q1.empty():
            break
        next1,p=q1.queue[0]
        if p==phase:
            if dist[next1-1]==None:
                dist[next1-1]=1
            next1,p=q1.get()
            for i in ab[next1]:
                if dist[i-1]==None:
                    q1.put((i,phase+1))
        else:
            break


    while True:
        if qN.empty():
            break
        nextN,p=qN.queue[0]
        if p==phase:
            if dist[nextN-1]==None:
                dist[nextN-1]=-1
            nextN,p=qN.get()
            for i in ab[nextN]:
                if dist[i-1]==None:
                    qN.put((i,phase+1))
        else:
            break
    phase+=1

c=Counter(dist)
if c[-1]<c[1]:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 29912
#include <stdio.h>
int main(){
    int n,a,b,r=0,i,j;
    scanf("%d%d%d",&n,&a,&b);
    for(i=1;i<=n;i++){
        int s=0;
        j=i;
        for(;j;j/=10)s+=j%10;
        if(a<=s&&s<=b)r+=i;
    }
    printf("%d\n",r);
    return 0;
}

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

int main(){
    int ans=0,sum=0;
    int n;
    cin >>n;

    for (int i = 1; i <= n; i+=2)
    {
        int count=0;
        for (int j = 1; j <=(int)sqrt(i); j++)
        {
            if(i%j==0)count++;
        }
        if(count == 4){
            ans++;
            //std::cout << i << '\n';
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, m;
  cin >> n >> m;

  if (n == 1)
  {
    cout << m;
    return;
  }

  ll ans = 1;
  for(ll i = 2; i * i <= m; ++i)
  {
    if (m % i == 0 && i * n <= m)
    {
      ans = max(ans, i);
      if (m / i * n <= m) ans = max(ans, m / i);
    }
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <inttypes.h>

int H, W;
char S[512][512];

int group[512][512];
int count[512 * 512][2];

void dfs(int y, int x, int mikisinn) {
	static const int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	int i;
	if (group[y][x] == mikisinn) return;
	group[y][x] = mikisinn;
	for (i = 0; i < 4; i++) {
		int ny = y + d[i][0], nx = x + d[i][1];
		if (0 <= ny && ny < H && 0 <= nx && nx < W && S[y][x] != S[ny][nx]) {
			dfs(ny, nx, mikisinn);
		}
	}
}

int main(void) {
	int i, j;
	int asumisu = 0;
	uint64_t mizuhasu = 0;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	for (i = 0; i < H; i++) {
		if (scanf("%511s", S[i]) != 1) return 1;
	}

	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (group[i][j] == 0) {
				dfs(i, j, ++asumisu);
			}
		}
	}

	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			count[group[i][j]][S[i][j] == '.']++;
		}
	}

	for (i = 1; i <= asumisu; i++) {
		mizuhasu += (uint64_t)count[i][0] * (uint64_t)count[i][1];
	}
	printf("%" PRIu64 "\n", mizuhasu);

	return 0;
}


Measured memory_bytes: 15156
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<string> s(n);
    vector<int> t(n);
    ll sum=0;
    rep(i,n){
        cin>>s[i]>>t[i];
        //sum+=t[i];
    }
    string x;
    cin>>x;
    int g=0;
    rep(i,n){
        if(g==1){
            sum+=t[i];
        }
        if(s[i]==x){
            g=1;
        }
    }
    cout<<sum<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	int n, k;
	cin >> n >> k;
	int* sunuke = new int[n];
	memset(sunuke, 0, sizeof(int) * n);
	rep(i, k) {
		int d;
		cin >> d;
		rep(j, d) {
			int a;
			cin >> a;
			++sunuke[a - 1];
		}
	}

	int ans = 0;
	rep(i, n) {
		if (sunuke[i] == 0) {
			++ans;
		}
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
long long int N,A,B,C,D;
int flag=0;
int main(void)
{
	scanf("%lld %lld %lld %lld %lld",&N,&A,&B,&C,&D);
	int cnt;
	cnt=B-A;	
	for(int i=0;i<N;i++)
	{
		long long int b,c;
		b=C*(N-1-i)-D*i;
		c=-C*i+(N-1-i)*D;
		if(b<=cnt&&cnt<=c)
		flag=1;
	} 
	if(flag)
	printf("YES\n");
	else
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
m = len(T)
for i in range(len(S)-len(T)+1):
    s = S[i:len(T)+i]
    d = 0
    for j in range(len(T)):
        if s[j] != T[j]:
            d += 1
    m = min(m, d)
print(m)


Measured memory_bytes: 73512
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

typedef long long ll;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

const int N=1e5+50; 

int n,k,a[N];
ll s[N],b[N];

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	scanf("%d%d",&n,&k); 
	rep(i,1,n){
		scanf("%d",a+i); 
		s[i]=s[i-1]+a[i];
		b[i]=b[i-1]+max(a[i],0); 
	}
	ll ans=0;
	rep(i,k,n){
		ans=max(ans,max(0ll,s[i]-s[i-k])+b[n]-b[i]+b[i-k]);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second
#define rep(i,x) for(int i = 0 ; i < x ; i ++)
#define mp1(a,b,c) P1(a,P(b,c))

const int INF = 1000000000;

/*struct FLOW_EDGE{
	int to;
	int flow;
	FLOW_EDGE* rev;
	void init(int to_,int flow_,FLOW_EDGE* rev_){
		to = to_;
		flow = flow_;
		rev = rev_;
	}
};

const int MAX_V = 20010;
struct MAXFLOW_MINIMUMCUT_FLOW{
	vector<FLOW_EDGE*> G[MAX_V];
	bool used[MAX_V];
	
	void add_edge(int from,int to,int flow){
		G[from].pb(new FLOW_EDGE);
		G[to].pb(new FLOW_EDGE);
		G[from][G[from].size()-1]->init(to,flow,G[to][G[to].size()-1]);
		G[to][G[to].size()-1]->init(from,0,G[from][G[from].size()-1]);
	}
	
	int dfs(int v,int t,int f){
		if(v == t)return f;
		used[v] = true;
		for(int i = 0 ; i < G[v].size() ; i ++){
			FLOW_EDGE* ed = G[v][i];
			if(ed->flow > 0 && !used[ed->to]){
				int d = dfs(ed->to,t,min(f,ed->flow));
				if(d > 0){
					ed->flow -= d;
					ed->rev->flow += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int flow(int s,int t){
		int ret = 0;
		int d = 1;
		while(d > 0){
			for(int i = 0 ; i < MAX_V ; i ++){
				used[i] = false;
			}
			d = dfs(s,t,INF);
			ret += d;
		}
		return ret;
	}
};*/

const int MAX_V_flow = 20010;
struct FLOW{
	vector<P1> G[MAX_V_flow];
	bool used[MAX_V_flow];
	
	void init(){
		rep(i,MAX_V_flow)G[i].clear();
	}
	
	void add_edge(int from,int to,int flow){
		G[from].pb( mp1 ( to , flow , G[to].size() ) );
		G[to].pb( mp1 ( from , 0 , G[from].size()-1 ) );
	}
	
	int dfs(int v,int t,int f){
		if(v == t)return f;
		used[v] = true;
		rep(i,G[v].size()){
			if(!used[G[v][i].fr] && G[v][i].sc.fr > 0){
				int d = dfs(G[v][i].fr,t,min(f,G[v][i].sc.fr));
				if(d > 0){
					G[v][i].sc.fr -= d;
					G[G[v][i].fr][G[v][i].sc.sc].sc.fr += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int flow(int s,int t){
		int ret = 0,d = 1;
		while(d > 0){
			rep(i,MAX_V_flow)used[i] = false;
			d = dfs(s,t,INF);
			ret += d;
		}
		return ret;
	}
}flow;

int main(){
	int H,W;
	char a[102][102];
	scanf("%d%d",&H,&W);
	for(int i = 1 ; i <= H ; i ++){
		scanf("\n");
		for(int j = 1 ; j <= W ; j ++){
			scanf("%c",&a[i][j]);
		}
	}
	
	//MAXFLOW_MINIMUMCUT_FLOW flow;
	for(int i = 1 ; i <= H ; i ++){
		for(int j = 1 ; j <= W ; j ++){
			for(int k = 1 ; k <= W ; k ++){
				flow.add_edge((i-1)*W+j+H*W,(i-1)*W+k,INF);
			}
		}
	}
	for(int i = 1 ; i <= H ; i ++){
		for(int j = 1 ; j <= H ; j ++){
			for(int k = 1 ; k <= W ; k ++){
				flow.add_edge((i-1)*W+k+H*W,(j-1)*W+k,INF);
			}
		}
	}
	
	int s,t;
	for(int i = 1 ; i <= H ; i ++){
		for(int j = 1 ; j <= W ; j ++){
			if(a[i][j] == 'o'){
				flow.add_edge((i-1)*W+j,(i-1)*W+j+H*W,1);
			}
			if(a[i][j] == 'S')s = (i-1)*W+j+H*W;
			if(a[i][j] == 'T')t = (i-1)*W+j;
		}
	}
	int ret = flow.flow(s,t);
	if(ret >= INF)cout << -1 << endl;
	else cout << ret << endl;
}



Measured memory_bytes: 62080
#include <iostream>
#include <tuple>
#include <algorithm>

int N {}, M {};

int princess(std::tuple<int, int> t[])
{
    std::sort(t, t + N);
    std::reverse(t, t + N);
    for (int i {}; i < N; ++i)
        if (std::get<1>(t[i]) <= M)
        {
            M -= std::get<1>(t[i]);
            std::get<1>(t[i]) = 0;
        }
        else
        {
            std::get<1>(t[i]) -= M;
            break;
        }
    
    int ans {};
    for (int i {}; i < N; ++i)
        ans += std::get<0>(t[i]) * std::get<1>(t[i]);
    return ans;
}

int main()
{
    while (std::cin >> N >> M && N > 0)
    {    
        std::tuple<int, int> t[N];
        for (int i {}; i < N; ++i)
        {
            int d {}, p {};
            std::cin >> d >> p;
            t[i] = std::make_tuple(p, d);
        }
        std::cout << princess(t) << std::endl;
    }
}


Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
using namespace std;
long long int a[3];
long long int ans;
int main()
{
    for (int i = 0; i < 3; i++)
    {
        cin >> a[i];
    }
    sort(a, a + 3);
    if (a[2] % 2 == 0 || a[1] % 2 == 0 || a[0] % 2 == 0)
    {
        cout << "0" << endl;
    }
    else
    {
        ans = a[1] * a[0];
        cout << ans << endl;
    }
}

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

int N,X[1<<18],Y[1<<18];
char D[1<<18];

void rotate(){
  for(int i=0;i<N;i++){
    int nx=200000-Y[i],ny=X[i];
    char nz;
    if(D[i]=='U') nz='L';
    if(D[i]=='L') nz='D';
    if(D[i]=='D') nz='R';
    if(D[i]=='R') nz='U';
    X[i]=nx; Y[i]=ny; D[i]=nz;}
}

vector<pair<int,char> > V1[1<<19];
vector<pair<int,char> > V2[1<<19];
  
int solve1(){
  int ans=(1<<24);
  for(int i=0;i<=400000;i++) V1[i].clear();
  for(int i=0;i<N;i++){
    if(!(D[i]=='R' || D[i]=='U')) continue;
    V1[X[i]+Y[i]].push_back(make_pair(Y[i],D[i]));
  }
  for(int i=0;i<=400000;i++){
    sort(V1[i].begin(),V1[i].end());
    for(int j=0;j<(int)V1[i].size()-1;j++){
      if(V1[i][j].second=='U' && V1[i][j+1].second=='R'){
	ans = min(ans,V1[i][j+1].first-V1[i][j].first);}
    }}
  return ans*10;
}

int solve2(){
  int ans=(1<<24);
  for(int i=0;i<=200000;i++) V2[i].clear();
  for(int i=0;i<N;i++){
    if(!(D[i]=='R' || D[i]=='L')) continue;
    V2[Y[i]].push_back(make_pair(X[i],D[i]));}
  for(int i=0;i<=200000;i++){
    sort(V2[i].begin(),V2[i].end());
    for(int j=0;j<(int)V2[i].size()-1;j++){
      if(V2[i][j].second=='R' && V2[i][j+1].second=='L'){
	ans = min(ans,V2[i][j+1].first-V2[i][j].first);}
    }}
  return ans*5;
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> X[i] >> Y[i] >> D[i];}
  int ans= (1<<24);
  for(int t=1;t<=4;t++){
    int ans1=solve1();
    //cout << ans1 << endl;
    ans = min(ans,ans1);
    int ans2=solve2();
    //cout << ans2 << endl;
    ans = min(ans,ans2);
    rotate();
  }

  if(ans==(1<<24)) cout << "SAFE" << endl;
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 42736
import heapq


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

AB.sort()
ans = 0 
q = []
heapq.heapify(q)
idx = 0
for i in range(1,M+1):
    while idx<N and AB[idx][0]<=i:
        heapq.heappush(q, -AB[idx][1])
        idx += 1
    if q:
        p = -heapq.heappop(q)
        ans += p
print(ans)

Measured memory_bytes: 31596
#include<bits/stdc++.h> 
using namespace std;
 
class Hash {
    public:
    
    Hash(const char *s, long long base = 1009, long long m = 1000000007) : MOD(m) {
        int n = strlen(s);
        
        hash = (long long *)malloc(sizeof(long long) * (n + 1));
        pow = (long long *)malloc(sizeof(long long) * (n + 1));
        
        hash[0] = 0;
        pow[0] = 1;
        
        for (int i = 0; i < n; i++) {
            hash[i + 1] = (hash[i] * base + s[i]) % MOD;
            pow[i + 1] = pow[i] * base % MOD;
        }
    }
    
    ~Hash() {
        free(hash);
        free(pow);
    }
    
    //x銇嬨倝y鏂囧瓧銇儚銉冦偡銉ュ€?
    long long get(int x, int y) {
        return (hash[x + y] - hash[x] * pow[y] % MOD + MOD) % MOD;
    }
    
    private:
    
    long long MOD;
    long long *hash;
    long long *pow;
};
 
char s[500001];
int b[500001];
vector <int> v[500001];
 
bool check(int x, int y, Hash &h1, Hash &h2) {
    int c = y - x, i, j;
    
    if (c == 1) return true;
    
    for (i = 0; i < v[c].size(); i++) {
        int z = (y - x) / v[c][i];
        
        for (j = 1; j * 2 <= v[c][i]; j *= 2) {
            if (h1.get(x, z * j) != h1.get(x + z * j, z * j)) break;
        }
        
        if (j * 2 <= v[c][i]) continue;
        
        if (h1.get(x, z * j) != h1.get(y - z * j, z * j)) continue;
        
        for (j = 1; j * 2 <= v[c][i]; j *= 2) {
            if (h2.get(x, z * j) != h2.get(x + z * j, z * j)) break;
        }
        
        if (j * 2 <= v[c][i]) continue;
        
        if (h2.get(x, z * j) != h2.get(y - z * j, z * j)) continue;
        
        return false;
    }
    
    return true;
}
 
int main() {
    int n, ans = 0, i;
    long long j;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i < n; i++) {
        if (s[i] != s[0]) break;
    }
    
    if (i == n) {
        printf("%d\n", n);
        printf("%d\n", 1);
        
        return 0;
    }
    
    for (i = 2; i <= 500000; i++) {
        if (b[i] == 0) {
            b[i] = i;
            
            for (j = (long long)i * i; j <= 500000; j += i) {
                if (b[j] == 0) b[j] = i;
            }
        }
    }
    
    for (i = 1; i <= n; i++) {
        int c = i;
        
        while (c > 1) {
            if (v[i].size() == 0 || v[i].back() != b[c]) v[i].push_back(b[c]);
            
            c /= b[c];
        }
    }
    
    Hash h1(s);
    Hash h2(s, 10009, 1000000009);
    
    if (check(0, n, h1, h2) == true) {
        printf("%d\n", 1);
        printf("%d\n", 1);
        
        return 0;
    }
    
    for (i = 1; i < n; i++) {
        if (check(0, i, h1, h2) == true && check(i, n, h1, h2) == true) ans++;
    }
    
    printf("%d\n", 2);
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 48000
#ABC126 B

S = list(map(int,input()))
if 1 <= S[0]*10 + S[1] <= 12 and 1 <= S[2]*10 + S[3] <= 12:
    print("AMBIGUOUS")
elif 1 <= S[0]*10 + S[1] <= 12 and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("MMYY")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0)  and  1 <= S[2]*10 + S[3] <= 12:
    print("YYMM")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0) and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("NA")

Measured memory_bytes: 9140
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[101010];
int main()
{
	int n,t,mi,p=0,c1,c2,ans=0;
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	mi=a[1];
	for(int i=2;i<=n;i++)
	{
		p=max(p,a[i]-mi);
		mi=min(mi,a[i]);
	}
	c1=c2=0;
	mi=a[1];
	c1=1;
	for(int i=2;i<=n;i++)
	{
		if(a[i]-mi==p)
			c2++;
		if(a[i]==mi)
			c1++;
		else if(a[i]<mi)
		{
			mi=a[i];
			ans+=min(c1,c2);
			c1=1;
			c2=0;
		}
	}
	ans+=min(c1,c2);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    private static BufferedReader br;
	public static void main (String[] args) throws java.lang.Exception
	{
		br=  new BufferedReader(new InputStreamReader(System.in));
		char alpha = br.readLine().charAt(0);
		if(alpha >= 'a' && alpha <= 'z')
		    System.out.println("a");
		else
		    System.out.println("A");
	}
}


Measured memory_bytes: 32580
# -*- coding: utf-8 -*-
import itertools

l = range(0,10)

while True:
	cnt = 0
	a,b = map(int, raw_input().strip().split())
	if a==0 and b==0:
		break
	for elem in itertools.combinations(l, a):
		tmp = 0
		for i in xrange(0,a):
			tmp += elem[i]
		if tmp == b:
			cnt += 1
	print cnt

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int ans=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(i*500+j*100+k*50==x){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long N;
cin>>N;
long long answer=0;
vector<long long>L(N);
for(int i=0; i<N; i++){
    cin>>L.at(i);
}
 sort(L.begin(),L.end());
for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
        for(int k=j+1; k<N; k++){
            if(L.at(i)==L.at(j)||L.at(i)==L.at(k)||L.at(j)==L.at(k)
             
    ){
                continue;
            }
            else
            {
              long long A=L.at(i);
              long long B=L.at(j);
              long long C=L.at(k);
              long long u=max(B,C);
              long long t=max(A,u);
                if(A+B+C-t>t){
                    answer++;
                }
            }
        }
    }
}
cout<<answer<<endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 

//power of 2 ...n&(n-1)==0
int h,w,k,x11,y11,x2,y2;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};

vector<vector<char>> mat;

vector<vector<int>> vis,dis;

void bfs(int x,int y)
{
	queue<pair<int,int>> q;
	q.push({x,y});
	vis[x][y]=1;
	dis[x][y]=0;
	while(!q.empty())
	{
		int X=q.front().first;
		int Y=q.front().second;
		q.pop();
		for(int d=0;d<4;d++)
		{
			for(int len=1;len<=k;len++)
			{
				int xn=X+(dx[d])*len;
				int yn=Y+(dy[d])*len;
				if(xn<1||yn<1||xn>h||yn>w)
					break;
				if(dis[X][Y]+1>dis[xn][yn]&&vis[xn][yn])
					break;
				if(mat[xn][yn]=='@')
				{
					break;
				}
				if(vis[xn][yn])
					continue;
				vis[xn][yn]=1;
				dis[xn][yn]=dis[X][Y]+1;
				q.push({xn,yn});
			}
		}
	}
}
int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	 //ll testcase;
	 //cin>>testcase;
	 //for(ll t=0;t<testcase;t++)
	{
		// use long long
		//donot memeset other than 0 or 1 or -1
		//segmentation fault-> check for uninitialized global variable or out of bounds
		//always check for bottle neck (whether original constraints can be reduced by introducing some condition)
		//dont rush to writing code think through the logic	
		//implement dijkstra again ---it is bfs because we vis all the points connected to the current point first
		//from every not visited cell we will update the distances of cell which can be visited
		cin>>h>>w>>k;
		cin>>x11>>y11>>x2>>y2;
		mat=vector<vector<char>> (h+1,vector<char> (w+1));
		for(int i=1;i<=h;i++) 
		{
			for(int j=1;j<=w;j++)
			{
				cin>>mat[i][j];
			}
		}
				
		vis=dis=vector<vector<int>> (h+1,vector<int> (w+1,0));		
		bfs(x11,y11);
		
		if(!vis[x2][y2])
		{
			cout<<-1<<'\n';
		}
		else
		{
			cout<<dis[x2][y2]<<'\n';
		}
		
	}
	return 0;
}





























































Measured memory_bytes: 24776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n, m;
    while (cin >> n >> m, n) {
        int r;
        cin >> r;
        vector<vector<int> > solve(m+1, vector<int>(1261, 0));
        rep(i, r) {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            if (d) {
                solve[c][a]++;
            } else {
                solve[c][a]--;
            }
        }
        for (int j = 1; j <= m; j++) {
            for (int i = 540; i < 1260; i++) {
                solve[j][i+1] += solve[j][i];
            }
        }
        int q;
        cin >> q;
        rep(i, q) {
            int a, b, c;
            cin >> a >> b >> c;
            int ret = 0;
            for (int j = a; j < b; j++) {
                if (solve[c][j]) {
                    ret++;
                }
            }
            cout << ret << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 50836
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];


    int odd = 0;
    REP(i, N) {
        if (a[i] % 2 == 1) {
            odd++;
        }
    }

    cout << (odd % 2 == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    a = list(map(int,input().split()))
    if sum(a) == 17:
        return 'YES'
    return 'NO'



print(main())


Measured memory_bytes: 5640
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

n = int(input())
d = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range (i+1, n):
        ans += d[i] * d[j]
print(ans)


Measured memory_bytes: 9080