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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// 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 int 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 {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= 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 {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        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];
    }
} comb(2000005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

mint g(int r, int c) {
    return comb(r + c + 2, r + 1) - 1;
}

int main() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--, c1--;

    mint ans = g(r2, c2);
    ans -= g(r1, c2);
    ans -= g(r2, c1);
    ans += g(r1, c1);

    cout << ans.x << endl;
}


Measured memory_bytes: 31488
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int N,K;
    cin >> N >> K;
    int ans = K;
    REP(i,N-1) ans *= (K-1);
    cout << ans << endl;
    return 0;
}


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

int main(void){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s, t;

    s.push_back(ll(-10e10));
    t.push_back(ll(-10e10));
    for(int i = 0; i < a; i++){
        ll tmp; cin >> tmp;
        s.push_back(tmp);
    }
    for(int i = 0; i < b; i++){
        ll tmp; cin >> tmp;
        t.push_back(tmp);
    }
    s.push_back(ll(20e10));
    t.push_back(ll(20e10));

    for(int i = 0; i < q; i++){
        ll x; cin >> x;
        vector<ll> temple(2);
        vector<ll> shrine(2);

        auto t_itr = lower_bound(t.begin(), t.end(), x);
        temple[1] = *t_itr;
        t_itr--;
        temple[0] = *t_itr;
        // cout << temple[0] << " " << temple[1] << endl;

        auto s_itr = lower_bound(s.begin(), s.end(), x);
        shrine[1] = *s_itr;
        s_itr--;
        shrine[0] = *s_itr;
        // cout << shrine[0] << " " << shrine[1] << endl;

        ll ans = ll(30e10);
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j++){
                ans = min(ans, abs(x - shrine[i]) + abs(shrine[i] - temple[j]));
                ans = min(ans, abs(x - temple[j]) + abs(shrine[i] - temple[j]));
            }
        }

        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

  vll a(9);
  rep(i,0,9){
  cin >> a[i]; 
  }
 
  ll n;
  cin >> n;
  vll b(n);
  vb flag(9,false);
  rep(k,0,n) {
    
    cin >> b[k];
  
    rep(i,0,9) if(b[k]==a[i]) flag[i]=true;
  }
    
 
  
  if(flag[0]&&flag[1]&&flag[2]) cout << "Yes" << endl;
  else if(flag[4]&&flag[3]&&flag[5]) cout << "Yes" << endl;
  else if(flag[7]&&flag[8]&&flag[6]) cout << "Yes" << endl;
  else if(flag[0]&&flag[3]&&flag[6]) cout << "Yes" << endl;
   else if(flag[7]&&flag[1]&&flag[4]) cout << "Yes" << endl;
   else if(flag[2]&&flag[8]&&flag[5]) cout << "Yes" << endl;
   else if(flag[0]&&flag[8]&&flag[4]) cout << "Yes" << endl;
   else if(flag[2]&&flag[4]&&flag[6]) cout << "Yes" << endl;
   else cout << "No" << endl;
  
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
//?¶????????????????????????????????????§??????????????????????¢????????????????
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	double x = 0.0, y = 0.0;
	int d, a;
	int ca = 90;
	char c;
	cin >> d >> c >> a;

	do {
		x += d * cos(ca / 180.0 * PI);
		y += d * sin(ca / 180.0 * PI);
		ca -= a;
		cin >> d >> c >> a;

	} while (d != 0 || a != 0);
	//cout << fixed << setprecision(0) << x << endl << y << endl;
	cout << int(x) << endl << int(y) << endl;
}

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

int d[200000],e[200000];

int main(){
    int n,m,f=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int b,c;
        cin>>b>>c;
        if(b==1) d[c]=1;
		if(c==n) e[b]=1;
    }
    for(int i=0;i<n;i++){
        if(d[i]==1&&e[i]==1){
             f=1;
        }
    }
    if(f==0) cout<<"IMPOSSIBLE"<<endl;
    else cout<<"POSSIBLE"<<endl;
    return 0;
} 

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
#include <iomanip>  

using namespace std;
int main() {
	int n;
	double x[8], y[8], ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
	}
	for (int i = 0; i < n-1; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i < j) {
				ans = ans + sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
			}
		}
	}
	ans = ans * 2/n;
	cout << setprecision(15) << ans << endl;

}

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

using namespace std;

//#define cin f
//#define cout fo

//ifstream fi ("STONEFROG.INP");
//ofstream fo ("STONEFROG.INP");

int n, a[100001], f[100001];

//unsigned long long frog(unsigned long long i){
//	if (i == 1) return 0;
//	if ( i == 2){
//		f[i] = abs(a[i] - a[i-1]);
//		return f[i];
//	}
//	
//	f[i] = min(frog(i-1) + abs(a[i] - a[i-1]), frog(i-2)+ abs(a[i] - a[i-2]));
//	
//	return f[i];
//}

int main(){
//	freopen("test.txt" , "r" , stdin);
//	ios_base:: sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);

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

	f[2] = abs(a[2] - a[1]);
	f[1] = 0;
	for (int i = 3 ; i <= n ; i++){
		f[i] = min(f[i-1] + abs(a[i] - a[i-1]) , f[i-2] + abs(a[i] - a[i-2]));
	}
//	for (int i = 1 ; i <= n ; i++){
//		cout << f[i] << " ";
//	}
	cout << f[n];
	return 0;
}

Measured memory_bytes: 4384
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k,a,b;
    cin >> k >> a >> b;
    bool flag=0;
    for(int i=a;i<=b;++i){
        if(i%k==0){
            flag=1;
        }
    }

    if(flag){
        cout << "OK" ENDL;
    }else cout << "NG" ENDL;
    
    
    
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<cstring>

#define vti vector<int>
#define forn(i,a,n) for(int i=(a);i<(n);i++)
#define ford(i,a,d) for(int i=(a);i>(d);i--)
#define mset(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define mkp(a,b) make_pair(a,b)
using namespace std;
const long long N=2e5+3;
const long long inf=0x3f3f3f3f;
typedef long long ll;

ll ans=0;
ll cal(ll a)
{
    if(a==1) return a;
    else return 2*cal(a/2)+1;
}

int main()
{
//    ios::sync_with_stdio(false);
//    freopen("a.in","r",stdin);
//    freopen("ao","w",stdout);

    ll h;
    cin>>h;
    cout<<cal(h);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	//int INF = 1 << 28;
	long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt(); String str = sc.next() + "=";
			if(n == 0) break;
			
			depth = n%2==0? 2 : 1;
			System.out.println(minmax(0, str));
		}
	}
	
	int depth;
	long minmax(int d, String l) {
		if(d == depth) {
			line = l; p = 0;
			return d%2==0? or(): -or();
		}
		long max = -INF;
		for(String next: nextStr(l)) {
			max = max(max, -minmax(d+1, next));
		}
		return max;
	}
	char[] ops = {'|', '^', '&', '+', '-', '*'};
	String[] nextStr(String l) {
		HashSet<String> ret = new HashSet<String>();
		int n = l.length() - 1;
		
		for(int i=0;i<n;i++) {
			if( '0' <= l.charAt(i) && l.charAt(i) <= '9' ) {
				if(i>0 && '0' <= l.charAt(i-1) && l.charAt(i-1) <= '9') ret.add(l.substring(0, i) + l.substring(i+1)); 
				for(int j=0;j<10;j++) {
					if(j != 0) ret.add(l.substring(0, i) + j + l.substring(i));
					ret.add(l.substring(0, i+1) + j + l.substring(i+1));
				}
				if( '1' <= l.charAt(i+1) && l.charAt(i+1) <= '9' ) {
					for(char op: ops) ret.add(l.substring(0, i+1) + op + l.substring(i+1));
					ret.add(l.substring(0, i) + l.substring(i+1));
				}
			}
			else if( l.charAt(i) != '(' && l.charAt(i) != ')' ) {
				if('0' <= l.charAt(i-1) && l.charAt(i-1) <= '9' && '0' <= l.charAt(i+1) && l.charAt(i+1) <= '9')
					ret.add(l.substring(0, i) + l.substring(i+1));
			}
		}
		
		return ret.toArray(new String[]{});
	}
	
	String line; int p;
	char next() {
		return line.charAt(p++);
	}
	
	long or() {
		long a = xor();
		char c = next();
		while( c == '|' ) {
			a |= xor();
			c = next();
		}
		p--;
		return a;
	}
	
	long xor() {
		long a = and();
		char c = next();
		while( c == '^' ) {
			a ^= and();
			c = next();
		}
		p--;
		return a;
	}
	
	long and() {
		long a = add();
		char c = next();
		while( c == '&' ) {
			a &= add();
			c = next();
		}
		p--;
		return a;
	}
	
	long add() {
		long a = mlt();
		char c = next();
		while( c == '+' || c == '-' ) {
			if(c == '+') a += mlt();
			else 		 a -= mlt();	
			c = next();
		}
		p--;
		return a;
	}
	
	long mlt() {
		long a = num();
		char c = next();
		while( c == '*' ) {
			a *= num();
			c = next();
		}
		p--;
		return a;
	}
	
	long num() {
		char c = next();
		if( c == '(' ) { long a = or(); p++; return a; }
		String val = "";
		while( '0' <= c && c <= '9') {val += c; c = next();}
		p--;
		return Long.valueOf(val);
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 190816
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
        ll n,len,c1,c2,c3,c,ans=0;
        cin >> n;
        vector<vector<vector<vector<ll>>>> dp(n+1, vector<vector<vector<ll>>>(4, vector<vector<ll>>(4, vector<ll>(4))));
        dp.at(0).at(3).at(3).at(3) = 1;
        for(len=0;len<n;++len){
                for(c1=0;c1<4;++c1){
                        for(c2=0;c2<4;++c2){
                                for(c3=0;c3<4;++c3){
                                        if(dp.at(len).at(c1).at(c2).at(c3)==0) continue;
                                        for(c=0;c<4;++c){
                                                if(c2==0&&c1==1&&c==2) continue;
                                                if(c2==0&&c1==2&&c==1) continue;
                                                if(c2==1&&c1==0&&c==2) continue;
                                                if(c3==0&&c1==1&&c==2) continue;
                                                if(c3==0&&c2==1&&c==2) continue;
                                                dp.at(len+1).at(c).at(c1).at(c2) += dp.at(len).at(c1).at(c2).at(c3);
                                                dp.at(len+1).at(c).at(c1).at(c2) %= MOD;
                                        }
                                }
                        }
                }
        }
        for(c1=0;c1<4;++c1){
                for(c2=0;c2<4;++c2){
                        for(c3=0;c3<4;++c3){
                                ans += dp.at(n).at(c1).at(c2).at(c3);
                                ans %= MOD;
                        }
                }
        }
        cout << ans << endl;
        return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if(K < A){
    cout << K << endl;
  }else if(K < A+B){
    cout << A << endl;
  }else if(K < A+B+C){
    cout << A - (K-(A+B)) << endl;
  }else if(K == A+B+C){
    cout << A - C << endl;
  }
}

Measured memory_bytes: 3636
#include <stdio.h>

main()
{
  int a,b,ans=0;
  int i=0;

  while(scanf("%d%d",&a,&b) == 2 )
    {
      ans = a + b;
      while(1)
	{
	  if(ans == 0) break;
	  i++;
	  ans /= 10;
	}
      printf("%d\n",i);
      i = 0;
    }
  return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var n, q int
	fmt.Scan(&n)

	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&A[i])
	}

	fmt.Scan(&q)
	M := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&M[i])
	}

	numMap := make(map[int]struct{})
	numMap[0] = struct{}{}
	for i := 0; i < n; i++ {
		next := make(map[int]struct{})
		for val, _ := range numMap {
			next[val] = struct{}{}
		}

		for val, _ := range next {
			numMap[val+A[i]] = struct{}{}
		}
	}

	for i := 0; i < q; i++ {
		if _, ok := numMap[M[i]]; ok {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}

}



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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
//
const int N = 1e5+5 ; 
int par[N] ,lastx [N] , lasty[N] , x[N] , y[N] ; 
void init(int n ){
	for(int i= 0 ; i <= n ; i++ ){
		par[i] = i ; 
	}
}

int find_set (int u ){
	if( par[u] == u )
		return u ; 
	return par[u] = find_set ( par[u] ) ; 
}

void union_set(int u , int v ){
u = find_set ( u ) ; 
v = find_set ( v ); 
if( u == v ) return ; 
par[u] = v ; 
}

int main(){
int n ; 
cin >> n ; 
init(n); 
for(int i = 1 ; i <= n ; i++){
cin >> x[i] >> y[i] ;
if( lastx[x[i]] ) union_set ( i , lastx[x[i]] )  ; 
if( lasty[y[i]] ) union_set ( i , lasty[y[i]] ) ; 
lastx[x[i]]=i; 
lasty[y[i]]=i; 
}
map<int,set <int>> distinct_x , distinct_y ; 
for(int i = 1 ; i<= n ; i++ ){
distinct_x[find_set(i)].insert(x[i]); 
distinct_y[find_set(i)].insert(y[i]); 
}
set <int> sets ; 
for(int i = 1 ; i <= n ; i++ )sets.insert(find_set(i)); 
ll ans=0; 
for(int i : sets )ans += distinct_x[i].size()*distinct_y[i].size() ; 
ans -= n ; 
cout << ans << endl; 
}


Measured memory_bytes: 6912
#include<stdio.h>

int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int cnt = 0;
    
    for(int i = a; i <= b; i++){
        if(c % i == 0) cnt++;    
    }
    
    printf("%d\n", cnt);
    
    return 0;
}


Measured memory_bytes: 2092
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;

import std.typecons;
alias Seg = Tuple!(int, "l", int, "r", int, "len");

void main() {
    int n, m;
    scan(n, m);

    auto p = new Seg[](n);

    foreach (i ; 0 .. n) {
        int li, ri;
        scan(li, ri);
        p[i] = Seg(li, ri, ri - li + 1);
    }

    p.sort!"a.len < b.len"();

    writeln(n);

    auto ft = FenwickTree(m + 2);

    foreach (d ; 2 .. m + 1) {
        while (!p.empty && p.front.len < d) {
            ft.add(p.front.l, 1);
            ft.add(p.front.r + 1, -1);
            p.popFront();
            n--;
        }

        int ans = n;

        for (int i = 0; i <= m; i += d) {
            ans += ft.sum(i + 1);
        }

        writeln(ans);
    }
}


struct FenwickTree {
    private {
        int N;
        int[] data;
    }

    this(int n) {
        N = n;
        data = new int[](N + 1);
    }

    void add(int i, int x) {
        i++;
        while (i <= N) {
            data[i] += x;
            i += i & (-i);
        }
    }

    int sum(int r) {
        int res;
        while (r > 0) {
            res += data[r];
            r -= r & (-r);
        }
        return res;
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 7164
using System;
using System.Collections.Generic;

namespace Search
{
    class Dictionary
    {
        static void Main(string[] args)
        {
            var dic = new DNADictionary();

            var n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var com = Console.ReadLine().Split(' ');
                switch (com[0])
                {
                    case "insert":
                        dic.Add(com[1]);
                        break;
                    case "find":
                        if (dic.Find(com[1])) Console.WriteLine("yes");
                        else Console.WriteLine("no");
                        break;
                }
            }
        }

        class DNADictionary
        {
            const int A = 0;
            const int C = 1;
            const int G = 2;
            const int T = 3;

            HashSet<int> set;

            public DNADictionary()
            {
                set = new HashSet<int>();
            }

            public void Add(string str)
            {
                set.Add(Convert(str));
            }

            public bool Find(string str)
            {
                if (set.Contains(Convert(str))) return true;
                else return false;
            }

            internal int Convert(string str)
            {
                var length = str.Length;
                var key = 0;
                for (int i = length - 1; i >= 0; i--)
                {
                    switch (str[i])
                    {
                        case 'A':
                            key = (A + key) << 2;
                            break;
                        case 'C':
                            key = (C + key) << 2;
                            break;
                        case 'G':
                            key = (G + key) << 2;
                            break;
                        case 'T':
                            key = (T + key) << 2;
                            break;
                    }
                }
                key = (key << 2) + length;
                return key;
            }
        }
    }
}

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

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 vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


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

    vl l(n);
    rep(i, n) cin >> l[i];

    ll cnt = 0;

    rep(i, n - 2) {
        rep(j, i + 1, n - 1) {
            rep(k, j + 1, n) {
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;

                vl t = {l[i], l[j], l[k]};
                sort(rng(t));

                if (t[2] < t[1] + t[0])
                    cnt++;
            }
        }
    }

    prt(cnt);

    return 0;
}


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

char a[100],b[100];
int c[100]={1};

int main ()
{
	long long n,i,sn=1,bj=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		cin>>b[i];
	for(i=0;i<n;i++)
	{
		if(a[i]==b[i])
			c[bj++]=1;
		else
		{
			c[bj++]=2;
			i++;
		}
	}
	c[bj]=0;
	if(c[0]==1)
		sn*=3;
	else
		sn*=6;
	for(i=1;i<n;i++)
	{
		if(c[i]==0)
			break;
		long long t=sn;
		if(c[i-1]==1)
			sn*=2;
		else if(c[i]==2)
			sn*=3;
		else
			sn*=1;
		sn=sn%1000000007;
	}
	cout<<sn<<endl;
} 

Measured memory_bytes: 256
n = int(raw_input())

dp = [0]*(3)

for i in range(n):
    dp_new = [0]*3
    c=map(int,raw_input().split())
    
    for i in range(3):
        for j in range(3):
            if i != j:
                dp_new[j] = max(dp_new[j],dp[i]+c[j])
    dp = dp_new
print(max(dp))

Measured memory_bytes: 5764
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 x[100];
s64 y[100];
s64 h[100];

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

    int N;
    cin >> N;

    rep (i, N)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    if (N == 1)
    {
        cout << x[0] << " " << y[0] << " " << h[0] << "\n";
        return 0;
    }

    s64 cx, cy, H;
    bool detected;
    for (cx = 0; cx <= 100; ++cx)
    {
        for (cy = 0; cy <= 100; ++cy)
        {
            detected = true;
            int temp = 0;
            while (h[temp] == 0) ++temp;
            H = abs(x[temp] - cx) + abs(y[temp] - cy) + h[temp];
            for (int i = 0; i < N && detected; ++i)
            {
                s64 height = MAX(H - abs(x[i] - cx) - abs(y[i] - cy), 0);
                if (height != h[i])
                {
                    detected = false;
                }
            }
            if (detected) break;
        }
        if (detected) break;
    }

    cout << cx << " " << cy << " " << H << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,ans=0;
  std::cin>>n;

  std::vector<ll> a(n+2),b(n+2);

  rep(i,0,n)std::cin>>a[i];
  rep(i,0,n)std::cin>>b[i];
  a[n]=a[0];a[n+1]=a[1];
  b[n]=b[0];b[n+1]=b[1];

  std::priority_queue<P> que;

  rep(i,1,n+1){
    if((b[i]>b[i-1]+b[i+1])&&(b[i]!=a[i])){
      que.push(P(b[i],i));
    }
  }

  while(que.size()){
    P p=que.top();que.pop();
    ll itr=p.second;

    ll temp=MOD,x=b[itr-1]+b[itr+1];

    if((b[itr]-a[itr])%x==0)temp=(b[itr]-a[itr])/x;

    ll cnt=std::min((b[itr]-1)/x,temp);

    ans+=cnt;

    b[itr]-=cnt*x;

    b[0]=b[n];
    b[n+1]=b[1];

    itr=(itr+n-2)%n+1;
    if((b[itr]>b[itr-1]+b[itr+1])&&(b[itr]!=a[itr])&&(b[itr]>0)){
      que.push(P(b[itr],itr));
    }
    itr=(itr+n+1)%n+1;
    if ((b[itr] > b[itr - 1] + b[itr + 1]) && (b[itr] != a[itr]) &&
        (b[itr] > 0)) {
      que.push(P(b[itr], itr));
    }
  }

  rep(i,1,n+1){
    if(b[i]!=a[i]){
      std::cout<<-1;
      return 0;
    }
  }

  std::cout<<ans;

  return 0;
}


Measured memory_bytes: 5620
#include<iostream>

using namespace std;

string code;
bool enter = false;

int main()
{
	cin >> code;
	for(int i = 0;i < 3;i ++) 
			if(code[i]==code[i+1])
				enter = true;
	if(enter)
		cout << "Bad" << endl;
	else
		cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=2005;
const int MOD=1000000007;

int n,k,f[N][N][3];

void updata(int &x,int y)
{
	x+=y;x-=x>=MOD?MOD:0;
}

int main()
{
	scanf("%d%d",&n,&k);
	f[n+1][0][2]=1;
	for (int i=n+1;i>1;i--)
	{
		for (int j=n;j>=0;j--) updata(f[i][j][1],f[i][j+1][1]);
		for (int j=0;j<=n;j++)
			for (int t=1;t<=2;t++)
			{
				updata(f[i-1][j+1][2],f[i][j][t]);
				updata(f[i-1][j][1],f[i][j][t]);
			}
	}
	int ans=f[1][n-k][1];
	for (int j=1;j<=n-k-1;j++) updata(ans,ans);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 47360
a=1/3
while 1:
    z=int(input())
    if z==0:break
    m,zz=0,z*z*z
    for x in range(1,int(z/pow(2,a))+1):
        xx=x*x*x
        y=int(pow(zz-xx,a))
        yy=y*y*y
        m=max(m,yy+xx)
    print(zz-m)

Measured memory_bytes: 7692
#define DivertaPC2019_A
#ifdef DivertaPC2019_A

#pragma comment (linker, "/STACK:256000000")
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    write(N - K + 1);
}

#endif

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, n) for (int i = 0; i < (int)(n); i++) // repマクロ

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = a - 2*b;
  if (ans <= 0)
    cout << 0 << endl;
  else
    cout << ans << endl;
}

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

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

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  for(i=0;i<r;i++){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

int main(){
  ll i,N,K;
  cin>>N>>K;
  for(i=0;i<K;i++)cout<< (modncr(K-1,i)*modncr(N-K+1,i+1))%mod <<endl;
  return 0;
}

Measured memory_bytes: 256
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		new Main();	
	}

	public Main() {
		while(sc.hasNext()){
			new aoj0057().doIt();
		}
	}
	class aoj0057 {
		int a[] = new int [10001];
		void DP(){
			a[0] = 1;
			for(int i = 1;i <= 10000;i++)a[i] = a[i-1] + i;
		}
		void doIt() {
			DP();
			int n = sc.nextInt();
			System.out.println(a[n]);
		}
	}
}

Measured memory_bytes: 22068
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
typedef long long ll;
int N;
ll d[100000], cnt[100000];
int main() {
  scanf("%d", &N);
  for (auto i = 0; i < N; i++) {
    scanf("%ld", d + i);
    cnt[d[i]]++;
  }
  if (d[0] != 0 || cnt[0] >= 2) {
    puts("0");
    return 0;
  }
  ll res = 1;
  for (auto i = 2; i < N; i++) {
    for (auto j = 0; j < cnt[i]; j++) {
      res = (res * cnt[i - 1]) % MOD;
    }
  }
  printf("%ld\n", res);
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int a[200005];

int main(){
	int n;
	long long sum = 0;
	scanf("%d", &n);
	int temp;
	for(int i=  1; i <= n ;i++){
		scanf("%d", &a[i]);
		a[i] -= i;
	}
	sort(a+1, a+n+1);
	if(n%2)
		temp = a[(n+1)/2];
	else
		temp = a[n/2];
	for(int i=1; i<= n; i++){
		sum += abs(a[i]-temp);
	}
	printf("%lld\n", sum);
return 0;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  int mx=0,mi=INF;
  repeat(i,N){
    int A;cin>>A;
    mx = max(mx,A);
    mi = min(mi,A);
  }
  cout << mx-mi << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#define MIN 1<<31-1
#define HMAX 1000000000000000000
#define MOD 1000000007
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RSET(s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
typedef long long int ll;
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int ans=a;
	if(b<a)
	ans--; 
	cout<<ans;
//  freopen("1.txt","r",stdin);
//  freopen("2.txt","w",stdout);
	return 0;
}

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

#define H 50
#define W 50

int h, w;
char s[H+2][W+2];

int main(void)
{
    cin >> h >> w;
    int cntWhite = 0;
    int dist[H+2][H+2];
    for (int i = 0; i <= h+1; i++){
        for (int j = 0; j <= w+1; j++){
            dist[i][j] = -1;
            s[i][j] = '#';
        }
    }

    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            cin >> s[i][j];
            if (s[i][j] == '.'){
                cntWhite++;
            }
        }
    }

    queue<int> searchCoor;
    searchCoor.push(1);
    searchCoor.push(1);
    dist[1][1] = 1;
    while (searchCoor.empty() == false && dist[h][w] == -1){
        int nowH = searchCoor.front(); searchCoor.pop();
        int nowW = searchCoor.front(); searchCoor.pop();
        for (int j = -1; j < 3; j++){                           // sin, cos内部の値が大きいと誤差で正確な値がでない...
            int nextH = nowH + sin(0.5*j*M_PI);
            int nextW = nowW + cos(0.5*j*M_PI);
            if (s[nextH][nextW] == '.' && dist[nextH][nextW] == -1){
                searchCoor.push(nextH);
                searchCoor.push(nextW);
                dist[nextH][nextW] = dist[nowH][nowW] + 1;
            }
        }
    }

    int ans = ( (dist[h][w] == -1) ? -1 : cntWhite - dist[h][w] );
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4024
#include <iostream>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>



typedef long long lli;

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

#define rep1(i, n) for(int i=1; i < (int)(n); i++)

#define all(x) (x).begin(),(x).end()

#define fill(x,y) memset(x,y,sizeof(x))

#define debug1(i) cout << i << '\n'

#define debug2(i,j) cout << i << j << '\n'



using namespace std;
lli gcd(lli a, lli b) {
	lli c;
	while (a % b != 0) {
		c = b;
		b = a % b;
		a = c;
	}
	return b;
}

lli lcm(lli a, lli b) {
	return a * b / gcd(a, b);
}



int main() {
	lli a, b, c, d, e;
	cin >> a >> b >>c >> d;

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


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  ll d1=h1*60+m1,d2=h2*60+m2;
  d2-=k+d1;
  pr(max(0LL,d2));
}

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


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
        x[i]--;
    }

    vector<int> a(N * N, -1);
    for (int i = 0; i < N; i++) a[x[i]] = i;

    queue<int> que;
    vector<pair<int, int>> p(N);
    for (int i = 0; i < N; i++) p[i] = pair<int, int>(x[i], i);
    sort(p.begin(), p.end());

    for (int i = 0; i < N; i++) {
        int j = p[i].second;
        for (int k = 0; k < j; k++) que.push(j);
    }
    for (int i = 0; i < N; i++) {
        int j = p[i].second;
        for (int k = 0; k < N - j - 1; k++) que.push(j);
    }

    for(int i=0; i<N*N; i++){
        if (a[i] == -1) {
            a[i] = que.front();
            que.pop();
        }
    }

    vector<int> cnt(N, 0);
    for(int i=0; i<N*N; i++){
        cnt[a[i]]++;
        if(cnt[a[i]] == a[i]+1 && i != x[a[i]]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 0; i < N * N; i++) cout << a[i] + 1 << " ";

    return 0;
}


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

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

    int n;
    cin >> n;
    int a[n];
    rep(i,0,n) cin >> a[i];
    bool flag=true;
    rep(i,0,n){
        if(a[i]%2==0){
            if(a[i]%3!=0 and a[i]%5!=0)flag=false;
        }
    }
     if(flag) cout <<"APPROVED"<<"\n";
     else cout <<"DENIED"<<"\n";
    
}

Measured memory_bytes: 256
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  string s;cin>>s;
  REP(i,s.length()) {
    if(i%2==0) {
      if(s[i]=='L') {
        p("No");
        return 0;
      }
    } else {
      if(s[i]=='R') {
        p("No");
        return 0;
      }
    }
  }
  p("Yes");
  return 0;
}



Measured memory_bytes: 256
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, X = list(map(int, input().split()))

M = []
for _ in range(N):
    M.append(int(input()))

ans = len(M) + (X - sum(M)) // min(M)
print(ans)


Measured memory_bytes: 13560
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;

ll mymod(ll a, ll b)
{
	return (a%b + b)%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
struct vertex
{
	vll adj;
};

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<int>> G;
vector<vector<int>> Tree;
using P = pair<int, int>;
vector<P> edge;
map<P, bool> used;
vector<P> res;
vector<bool> deg;
vector<bool> visited;

void dfs(int p, int u) {
    visited[u] = true;
    for(int to : G[u]) {
        if(visited[to]) continue;
        dfs(u, to);
    }
    if(p != -1) {
        Tree[u].push_back(p);
        Tree[p].push_back(u);
        used[P(u, p)] = true;
        used[P(p, u)] = true;
    }
}

bool init() {
    cin >> N >> M;
    G.resize(N);
    Tree.resize(N);
    deg.resize(N, false);
    visited.resize(N, false);
    for(int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        edge.push_back(P(a, b));
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if(M % 2) return false;
    dfs(-1, 0);
    return true;
}

void dfs2(int p, int u) {
    visited[u] = true;
    for(int to : Tree[u]) {
        if(visited[to]) continue;
        dfs2(u, to);
    }
    if(p != -1) {
        if(deg[u]) {
            res.push_back(P(u, p));
        } else {
            res.push_back(P(p, u));
            deg[p] = !deg[p];
        }
    }
}

void solve() {
    for(P e : edge) {
        if(!used[e] | !used[P(e.second, e.first)]) {
            res.push_back(e);
            used[e] = false;
            deg[e.first] = !deg[e.first];
        }
    }
    visited.assign(N, false);
    dfs2(-1, 0);
}

int main() {
    if(!init()) {
        cout << -1 << endl;
        return 0;
    }
    solve();
    for(P e : res) {
        cout << e.first + 1 << ' ' << e.second + 1 << endl;
    }
}

Measured memory_bytes: 35956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int compare_int(const void *a, const void *b) {
    return *(int *)a - *(int *)b;  //昇順
                                   // return *(int*)b - *(int*)a;//降順
}

int main() {
    int n, k;
    cin >> n >> k;
    int *h = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    qsort(h, n, sizeof(int), compare_int);
    ll sum = 0;
    for (int i = 0; i < n - k; i++) {
        sum += h[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	static final long MOD = 1000000007;
	static long[][] table;
	static long[][] table2;
	static int N, M;
	static long[] pot2, invPot2;
	
	static long calc(int rem, int bits) {
		long ret = table[rem][bits];
		if (ret != -1) return ret;
		if (bits == 1) return table[rem][bits] = pot2[rem];
		ret = (calc2(rem - 1, bits - 1) * pot2[rem]) % MOD;
		ret += (rem + 1) * calc(rem, bits - 1);
		ret %= MOD;
		return table[rem][bits] = ret;
	}
	
	static long calc2(int rem, int bits) {
		long ret = table2[rem][bits];
		if (ret != -1) return ret;
		if (rem == 0) return table2[rem][bits] = 0;
		ret = calc2(rem - 1, bits);
		long tmp = (rem * calc(rem, bits)) % MOD;
		tmp = (tmp * invPot2[rem + 1]) % MOD;
		ret = (ret + tmp) % MOD;
		return table2[rem][bits] = ret;
	}
	
	static long eleva(long a, int e) {
		if (e == 0) return 1;
		long ret = eleva(a, e / 2);
		ret = (ret * ret) % MOD;
		if (e % 2 == 1) {
			ret = (ret * a) % MOD;
		}
		return ret;
	}
	
	static long inv(long a) {
		return eleva(a, (int)MOD - 2);
	}
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		N = sc.nextInt();
		M = sc.nextInt();
		pot2 = new long[M + 1];
		invPot2 = new long[M + 1];
		pot2[0] = 1;
		for (int i = 1; i < pot2.length; i++) {
			pot2[i] = (pot2[i-1] * 2) % MOD;
		}
		invPot2[pot2.length - 1] = inv(pot2[pot2.length - 1]);
		for (int i = pot2.length - 2; i >= 0; i--) {
			invPot2[i] = (invPot2[i+1] * 2) % MOD;
		}
		table = new long[M+1][N+1];
		table2 = new long[M+1][N+1];
		for (int i = 0; i < table.length; i++) {
			Arrays.fill(table[i], -1);
			Arrays.fill(table2[i], -1);
		}
		out.println(calc(M, N));
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 573556
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n, m, k;
	int flag = 0;

	scanf("%d %d %d", &n, &m, &k);
	
	for (int i = 0; i <= m; i++) {
		for (int j = 0; j <= n; j++) {
			if (n * i + m * j - 2 * i * j == k) {
					flag = 1;
					break;
			}
		}
		if (flag)break;
	}
	
	if (flag)printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128