akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; ++i )
int main(){
  int N;
  bool can_go[20][20][20][20];
  cin >> N;
  while( N-- ){
    int gx,gy,q,dp[20][20];
    fill_n(can_go[0][0][0],160000,true);
    fill_n(dp[0],400,0);
    dp[0][0] = 1;
    cin >> gx >> gy;
    cin >> q;
    while( q-- ){
      int sx,sy,gx,gy;
      cin >> sx >> sy >> gx >> gy;
      can_go[sx][sy][gx][gy] = false;
      can_go[gx][gy][sx][sy] = false;
    }
    for(int i = 0 ; i <= gx ; i++ ){
      for(int j = 0 ; j <= gy ; j++ ){
        if(can_go[i][j][i+1][j]) dp[i+1][j] += dp[i][j];
        if(can_go[i][j][i][j+1]) dp[i][j+1] += dp[i][j];
      }
    }
    if(!dp[gx][gy]) cout << "Miserable Hokusai!" << endl;
    else cout << dp[gx][gy] << endl;
  }
}

Measured memory_bytes: 1316
# coding: utf-8
# Your code here!
# 行数を取得
import sys
list=[]
for line in sys.stdin:
    list.append(line)

NandX=list[0].split()

N=int(NandX[0])
X=int(NandX[1])

L=list[1].split()
D=0
i=0

if N==1:
    print(1)
else:
    while D<=X and i<=N-1:
        D=D+int(L[i])
        i+=1
        
    if i==N and D<=X:
        print(N+1)
    else:
        print(i)


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

using ll = long long int;
using P = pair<int,int>;
constexpr int INF = 1<<30;

int n;
vector<vector<P> > g;
vector<int> d;

void dijkstra(int s){
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(make_pair(d[s],s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        int k = int(g[v].size());
        for(int i=0;i<k;i++){
            int u = g[v][i].first, c = g[v][i].second;
            if(d[u] > d[v] + c){
                d[u] = d[v] + c;
                que.push(make_pair(d[u], u));
            }
        }
    }
}

int main(){
    cin >> n;
    g.resize(n);
    d.resize(n);
    for(int i=0;i<n;i++){
        int v, k;
        cin >> v >> k;
        for(int j=0;j<k;j++){
            int u, c;
            cin >> u >> c;
            g[v].push_back(make_pair(u,c));
        }
    }
    dijkstra(0);
    for(int i=0;i<n;i++){
        cout << i << " " << d[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ar[50][50];
int main()
{
    ll ans=0;
    string s,t,str;
    cin >> s >> t;
    ll a,b;
    cin >> a >> b;
    cin >> str;
    if(str==s) cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
    return 0;
}



Measured memory_bytes: 256
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
candi = int(N / 1.08)
if int(candi * 1.08) == N:
    print(candi)
elif int((candi + 1) * 1.08) == N:
    print(candi + 1)
else:
    print(':(')


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll n, k;
  cin >> n >> k;
  vll d(k);
  vll have(n, 0);
  rep(i, 0, k){
    cin >> d.at(i);
    rep(j, 0, d.at(i)){
      ll aa;
      cin >> aa;
      aa--;
      have.at(aa) = 1;
    }
  }

  ll ans = 0;
  rep(i, 0, n) if(have.at(i) == 0) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	int a, b;
	cin >> a >> b;
	if (a %b == 0)cout << 0 << rt;
	else cout << 1 << rt;

	please AC;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int num[100][100];
int dp[100][100]={0};
int main(){
    string str;
    int k,c,i,n=0;
    while(cin>>str){
        n++;
        k=0,c=0,i=0;
        for(i=0;i<str.length();i++){
            if(str[i]==','){
                num[n-1][c]=k;
                c++;
                k=0;
            }
            else{
                k*=10;
                k+=str[i]-'0';
            }
        }
        num[n-1][c]=k;
    }
    dp[0][0]=num[0][0];
    for(i=0;i<(n-1)/2;i++){
        for(int j=0;j<=i;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]+num[i+1][j]);
            dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+num[i+1][j+1]);
        }
    }
    for(;i<n-1;i++){
        for(int j=0;j<n-i;j++){
            if(j>0)dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+num[i+1][j-1]);
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]+num[i+1][j]);
        }
    }
    cout<<dp[n-1][0]<<endl;;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
using namespace std;
const int N = 1e4 + 5;
int n,t;
struct node{
    int w,v;
    bool operator < (node & rhs)const {
        return w<rhs.w;
    }
}s[N];
int dp[N];

int main(){
    scanf("%d%d", &n,&t);
    rep(i,1,n) scanf("%d%d", &s[i].w, &s[i].v);
    sort(s+1,s+1+n);
    rep(i,1,n){
        per(j,t+s[i].w-1,0){
            if(j>=s[i].w) dp[j] = max(dp[j],dp[j-s[i].w]+s[i].v);
        }
    }
    int ans = 0;
    rep(i,t,6000) ans = max(ans, dp[i]);
    printf("%d\n", ans);
    return 0;
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int k;
	int s;
	cin >> k >> s;
	int res = 0;
	for (size_t a = 0; a <= k; a++) {
		for (size_t b = 0; b <= k; b++) {
			int c = s - (a + b);
			if (0 <= c && c <= k) {
				// printf("%d %d %d\n", a, b, c);
				res ++;
			}
		}
	}
	cout << res << endl;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  cout << s[0] << s.length() - 2 << s[s.length()-1] << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin>>n;
	//int t=n;
	int p[101]={0};
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++) p[i*j]=1;
	}
	if(p[n]) cout<<"Yes";
	else cout<<"No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys


def solve(n: int, h: "List[int]"):
    ret = 0
    while True:
        tmp = 0
        found = False
        for i in range(n):
            if h[i] > 0:
                h[i] -= 1
                if not found:
                    found = True
                    tmp += 1
            else:
                found = False
        if tmp < 1:
            break
        else:
            ret += tmp
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};
int h,w;
int dist[1010][1010];
string s[1010];
int main(){
	cin>>h>>w;
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--;cw--;dh--;dw--;
	rep(i,h){
		cin>>s[i];
	}
	rep(i,h)rep(j,w)dist[i][j]=INF;
	deque<pii> q;
	dist[ch][cw]=0;
	q.push_back(mp(ch,cw));
	while(!q.empty()){
		pii p=q.front();
		q.pop_front();
		int x=p.fi,y=p.sc;
		rep(i,4){
			int xx=x+dx[i],yy=y+dy[i];
			if(xx<0||xx>=h||yy<0||yy>=w){
				continue;
			}
			if(s[xx][yy]=='#'){
				continue;
			}
			if(dist[xx][yy]<=dist[x][y]){
				continue;
			}
			dist[xx][yy]=dist[x][y];
			q.push_front(mp(xx,yy));
		}
		for(int i=x-2;i<=x+2;i++){
			for(int j=y-2;j<=y+2;j++){
				if(i<0||i>=h||j<0||j>=w){
					continue;
				}
				if(s[i][j]=='#'){
					continue;
				}
				if(dist[i][j]<=dist[x][y]+1){
					continue;
				}
				dist[i][j]=dist[x][y]+1;
				q.push_back(mp(i,j));
			}
		}
	}
	if(dist[dh][dw]==INF){
		cout<<-1;
		return 0;
	}
	cout<<dist[dh][dw];
	return 0;
}

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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
int checkerCounter = 1;
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++)cin>>s[i];
    int dp[n][m];
    if(s[0][0]=='.')dp[0][0]=0;
    else dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(i==0 and j==0){
               continue;
            }
            if(i==0){
                dp[i][j]=dp[i][j-1];
                if(s[i][j]=='#' and s[i][j-1]=='.')dp[i][j]++;
                continue;
            }
            if(j==0){
                dp[i][j]=dp[i-1][j];
                if(s[i][j]=='#' and s[i-1][j]=='.')dp[i][j]++;
                continue;
            }
            int x=dp[i][j-1];
            int y=dp[i-1][j];
            dp[i][j]=min(x,y);
            if(y<x){
                if(s[i][j]=='#' and s[i-1][j]=='.')dp[i][j]++;
            }
            if(x<y){
                if(s[i][j]=='#' and s[i][j-1]=='.')dp[i][j]++;
            }
            if(x==y){
                if(s[i][j]=='#' and s[i][j-1]=='.' and s[i-1][j]=='.')dp[i][j]++;
            }
        }
    }
//    for(int i=0;i<n;i++){
//        for(int j=0;j<m;j++){
//            cout<<dp[i][j]<<" ";
//        }cout<<endl;
//    }
    cout<<dp[n-1][m-1]<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
int main() {
	char s[2][110];
	int d[2];
	scanf("%s%s", s[0], s[1]);
	for (int i = 0; i < 2; i++)
	{
		int j = 0;
		for (; s[i][j] != '\0'; j++);
		d[i] = j;
	}
	if (d[0] > d[1])		printf("GREATER");
	else if (d[0] < d[1])	printf("LESS");
	else
	{
		int i = 0;
		while (1)
		{
			if (s[0][i] > s[1][i])
			{
				printf("GREATER");
				break;
			}
			else if (s[0][i] < s[1][i])
			{
				printf("LESS");
				break;
			}
			i++;
			if (i > d[0])
			{
				printf("EQUAL");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < B.length(); i++) {
			sb.append(A.charAt(i));
			sb.append(B.charAt(i));
		}

		if (A.length() > B.length()) {
			sb.append(A.charAt(B.length()));
		}

		System.out.println(sb.toString());


	}

}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int i;
    for(i = 1; i < n; i++)  if(s[i] == 'x' && s[i-1] == 'x')    break;
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <string>
#define MAX 100007
#define scn1(a) scanf("%d", &a);
#define scn2(a, b) scanf("%d %d", &a, &b);
#define scn3(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define lscn1(a) scanf("%lli", &a);
#define lscn2(a, b) scanf("%lli %lli", &a, &b);
#define lscn3(a, b, c) scanf("%lli %lli %lli", &a, &b, &c);
#define prnt(a) printf("%d\n", a);
#define forr(i, a, n) for(int i=a;i<n;i++)
#define nl puts("");
#define PB push_back
#define enl cout << "\n";
#define CHK(a) cout << (#a) << " = " << (a) << endl;
typedef long long int ll;
using namespace std;
void arraychk(int a[],int n) {for(int i=0;i<n;i++)cout<<a[i]<<" ";enl;}
#define LOOPCHK(a, n) arraychk(a, n);

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll tt=1;
    // cin >> tt;
    for(int cse=1; cse<=tt; cse++)
    {
        int i=0, j=0, k=0, l=0, m=0,
        n=0, x=0, y=0, ans=0, sum=0;
        
        cin >> n;
        // cout << "Case " << cse <<  ":";
        if(n) cout << 0 << endl;
        else cout << 1 << endl;
    }
    return 0;
}


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

#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}



string mat[15];

int r[15];
int c[1005];

int main()
{
  ios::sync_with_stdio(false);
  int h,w,k;
  cin >> h >> w >> k;

  for(int i = 0; i < h; i++)
    cin >> mat[i];

  int ans = INT_MAX;

  for(int mask = 0; mask < (1 << (h - 1)) ; mask++)
  {
    int res = __builtin_popcount(mask);
    vector<int>cnt(res + 1, 0);
    for(int j = 0; j < w; j++)
    {
      int p = 0;
      for(int i = 0 ; i < h; i++)
      {
        cnt[p] += mat[i][j] == '1';
        if(mask & (1 << i))
          p++;
      }

      bool cut = false;
      for(const auto &c : cnt)
      {
        if(c > k)
          cut = true;
      }

      if(cut)
      {
        res++;
        fill(cnt.begin(), cnt.end(), 0);
        p = 0;
        for(int i = 0 ; i < h; i++)
        {
          cnt[p] += mat[i][j] == '1';
          if(mask & (1 << i))
            p++;
        }

        bool cut = false;
        for(const auto &c : cnt)
        {
          if(c > k)
            cut = true;
        } 

        if(cut)
        {
          res = 2e9;
          break;
        }
      }
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    ll a, b; cin >> a >> b;
    cout << lcm(a, b) << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
int Size = 1e14;


int32_t main()
{


        string str;
        cin>>str;

        int cnt=0,mx=0;
        for(int i=0; i<str.size(); i++){
            if(str[i]=='R') cnt++;
            else {
             mx=max(mx,cnt);
             cnt=0;
            }
        }
              mx=max(mx,cnt);
        cout<<mx<<endl;


	return 0;
}


Measured memory_bytes: 3548
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $k);
for($i = $a; $i <= min($b, $a + $k - 1); $i++) {
    echo $i. "\n";
}
for($i = max($a + $k, $b - $k + 1); $i < $b + 1; $i++) {
    echo $i. "\n";
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, k; cin >> n >> k;
	VI h(n); REP(i, n)cin >> h[i];
	sort(ALL(h), greater<ll>());
	ll ans = 0;
	REP(i, n) {
		if (i >= k)
			ans += h[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int m, n;
    int i, j;
    scanf("%d %d", &n, &m);
    int a[n], b[n], c[m], d[m];
    for(i=0; i<n; i++){
        scanf("%d %d", &a[i], &b[i]);
    }
    for(j=0; j<m; j++){
        scanf("%d %d", &c[j], &d[j]);
    }
    // end to read

    int minp[n],  min;
    int k, l, h;
    for(k=0; k<n; k++){
        min = abs(a[k]-c[0]) + abs(b[k]-d[0]);
        minp[k] = 1;
        for(l=1; l<m; l++){
            int dis = abs(a[k]-c[l]) + abs(b[k]-d[l]);
            if(dis<min){
                min = dis;
                minp[k] = l+1;
            }
        }
    }
    for(h=0; h<n; h++){
        printf("%d\n", minp[h]);
    }
    return 0;
}


Measured memory_bytes: 128
a1,a2,a4,a8 = map(int, input().split())
n = int(input())
MIN_2 = min(a1*8,a2*4,a4*2,a8)
MIN_1 = min(a1*4,a2*2,a4)
a = (n // 2) 
b = (n - a*2) // 1
print(a*MIN_2+b*MIN_1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 10000+10;
const int mod = 1e9+7;
int num[26];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ms(num, 0);
    string s;
    cin >> s;
    for(int i = 0;i<s.size();i++)   num[s[i]-'a']++;
    LL ans = 1LL*s.size()*(s.size()-1)/2;
    for(int i = 0;i<26;i++){
        ans -= 1LL*(num[i])*(num[i]-1)/2;
    }
    ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 400020
using namespace std;
int read(){
	int nm=0,fh=1;char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int n,m,L,R,md,t[M],ans,p[M],t1,t2;
bool solve(int x){
	t1=0,t2=(n<<1);
	for(int i=1;i<=m;i++) p[i]=(t[i]>=x);
	for(int i=2;i<=n;i++) if(p[i]==p[i-1]) t1=i;
	for(int i=m-1;i>=n;i--) if(p[i]==p[i+1]) t2=i;
	if(t1==n||t2==n) return p[n]>0;
	if(t1>1&&t2<m&&p[t1]==p[t2]) return p[t1]>0;
	if(t2-n<n-t1) return p[t2]>0;
	if(t2-n>n-t1) return p[t1]>0;
	return (p[n]^(n&1)^1)>0;
}
int main(){
	n=read(),L=1,R=n,R<<=1,R--,m=R;
	for(int i=1;i<=n+n-1;i++) t[i]=read();
    while(L<=R){
    	md=(L+R>>1);
    	if(!solve(md)) R=md-1;
		else L=md+1,ans=md;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iterator>
#include <utility>
#include <string>
#include <algorithm>
#include <time.h>
#include <tuple>
#include <deque>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <iostream>

#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define pll pair<long long, long long>
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long int ll;

mt19937 rnd(time(NULL));

const ll INF = (ll)1e18;
const ll MOD = 1e9 + 7;
const ll maxn = (ll)2 * 1e5 + 10, L = 23;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    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 <iostream>
#include <algorithm>
#include <math.h>
#include <numeric>

#include <vector>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int main()
{
	int N;
	cin >> N;
	vector<double> v(N);
	rep(i, N)
	{
		cin >> v[i];
	}
	double val = 0;
	int len = v.size();
	while (len > 1)
	{
		sort(v.begin(), v.end());
		val = (v[0] + v[1]) / 2.0;
		v.erase(v.begin(),v.begin()+2);
	//	print(v.size())
	//	print(val)
		v.push_back(val);
		len--;
	}
	cout << v[0];
}


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

int main(){
  string s,t;
  cin >> s >> t;
  int a = t.size();
  int b = s.size();
  rep(i,a){
    cout << s[i] << t[i];
  }
  if(a != b){
    cout << s[a];
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

struct UnionFind {
	vector<int> data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}

	int find(int k) {
		if(data[k] < 0) return(k);
		return data[k] = find(data[k]);
	}

	bool same(int x, int y)	{
		return find(x) == find(y);
	}

	int size(int k)	{
		return -data[find(k)];
	}
};

struct Edge{
    int u, v;
};

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

    int n, m; cin >> n >> m;
    vector<Edge> edges(m);
    rep(i, m) {
        int x, y; cin >> x >> y;
        x--; y--;
        edges[i] = Edge{x, y};
    }

    int ans = 0;
    rep(i, m) {
        UnionFind uf(n);
        rep(j, m) {
            if (i==j) continue;
            uf.unite(edges[j].u, edges[j].v);
        }
        bool ok = true;
        rep(k, n) rep(l, n) {
            if (!uf.same(k, l)) ok = false;
        }
        if (!ok) ans++;
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

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

	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	int d = a[2] - a[0] + a[2] - a[1];

	int ans = d / 2;

	if (d % 2) {
		ans += 2;
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_qsort.c                                         :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: tnakamur <tnakamur@student.42tokyo.jp>     +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/18 12:28:01 by tnakamur          #+#    #+#             */
/*   Updated: 2020/04/18 14:09:57 by tnakamur         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <unistd.h>
#include <stdio.h>

void	ft_swap(int *a, int *b)
{
	int tmp;
	
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void	ft_qsort(int *tab, int left, int right)
{
	int Left = left;
	int Right = right;
	int pivot = tab[(left + right) / 2];

	while (1)
	{
		while (tab[Left] < pivot)
			Left++;
		while (tab[Right] > pivot)
			Right--;
		if (Left >= Right)
			break ;
		ft_swap(&tab[Left], &tab[Right]);
		Left++;
		Right--;
	}

	if (Left - 1 > left)
		ft_qsort(tab, left, Left - 1);
	if (Right + 1 < right)
		ft_qsort(tab, Right + 1, right);
}

int		main(void)
{
	int n;
	scanf("%d", &n);
	int tab[n];
	int i = 0;
	while (i < n)
		scanf("%d", &tab[i++]);
	ft_qsort(tab, 0, n - 1);
	int arc = tab[n / 2];
	int abc = tab[(n / 2) - 1];
	printf("%d\n", arc - abc);
	return (0);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s;
    int k;
    cin >> s >> k;
    set<char> ls;
    int n = s.length();
    rep(i, n) {
        ls.insert(s[i]);
    }
    vstr ans;
    for (char t : ls) {
        if (ans.size() > k) break;
        rep(i, n) {
            if (s[i] == t) {
                rep(j, k) {
                    string tmp = s.substr(i, j+1);
                    if (vfind(ans, tmp) == false) ans.push_back(tmp);
                }
            }
        }
    }
    sort(all(ans));

    cout << ans[k-1] << endl;
    return 0;
}

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

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  
  if (n == 0) cout << x << endl;
  
  else {
    bool fin = false;
    rep(i, n) {
      if (p[i] == x) break;
      if (i == n - 1) {
        fin = true;
        cout << x << endl;
      }
    }
    if (fin) return 0;
    
    int f, l;
    f = x; 
    l = x;
    rep(i, 100) {
      f--;
      l++;
      
      rep(i, n) {
        if (p[i] == f) break;
        if (i == n - 1) {
          fin = true;
          cout << f << endl;
        }
      }
      if (fin) return 0;
      
      rep(i, n) {
        if (p[i] == l) break;
        if (i == n - 1) {
          fin = true;
          cout << l << endl;
        }
      }
      if (fin) return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#define N 100
int main(){
  int n,i,j,mini,count=0,l,A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<=n-1;i++){
    mini=i;
    for(j=i;j<=n-1;j++){
      if(A[j]<A[mini]){
        mini=j;
      }
    }
      if(i != mini){
        count++;
        l=A[i];
        A[i]=A[mini];
        A[mini]=l;
      }
    }

    for(i=0;i<n-1;i++){
      printf("%d ",A[i]);

        }
    printf("%d",A[n-1]);
    printf("\n");
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define sort(x) sort(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int a[100005], n, m;

int main(){
	int i, j;
	for(i=1;i<=5;i++){
		cin >> a[i];
		if(a[i] != i)j = i;
	}
	cout << j;
}


Measured memory_bytes: 3592
n = int(input())
s = input()
acc_cnt_a = [0] * (n + 1)
acc_cnt_b = [0] * (n + 1)
acc_cnt_ab = [0] * (n + 1)
c_loc = []
cnt_a = 0
cnt_b = 0
cnt_ab = 0
for i, c in enumerate(s):
    if c == 'D':
        cnt_a += 1
    elif c == 'M':
        cnt_b += 1
        cnt_ab += cnt_a
    elif c == 'C':
        c_loc.append(i + 1)
    acc_cnt_a[i + 1] = cnt_a
    acc_cnt_b[i + 1] = cnt_b
    acc_cnt_ab[i + 1] = cnt_ab

q = int(input())
buf = []
for k in map(int, input().split()):
    ans = 0
    for r in c_loc:
        l = r - k
        if l > 0:
            rejected_a = acc_cnt_a[l]
            cnt_internal_b = acc_cnt_b[r] - acc_cnt_b[l]
            cnt_internal_ab = acc_cnt_ab[r] - acc_cnt_ab[l]
            ans += cnt_internal_ab - rejected_a * cnt_internal_b
        else:
            ans += acc_cnt_ab[r]
    buf.append(ans)
print('\n'.join(map(str, buf)))


Measured memory_bytes: 107252
import java.util.Scanner;

public class Main {

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

	private static void studyCheck() {
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()) {
			int t = sc.nextInt();
				if (t == 0) {
					break;
				}
			int n = sc.nextInt();

				for (int i = 0; i < n; i++) {
					int s = sc.nextInt(); int f = sc.nextInt();
					t -= f - s;
				}

				if (t <= 0) {
					System.out.println("OK");
				} else {
					System.out.println(t);
				}
		}

		sc.close();
	}

}


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

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

class Point
{
public:
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a * x, a * y); }
	Point operator / (double b) { return Point(x / b, y / b); }

	double dot(Point a, Point b) { return a.x* b.x + a.y * b.y; }
	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }

	bool operator <(const Point & p)const { return x != p.x ? x < p.x : y < p.y; }
	bool operator == (const Point & p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; }
};
typedef Point Vector;

struct Segment {
	Point p1, p2;
	Segment() {}
	Segment(Point p1, Point p2) :p1(p1), p2(p2) {}
};
typedef Segment Line;

double norm(Vector a) { return a.x* a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a)); }

double dot(Vector a, Vector b) { return a.x* b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x* b.y - a.y * b.x; }

int ccw(Point p0, Point p1, Point p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS) return CLOCKWISE;
	if (dot(a, b) < -EPS) return ONLINE_BACK;
	if (a.norm() < b.norm()) return ONLINE_FRONT;
	return ON_SEGMENT;

}
bool intersect(Point p1, Point p2, Point p3, Point p4)
{    
	return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
		ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);        
}                                                                                     
bool intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); }



double getDistanceLP(Line l, Point p) {
	return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));
}

double getDistanceSP(Segment s, Point p) {
	if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1);
	if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2);
	return getDistanceLP(s, p);
}

double getDistance(Segment s1, Segment s2) {
	if (intersect(s1, s2)) return 0.0;
	return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)),
		min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)));
}

int main()
{
	int q;
	cin >> q;
	double x0, y0, x1, y1, x2, y2, x3, y3;
	while (q--)
	{
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		Segment s1 = Segment(Point(x0, y0), Point(x1, y1)), s2 = Segment(Point(x2, y2), Point(x3, y3));
		printf("%.8lf\n",getDistance(s1,s2));
	}
	return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define LL long long
#define MAXN 1000005
using namespace std;

int n, q, k;
LL cnt[MAXN][4];
char s[MAXN];

void init()
{
	for(int i=1; i<=n; i++)
	{
		cnt[i][1]+=cnt[i-1][1];
		cnt[i][2]+=cnt[i-1][2];
		cnt[i][3]+=cnt[i-1][3];
		if(s[i]=='M') cnt[i][2]++;
		if(s[i]=='C') cnt[i][3]++, cnt[i][1]+=cnt[i][2];
	}
}

int main()
{
	scanf("%d", &n);
	scanf("%s", s+1);
	init();
	scanf("%d", &q);
	for(int i=1; i<=q; i++)
	{
		LL ans=0;
		scanf("%d", &k);
		for(int j=1; j<=n; j++)
			if(s[j]=='D')
			{
				ans+=cnt[min(n, j+k-1)][1]-cnt[j-1][1]-cnt[j-1][2]*(cnt[min(n, j+k-1)][3]-cnt[j-1][3]);
			}
		printf("%lld\n", ans);
	}	
} 

Measured memory_bytes: 32512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;


int main(){
	int N,K;
	cin>>N>>K;
	int ans=K;
	rep1(i,N-1)ans*=(K-1);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int p;
ll c[3030][3030],a[3030];

int read()
{
    int 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;
}

void calc(int x,int pos)
{
	a[0]=(a[0]+1)%maxd;
	ll now=-1;
	rep(i,0,p-1)
	{
		a[p-1-i]=(a[p-1-i]+now*c[p-1][i])%p;
		now=now*(-pos)%p;
	}
}

int main()
{
	p=read();
	rep(i,0,p)
	{
		c[i][0]=1;
		rep(j,1,i) c[i][j]=(c[i-1][j-1]+c[i-1][j])%p;
	}
	rep(i,0,p-1)
	{
		int a=read();
		if (a) calc(a,i);
	}
	rep(i,0,p-1)
	{
		a[i]=(a[i]+p)%p;
		printf("%lld ",a[i]);
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int count = 0;
  bool flag1 = false, flag2 = false;
  if(s[0] == 'A') flag1 = true;
  for(int i = 2; i < s.size()-1; i++){
    if(s[i] == 'C') flag2 = true;
  }
  if(flag1 == false || flag2 == false){
    cout << "WA" << endl;
    return 0;
  }
  for(int i = 1; i < s.size(); i++){
    if(s[i] == 'C') count++;
    if(s[i] != 'C'){
      if(s[i] <= 'Z'){
      cout << "WA" << endl;
      return 0;
      }
    }
  }
  if(count != 1){
    cout << "WA" << endl;
    return 0;
  }else{
    cout << "AC" << endl;
    return 0;
  }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{

    double x1, y1, x2, y2, x3, y3;
    double midx1, midx2, midy1, midy2;
    double circlex, circley;
    double slant1, slant2;
    double slice1, slice2;
    double radius;
    int i;
    int input;
    
    scanf("%d", &input);
    for (i = 0; i < input; i++) {
        scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
        midx1 = (x1 + x2) / 2;
        midy1 = (y1 + y2) / 2;
        midx2 = (x1 + x3) / 2;
        midy2 = (y1 + y3) / 2;
        slant1 = - (x2 - x1) / (y2 - y1);
        slant2 = - (x3 - x1) / (y3 - y1);
        slice1 = midy1 - slant1 * midx1;
        slice2 = midy2 - slant2 * midx2;
        circlex = (slice2 - slice1) / (slant1 - slant2);
        circley = slant1 * circlex + slice1;
        
        if (x2 == x1) {
            circley = midy1;
            circlex = (circley - slice2) / slant2;
        }
        else if (y2 == y1) {
            circlex = midx1;
            circley = slant2 * circlex + slice2;
        }
        if(x3 == x1) {
            circley = midy2;
            circlex = (circley - slice1) / slant1;
        }
        else if (y3 == y1) {
            circlex = midx2;
            circley = slant1 * circlex + slice1;
        }
        if (x2 == x1 && y3 == y1) {
            circley = midy1;
            circlex = midx2;
        }
        else if (x3 == x1 && y2 == y1){
            circley = midy2;
            circlex = midx1;
        }
        radius = sqrt((circlex - x1) * (circlex - x1) + (circley - y1) * (circley - y1));
        printf("%0.3f %0.3f %0.3f\n", circlex, circley, radius);
    }
    return 0;
}

Measured memory_bytes: 664
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
int n,m,sum;
const int N=1<<18|5,mod=998244353;
LL ksm(LL a,LL b,LL mod)
{
	LL res=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)res=res*a%mod;
	return res;
}
struct DXS
{
	int v[N];
	void FWT(int lim,int opt)
	{
		int a,b;
		for(int mid=1,len=2;len<=lim;mid<<=1,len<<=1)
			for(int i=0;i<lim;i+=len)
				for(int j=i;j<i+mid;++j)
					a=v[j],b=v[j+mid],v[j]=(LL)(a+b)*opt%mod,v[j+mid]=(LL)(a-b)*opt%mod;
	}
}E,P,S;
int main()
{
	cin>>m;n=1<<m;
	for(int i=0;i<n;++i)scanf("%d",&P.v[i]),sum+=P.v[i];
	sum=ksm(sum,mod-2,mod);
	for(int i=0;i<n;++i)P.v[i]=(LL)P.v[i]*sum%mod;
	--P.v[0];if(P.v[0]<0)P.v[0]+=mod;
	S.v[0]=n-1;
	for(int i=1;i<n;++i)S.v[i]=mod-1;
	P.FWT(n,1);S.FWT(n,1);
	for(int i=1;i<n;++i)E.v[i]=(LL)S.v[i]*ksm(P.v[i],mod-2,mod)%mod;
	E.FWT(n,(mod+1)/2);
	
	for(int i=0,x=E.v[0];i<n;++i)printf("%d\n",((E.v[i]-x)%mod+mod)%mod);
	return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <vector <ll>> matrix;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const ll INF = 1e18;
const int N = 10005;

int n, w[N], s[N], v[N];
ll dp[N];

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

    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> w[i] >> s[i] >> v[i];

    vector <int> p(n);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int a, int b) {
        return min(s[a] - w[b], s[b]) > min(s[b] - w[a], s[a]);
    });

    fill(dp, dp + N, -INF);

    for (auto it : p) {
        for (int i = w[it]; i < N; i++)
            umax(dp[min(s[it], i - w[it])], dp[i] + v[it]);

        umax(dp[s[it]], v[it]);
    }

    cout << *max_element(dp, dp + N) << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,k;
	cin >> k >> n;
	if(!(k%2)) {
		cout << k/2;
		for(int i=1;i<n;i++) {
			cout << " " << k;
		}
		cout << '\n';
		return 0;
	}
	vi res;
	for(int i=0;i<n;i++) {
		res.push_back((k+1)/2);
	}
	for(int i=0;i<(n/2);i++) {
		if(res.back() == 1) {
			res.pop_back();
		} else {
			res.back()--;
			while(res.size() < n) {
				res.push_back(k);
			}
		}
	}
	for(int i=0;i<res.size();i++) {
		if(i > 0) {cout << " ";}
		cout << res[i];
	}
	cout << '\n';
}

Measured memory_bytes: 3568