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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

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

    ///FastIO;

    lli a,b,c,d;
    cin>>a>>b>>c>>d;

    lli lcm = (c*d)/__gcd(c,d);

    cout<<(b-a+1 - (b/c - (a-1)/c) - (b/d - (a-1)/d) + b/lcm - (a-1)/lcm );

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(52);
const int LOG = (int)(20);

lli n, m, ar[N], dp[N][N][N * N], ans;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> ar[i];

	dp[0][0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= i; j++) {
			for(int k = 0; k <= 2500; k++) {
				dp[i][j][k] = dp[i - 1][j][k];
				if(k - ar[i] >= 0 && j > 0)
					dp[i][j][k] += dp[i - 1][j - 1][k - ar[i]];
			}
		}
	}
	for(int i = 1; i <= n; i++)
		ans += dp[n][i][m * i];
	
	cout << ans;
}

Measured memory_bytes: 54272
#include <iostream>
#include <vector>
constexpr int P = 1'000'000'007;
int n;
std::vector<int> x;
int power(int a, int b) {
    int ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = 1LL * ans * a % P;
        a = 1LL * a * a % P;
        b >>= 1;
    }
    return ans;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n;
    x.resize(n);
    for (int i = 0; i < n; ++i)
        std::cin >> x[i];
    int ans = 0;
    for (int i = 1, j = 0; i < n; ++i) {
        j = (j + power(i, P - 2)) % P;
        ans = (ans + 1LL * j * (x[i] - x[i - 1])) % P;
    }
    for (int i = 1; i < n; ++i)
        ans = 1LL * ans * i % P;
    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    return format!("{}", a * b);
}


Measured memory_bytes: 2156
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let n = read::<usize>();
    let mut av: Vec<i64> = Vec::with_capacity(n);
    for i in 0..n {
        let a = read::<i64>();
        av.push(a);
    }
    let mut ans = 0;
    let mut x = 0;
    let mut suc = true;
    for i in 0..n {
        let a = av.pop().unwrap();
        if a < x - 1 || a as usize > n - i - 1 {
            suc = false;
            break;
        }
        if a == x - 1 {
            x -= 1;
        } else {
            ans += a;
            x = a;
        }
    }
    if suc {
        println!("{}",ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 6396
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <unordered_map>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 2e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    int a = read(), b = read(),c = read();
    swap(a,b);
    swap(a,c);
    cout<<a<<' '<<b<<' '<<c;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);
 
int main(){
    IOS;
    vector<ll>v;
    f(i,0,60){
        v.pb(pow(2,i));
    }
    ll n;cin>>n;
    f(i,0,v.size()){
        if(v[i]>n){cout<<v[i]-1;break;}
        if(v[i]==n){cout<<v[i+1]-1;break;}
    }
    return 0;
}   


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;


struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1){}
  int root(int x) {
    if(d[x]<0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y){
    x = root(x); y=root(y);
    if(x==y) return false;
    if (d[x]>d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) {return root(x)==root(y);}
  int size(int x) {return -d[root(x)];}
  int factor_size() {
    int ans=0;
    rep(i,d.size()){
      if (d[i]<0) {ans++;}
    }
    return ans;
  }
  
};
  
int main(){ 
  ll n,m,k,q;
  cin >> n;

  ll s[n+1];
  s[0]=0;
  rep(i, n ){
    cin >> q;
    s[i+1] = s[i] + q;
  }

  ll ans = 0;
  sort(s, s+n+1);

  ll c = 1;
  for (int i=0;i<n;i++ ){
    if (s[i]==s[i+1]) c++;
    else {
      ans += c*(c-1)/2;
      c = 1;
    }
  }
  ans += c*(c-1)/2;

  cout << ans <<endl;
}



Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] img = new String[h];

        for (int i = 0; i < h; i++) {
            img[i] = sc.next();
        }

        for (int i = 0; i < h; i++) {
            System.out.println(img[i]);
            System.out.println(img[i]);
        }
    }
}


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

#define __sel(_1, _2, x, ...) x

#define repn(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) __sel(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (ll i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (ll i = (b - 1); i >= (a); i--)
#define rrep(i, ...) __sel(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x))
#define umin(m, x) (m = min(m, x))
#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()
#define bit(x, n) ((x) >> (n) & 1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define shv(v) for (auto __t1 : v) cerr << __t1 << " "; cerr << endl;
#define db(x) cerr << #x << ": " << (x) << endl;
#define dbv(v) cerr << #v << ": "; shv(v);
#define dbm(m) cerr << #m << ":" << endl; for (auto __t2 : m) { shv(__t2); }

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vld = vector<ld>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<double>>;
using vvld = vector<vector<ld>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

inline int gi() { int x; cin >> x; return x; }
inline ll gl() { int x; cin >> x; return x; }
inline char gc() { char x; cin >> x; return x; }
inline string gs() { string x; cin >> x; return x; }

inline vi gvi(int n) { vi v(n); rep(i, n) cin >> v[i]; return v; }
inline vl gvl(int n) { vl v(n); rep(i, n) cin >> v[i]; return v; }
inline vc gvc(int n) { vc v(n); rep(i, n) cin >> v[i]; return v; }
inline vs gvs(int n) { vs v(n); rep(i, n) cin >> v[i]; return v; }

inline vvi gvvi(int h, int w) { vvi m(h, vi(w)); rep(i, h) rep(j, w) cin >> m[i][j]; return m; }
inline vvl gvvl(int h, int w) { vvl m(h, vl(w)); rep(i, h) rep(j, w) cin >> m[i][j]; return m; }
inline vvc gvvc(int h, int w) { vvc m(h, vc(w)); rep(i, h) rep(j, w) cin >> m[i][j]; return m; }
inline vvs gvvs(int h, int w) { vvs m(h, vs(w)); rep(i, h) rep(j, w) cin >> m[i][j]; return m; }

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


void dfs(vvi& g, vi& cnt, int p, vi& ans) {
    for (auto t : g[p]) {
        if (ans[t] != -1) continue;
        ans[t] = ans[p] + cnt[t];
        dfs(g, cnt, t, ans);
    }
}

int main() {
    int n = gi(), q = gi();
    vi cnt(n, 0);
    vvi g(n);
    rep(i, 1, n) {
        int a = gi(), b = gi();
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    rep(i, q) {
        int p = gi(), x = gi();
        cnt[p - 1] += x;
    }
    vi ans(n, -1);
    ans[0] = cnt[0];
    dfs(g, cnt, 0, ans);
    for (auto t : ans)
        cout << t << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 27392
#include <iostream>
#define MOD ((long)1e9 + 7)

using namespace std;

long comb(int n, int k);

int main(void) {
    int N, K;

    cin >> N >> K;

    for (int i = 1; i <= K; i++) {
        cout << (comb(N - K + 1, i) * comb(K - 1, i - 1)) % MOD << endl;
    }

    return 0;
}

long comb(int n, int k) {
    static long c[2048][2048];
    if (n < k) return 0;
    if (k == 0) return c[n][k] = 1;
    if (k == n) return c[n][k] = 1;
    if (c[n][k]) return c[n][k];
    return c[n][k] = (comb(n - 1, k) + comb(n - 1, k - 1)) % MOD;
}

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

int main() {
    long long l, r;
    long long i, j;
    long long mod = 2019;

    cin >> l >> r;
    long long d = r - l;
    long long minimum;

    minimum = l * (l + 1) % mod;

    for(i = 0; i < d; i++) {
        for(j = i + 1; j <= d; j++) {
            long long tmp = (l + i) * (l + j) % mod;
            if(tmp == 0) {
                cout << 0 << endl;
                return 0;
            }
            if(tmp < minimum) {
                 minimum = tmp;
            }
        }
    }

    cout << minimum << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,K; cin>>N>>K;
	vector<ll> h(N);
	ll ans=10000000000;
	rep(i,N) cin>>h[i];
	sort(h.bg,h.ed);
	for(int i=K-1;i<=N-1;i++){
		ans=min(ans,h[i]-h[i-K+1]);
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  if(s[0] == '9' || s[1] == '9') puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int main(){
      string a[100],b[100];
      int n;
      map<string,int>M;
      cin>>n;
      REP(i,n){
            cin>>a[i];
            b[i]=a[i];
            M[a[i]]=i;
      }
      REP(i,n){
            for(int j=n-1;j>i;j--){
                  if(a[j][1]<a[j-1][1])swap(a[j],a[j-1]);
            }
      }
      bool ans=true;
      REP(i,n){
            cout<<a[i];
            if(i==n-1)cout<<endl;
            else cout<<" ";
      }
      REP(i,n-1){
            if(a[i][1]==a[i+1][1]&&M[a[i]]>M[a[i+1]])ans=false;
      }
      if(ans)cout<<"Stable"<<endl;
      else cout<<"Not stable"<<endl;
      REP(i,n-1){
            int minj=i;
            for(int j=i;j<n;j++){
                  if(b[j][1]<b[minj][1])minj=j;
            }
            swap(b[i],b[minj]);
      }
      ans=true;
      REP(i,n-1){
            if(b[i][1]==b[i+1][1]&&M[b[i]]>M[b[i+1]])ans=false;
      }
      REP(i,n){
            cout<<b[i];
            if(i==n-1)cout<<endl;
            else cout<<" ";
      }
      if(ans)cout<<"Stable"<<endl;
      else cout<<"Not stable"<<endl;
}

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

int main() {
  char a,b;
  char topCoDeer = 'H';
  cin >> a >> b;
  
  if(a == 'H'){
    if(b == 'H') topCoDeer = 'H';
    else topCoDeer = 'D';
  }else{
    if(b == 'H') topCoDeer = 'D';
    else topCoDeer = 'H';
  }
  
  cout << topCoDeer;
}


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

const int maxn = 55;
int n, ans, d[maxn], res[maxn], tmp[maxn];

void dfs(int i) {
	if (i == n) {
		copy(res, res + n, tmp);
		sort(tmp, tmp + n);
		int mx = 24;
		for (int i = 0, j = n - 1; i < n; j = i++) {
			mx = min(mx, min(abs(tmp[i] - tmp[j]), 24 - abs(tmp[i] - tmp[j])));
		}
        ans = max(ans, mx);
		return;
	}
	for (int j = -1; j <= 1; j += 2) {
		res[i] = d[i] * j;
		dfs(i + 1);
		if (d[i] == 0 || d[i] == 12) {
			break;
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &d[i]);
	}
	n++;
	if (n > 24) {
		printf("0\n");
		return 0;
	}
	res[1] = d[1];
	dfs(2);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 201000;
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;
}

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

void no() {
  cout << 0 << endl;
  exit(0);
}

int main() {
  ll N, M;
  cin >> N >> M;
  COMinit();
  vector<ll> A(N), B(M);
  const ll MAX = N * M;
  // cntA[x] = A[i]>=xとなるiの個数
  vector<ll> cntA(MAX + 2, 0), cntB(MAX + 2, 0);
  REP(i, N) {
    cin >> A[i];
    cntA[A[i]]++;
  }
  REP(j, M) {
    cin >> B[j];
    cntB[B[j]]++;
  }
  // A,Bに重複がある場合は0通り
  A.resize(unique(ALL(A)) - A.begin());
  if (SZ(A) < N) no();
  B.resize(unique(ALL(B)) - B.begin());
  if (SZ(B) < M) no();
  IFOR(i, 1, MAX + 1) {
    cntA[i - 1] += cntA[i];
    cntB[i - 1] += cntB[i];
  }
  ll ans = 1;
  IFOR(x, 1, MAX + 1) {
    ll s = cntA[x] - cntA[x + 1];  // A[i] = xなるiがあるか？
    ll t = cntB[x] - cntB[x + 1];  // B[j] = xなるjがあるか？
    if (s == 1 && t == 1) continue;
    if (s == 1) {
      (ans *= cntB[x]) %= MOD;
    } else if (t == 1) {
      (ans *= cntA[x]) %= MOD;
    } else {
      (ans *= cntA[x] * cntB[x] - (MAX - x)) %= MOD;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 20608
#include <stdio.h>
 
int main(void) {
	int n, m, sum, max;
	int t[10001];
	int p[101];
	int x[10001];
	int i, j;
	
	sum = 0;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &t[i]);
		sum += t[i];
	}
	
	max = sum;
	
	scanf("%d", &m);

	for (i = 0; i < m; i++) scanf("%d %d", &p[i], &x[i]);
	
	for (i = 0; i < m; i++){
		for (j = 1; j <= n; j++){
			if (j == p[i]){
				sum = sum - t[j-1] + x[i];
				printf("%d\n", sum);
				sum = max;
				break;
			}
		}
	}
	
	return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int ans=0;
  vector<int> div={-1,-1,-1};
  for(int i=0; i<M; i++){
    int s, c;
    cin >> s >> c;
    if(div.at(s-1)==-1) div.at(s-1)=c;
    else if(div.at(s-1)!=c){
      ans=-1;
      break;
    }
  }
  if(ans==0 && N==1){
    if(div.at(0)==-1) div.at(0)=0;
    ans=div.at(0);
  }
  if(ans==0 && N==2){
    if(div.at(0)==0){
      ans=-1;
    }
    else{
      if(div.at(0)==-1) div.at(0)=1;
      if(div.at(1)==-1) div.at(1)=0;
      ans=10*div.at(0)+div.at(1);
    }
  }
  if(ans==0 && N==3){
    if(div.at(0)==0){
      ans=-1;
    }
    else{
      if(div.at(0)==-1) div.at(0)=1;
      if(div.at(1)==-1) div.at(1)=0;
      if(div.at(2)==-1) div.at(2)=0;
      ans=100*div.at(0)+10*div.at(1)+div.at(2);
    }
  }

  cout << ans << endl;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int a;
  cin>>a;
  int z = log2(a);
  cout<<(1<<z)<<endl;
}


Measured memory_bytes: 14080
import math
A, B = map(int, input().split())


def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a


print(len(list(set(prime_factorize(math.gcd(A, B))))))


Measured memory_bytes: 9208
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int x,y;
  cin >> x >> y;
  int tsuru=0;
  int kame=0;
  bool ans = false;
  rep(i,x+1)
  {
    if(2*i+4*(x-i) == y)
    {
      ans = true;
    }
  }
  if(ans) cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }
  
  return 0;
}


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

using namespace std;

#define pb push_back
const int maxi=1e6+10;
const long long mo=1e9+7;
int a[maxi];
vector<int> v[maxi];
int n;

int pr[maxi];
long long dp[maxi];
int main()
{
    cin>>n;

    for (int i=1; i<=n; i++)
        scanf("%d",&a[i]);

    dp[0]=1;
    for (int i=1; i<=n; i++)
    {
        if (!pr[a[i]] || pr[a[i]]==i-1)
            dp[i]=dp[i-1];
        else

            dp[i]=(dp[i-1]+dp[pr[a[i]]])%mo;
                   pr[a[i]]=i;
        }
          cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 32512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		System.out.println((m-1) * (n-1));
	}

}

Measured memory_bytes: 21844
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
    	new Main(); 
    }
 
    public Main() {
    	new A().doIt();
    }
    class A{
    	void ans(int a[],int n,int p){
    		int cup = p;
    		while(true){
    			int cnt = 0;
    			for(int i = 0;i < n;i++){
    				if(cup == 0){
    					cup = a[i];
    					a[i] = 0;
    				}else{
    					a[i] = a[i] + 1;
    					cup = cup - 1;
    				}
    			}
    			for(int i = 0;i < n;i++){
//    				System.out.print(a[i]+" ");
    				if(a[i] != 0){
    					cnt++;
    				}
    			}
//    			System.out.println();
    			if(cnt == 1 && cup == 0)return;
    		}
    	}
    	void doIt(){
    		while(true){
    			int n = sc.nextInt();
    			int p = sc.nextInt();
    			if(n + p == 0)break;
    			int a[] = new int [n];
    			ans(a,n,p);
    			for(int i = 0;i < n;i++){
    				if(a[i] != 0){
    					System.out.println(i);
    				}
    			}
    		}
    	}
    }
}

Measured memory_bytes: 26952
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N, K;
    cin >> N >> K;
    lint V[N];
    cins(V, V + N);
    lint ans = 0;
    for(int i = 0; i <= N; i++){
        for(int j = 0; i + j <= min(N, K); j++){
            lint sum = 0;
            vector<lint> gem;
            for(int k = 0; k < i; k++){
                sum += V[k];
                gem.push_back(V[k]);
            }
            for(int k = 0; k < j; k++){
                sum += V[N - 1 - k];
                gem.push_back(V[N - 1 - k]);
            }
            sort(all(gem));
            int cnt = min(i + j, K - i - j);
            for(int k = 0; k < cnt; k++){
                sum -= min(0ll, gem[k]);
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<numeric>
using namespace std;


using ll = int64_t;

/// <summary>
/// GCDを計算します
/// </summary>
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
	if (a < b) {
		NumType tmp = a;
		a = b;
		b = tmp;
	}

	NumType r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

/// <summary>
/// 約数を数えます
/// </summary>
template <typename NumType>
NumType cntDivisor(const NumType& num) {
	NumType cnt = 0;
	for (NumType i = 1; i * i <= num; ++i) {
		if (num % i == 0) {
			cnt++;
			if (i * i != num) cnt++;
		}
	}

	return cnt;
}

template<typename TypeInt>
TypeInt L_C_M(TypeInt a, TypeInt b) {
	if (a == 0 && b == 0) {
		return 0;
	}
	return a * b / calcGCD<ll>(a, b);
}

/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)

const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


///////////////////////////////////////////////////////////////////////////

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

	ll A, B, C, D;

	cin >> A >> B >> C >> D;

	ll ans = 0;

	ll lm = L_C_M<ll>(C, D);
	bool a = false;
	if (lm != C * D) {
		a = true;
	}
	
	--A;
	ll a_1 = A / C, a_2 = A / D, a_3 = A / lm;
	ll b_1 = B / C, b_2 = B / D, b_3 = B / lm;
	/*
	ll ans_1 = A - (a_1 + a_2 - a_3);
	ll ans_2 = B - (b_1 + b_2 - b_3);

	ans = ans_2 - ans_1;
	*/

	ll ans_tmp = (b_1 + b_2 - b_3) - (a_1 + a_2 - a_3);
	ans = B - A - ans_tmp;
	
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
W = [input()]
tail = W[0][-1]
for i in range(N - 1):
  w = input()
  if w in W or w[0] != tail:
    print('No')
    break
  else:
    tail = w[-1]
    W.append(w)
else:
  print('Yes')

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>

using namespace std;

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

int main(){
	int n, C; scanf("%d %d", &n, &C);
	int d[30][30], c[500][500];
	rep(i, C) rep(j, C) scanf("%d", &d[i][j]);
	rep(i, n) rep(j, n){ scanf("%d", &c[i][j]); c[i][j]--; }
	int t[3][30] = {};
	rep(i, n) rep(j, n) t[(i + j) % 3][c[i][j]]++;
	int res = 1 << 29;
	rep(i, C) rep(j, C) rep(k, C){
		if(i == j || j == k || k == i) continue;
		int ret = 0;
		rep(l, C) ret += t[0][l] * d[l][i] + t[1][l] * d[l][j] + t[2][l] * d[l][k];
		res = min(res, ret);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define rrep(i,n) for (ll i = (n)-1; i >=0; --i)
#define ALL(a) a.begin(),a.end()
#define pb push_back
#define dame { puts("-1"); return 0;}
#define show(x) cerr<<#x<<" = "<<x<<endl;

using namespace std;
using ll = long long;
using ld = long double;
using pl = pair<ll, ll>;

typedef vector<ll> vl;
typedef vector<pl> vp;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);


int main() {
  ll n, m;
  cin >> n >> m;

  vector<ll> k(m);
  vector<ll> p(m);
  vector<vector<ll> > s(n);

  rep(i, m){
    cin >> k[i];
    ll tmp;
    rep(j, k[i]){
      cin >> tmp;
      tmp--;
      s[tmp].pb(i);
    }
  }

  rep(i, m){
    cin >> p[i];
  }

  int ans = 0;
  rep(i, 1<<n){
    vector<ll> son(m, 0);
    rep(j, n){
      if(i>>j&1) {
	rep(k, s[j].size()) son[s[j][k]]++;
      }
    }
    bool flug = true;
    
    rep(j, m){
      if(son[j]%2!=p[j]) flug = false;
      show(son[j]);
      show(p[j]);
    }
    if(flug) ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
ll maxRectangleInHistogram(vector<int> &v) {
    int n = v.size();
    stack<int> s;
    vector<int> L(n), R(n);
    rep(i, 0, n) {
        while (s.size() && v[s.top()] >= v[i]) s.pop();
        L[i] = s.size() ? (s.top() + 1) : 0;
        s.push(i);
    }
    while (s.size()) s.pop();
    rrep(i, n - 1, 0) {
        while (s.size() > 0 && v[s.top()] >= v[i]) s.pop();
        R[i] = s.size() ? s.top() : n;
        s.push(i);
    }
    ll res = 0;
    rep(i, 0, n) res = max(res, 1LL * v[i] * (R[i] - L[i]));
    return res;
}
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/










int N, H[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N; rep(i, 0, N) cin >> H[i];

    vector<int> v(H, H + N);
    cout << maxRectangleInHistogram(v) << endl;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    int n; cin >> n;
    string s; cin >> s;

    ll r = 0;
    ll g = 0;
    ll b = 0;

    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') { r++; } 
        if(s[i] == 'G') { g++; }
        if(s[i] == 'B') { b++; }
    }

    ll ans = r*g*b;
    for(ll i = 0; i < n; i++) {
        for(ll j = i+1; j < n; j++) {
            if(s[i] == s[j]) { continue; }
            ll k = 2*j - i;
            if(k >= n) { continue; }
            if(s[i] != s[k] && s[j] != s[k]) {
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var s = consoleReader.String;
            return
                s[0] == s[1] || s[1] == s[2] || s[2] == s[3]
                ? "Bad" : "Good";
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> SplitString { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

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

using namespace std;

int main() {
	string S;
	while( cin >> S ) {
		if( S == "0" ) {
			break;
		}
		long long int ans = 0;
		vector<vector<long long int>>dp( S.length(), vector < long long int >( 2 ) );
		for( size_t i = 0; i < S.length(); i++ ) {
			if( i ) {
				dp[i] = dp[i - 1];
			}
			if( i % 2 ) {
				dp[i][0] += S[i] - '0';
			} else {
				dp[i][1] -= S[i] - '0';
			}
		}
		for( size_t i = 0; i < S.length(); i++ ) {
			dp[i][0] += dp[i][1];
			dp[i][0] %= 11;
			dp[i][0] += 11;
			dp[i][0] %= 11;
		}
		vector<long long int>X( 11 );
		X[0]++;
		for( size_t i = 0; i < S.length(); i++ ) {
			ans += X[dp[i][0]];
			if( !( i < S.length() - 1 && S[i + 1] == '0' ) ) {
				X[dp[i][0]]++;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 7340
l = input().split()
sx = int(l[0])
sy = int(l[1])
tx = int(l[2])
ty = int(l[3])

# print(sx, sy, tx, ty)

ans = ''

dx = tx - sx
dy = ty - sy

# 往路 1
ans += 'U'*dy
ans += 'R'*dx

# 復路 1
ans += 'D'*dy
ans += 'L'*dx

# 往路 2
ans += 'L'
ans += 'U'*(dy + 1)
ans += 'R'*(dx + 1)
ans += 'D'

# 復路 2
ans += 'R'
ans += 'D'*(dy + 1)
ans += 'L'*(dx + 1)
ans += 'U'

print(ans)


Measured memory_bytes: 38256
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FDivisionOrSubtraction solver = new FDivisionOrSubtraction();
        solver.solve(1, in, out);
        out.close();
    }

    static class FDivisionOrSubtraction {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.readLong();
            // no of divisors of n-1
            // if k(simulate 2 to sqrt n) divisible by n , add +1

            long n1 = (n == 2) ? 0 : 1;

            for (long i = 2; i <= Math.sqrt(n - 1); i++)
                if ((n - 1) % i == 0) {
                    if (i == Math.sqrt(n - 1))
                        n1++;
                    else
                        n1 += 2;
                }


            long n2 = 1;
            for (long i = 2; i <= Math.sqrt(n); i++) {
                if (n % i == 0) {
                    long tmp = n;
                    while (tmp % i == 0) {
                        tmp /= i;
                    }
                    if (tmp % i == 1) n2++;
                }
            }

            System.out.println(n1 + n2);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<int> pat(W);
  pat[0] = 1;
  for (int i = 1; i <= W - 1; i++) {
    for (int bits = 0; bits < (1 << i); bits++) {
      bool ok = true;
      for (int j = 0; j < i - 1; j++) {
        if ((bits >> j) & (bits >> (j + 1)) & 1) {
          ok = false;
          break;
        }
      }
      if (ok) pat[i]++;
    }
  }
  auto patterns = [&](int n) {
    if (n <= 0) return 1;
    return pat[n];
  };
  vector<vector<modint>> dp(H + 5, vector<modint>(W + 5));
  dp[0][1] = 1;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      dp[i][j] = dp[i - 1][j] * patterns(j - 2) * patterns(W - 1 - j) +
                 dp[i - 1][j - 1] * patterns(j - 3) * patterns(W - 1 - j) +
                 dp[i - 1][j + 1] * patterns(j - 2) * patterns(W - 1 - j - 1);
    }
  }
  cout << dp[H][K] << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256