akhauriyash/Code-Regression huggingface dataset:
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
    ll C[n + 1][k + 1]; 
    ll i, j; 


    for (i = 0; i <= n; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            
            if (j == 0 || j == i) 
                C[i][j] = 1; 

            else
                C[i][j] = (C[i - 1][j - 1] + 
                                        C[i - 1][j])%MOD; 
        } 
    } 

    return C[n][k]; 
}
bool compare(const pair<int,ll> &a , const pair<int,ll>&b){
    //set<pair<int,int> , decltype(&compare)>s(&compare) ;
    return a.se<b.se ;
}

// struct compare{
//     // for priority_queue
//     bool operator()(const int &a , const int&b){
//         return a<b ;
//     }
// };

void solve()
{
    int n ; 
    cin>>n ;
    string s; 
    cin>>s ;
    bool ok = 0 ;
    if(n%2==0){
        int tn = n/2 ;
        ok = 1 ;
        rep(i , tn){
            ok &= (s[i]==s[i+tn]) ;
        }
    }
    if(ok){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";   
    }
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3832
/* Date: 1/03/2020
 * Author: @codingoo
 * Problem Name: YYMM OR MMYY
 * Platform: AtCoder
 */
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int s;
    cin >> s;
    int m = s/100;
    int y = s%100;
    if (1 <= m && m <= 12) {
        if (1 <= y && y <= 12)
            cout << "AMBIGUOUS" << "\n";
        else
            cout << "MMYY" << "\n";
    }
    else {
        if (1 <= y && y <= 12)
            cout << "YYMM" << "\n";
        else
            cout << "NA" << "\n";
    }
    return 0;
}



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

using namespace std;
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  string s;
  cin >> s;
  
  vector<vector<int>> deta(26);

  rep(i, s.length()){
    deta[s[i]-'a'].push_back(i+1);
  }

  int l, r;
  l = -1;
  r = -1;
  rep(i, 26){
    
    for(int j = 0; j + 1 < deta[i].size(); j++){
      if(deta[i][j+1] - deta[i][j] < 3){
        l = deta[i][j];
        r = deta[i][j+1];
        break;
      }
    }
  }

  cout << l << " " << r << endl;

  return 0;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a;string s; cin >> a >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
const int INF = 1e6;
int main(void){
  int n;
  int cost[10][10];
  while(cin>>n){
    if(n==0) break;
    REP(i,10)REP(j,10) cost[i][j] = INF;
    REP(i,n){
      int a,b,c;
      cin>>a>>b>>c;
      cost[a][b] = cost[b][a] = c;
    }
    REP(k,10)REP(i,10)REP(j,10)cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]);
    int ans = INF;
    int ansi;
    REP(i,10){
      int tmp=0;
      REP(j,10)tmp+=(cost[i][j]!=INF&&i!=j)?cost[i][j]:0;
      if(tmp!=0&&ans>tmp){
        ans = tmp;
        ansi = i;
      }
    }
    cout<<ansi<<" "<<ans<<endl;
  }

  return 0;
}

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

int main(void) {
  //input
  int64_t N;
  cin >> N;
  //calc
  int64_t answer = -1;
  int64_t M = (int64_t)sqrt(N);
  for(int64_t j = M; j >=1; j--) {
    if ( N % j != 0 ) {
      continue;
    }
    int64_t i = N / j;
    answer = (i-1) + (j-1);
    break;
  }

  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A,B=[0],[0]
for i in range(n):
    A.append(A[i]+a[i])
for i in range(m):
    B.append(B[i]+b[i])
ans,j=0,m
for i in range(n+1):
    if A[i]>k:
        break
    while B[j]>k-A[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)        


Measured memory_bytes: 47472
#include <iostream>
using namespace std;
int f(int n){
    if(n ==1)return 1;
    if(n ==2)return 2;
    if(n ==3)return 4;
    return f(n-1)+f(n-2)+f(n-3);
}
int main(void){
    while( true){
        int n;
        cin>>n;
        if(n==0)break;
 
    // Your code here!

        cout << (f(n) /3650 )+1 << endl; 
  }
}


Measured memory_bytes: 3032
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
//#include <ext/numeric>
//using namespace __gnu_cxx;


using namespace std;


// #define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    string s;
    cin>>s;

    int start = 0;

    int end = n - 1;


    while(start < end){


        if(s[start] > s[end]){

            swap(s[start]  ,s[end]);
            count++;
            start++, end--;
        }

        else if(s[start] == 'R'){

            start++;
        }

        else{

            end--;
        }
    }

    cout<<count<<endl;


}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3732
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 3e5+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}

vl a;
void solve(){
	ll n,x,b,ans;
	cin >> n >> x;
	rep(i,0,n){
		cin >> b;
		a.pb(abs(x-b));
	}
	ans=a[0];
	rep(i,0,n){
		ans=__gcd(ans,a[i]);
	}
	cout << ans;
}

int main() {
	isc;
	solve();
	return 0;
}


Measured memory_bytes: 1400
N = int(input())
A = []
m1 = 0
m2 = 0
for i in range(N):
  a = int(input())
  if m1<=a:
    m2 = m1
    m1 = a
  elif m2<=a:
    m2 = a
  A += [a]
for a in A:
  if a == m1:
    print(m2)
  else:
    print(m1)

Measured memory_bytes: 12532
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <stack>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a))

using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const double E=exp(1.0);
const double eps=1e-9;
const int mod=1e7;
const int M=1e6;

struct node{
	int nxt,dis;
};
vector <node> vec[M];
ll d[M];

void dfs(int x,int y) {
	for(int i=0;i<vec[x].size();i++) {
		node t=vec[x][i];
		if(t.nxt!=y) {
			d[t.nxt]=d[x]+t.dis;
			dfs(t.nxt,x);
		}
	}
}

int main() {
	int n,i,k,m;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		node temp;
		temp.nxt=b,temp.dis=c;
		vec[a].push_back(temp);
		temp.nxt=a,temp.dis=c;
		vec[b].push_back(temp);
	}
	scanf("%d%d",&m,&k);
	dfs(k,k);
	while(m--){
		int a,b;
		scanf("%d %d",&a,&b);
		printf("%lld\n",d[a]+d[b]);
	}
		
}

Measured memory_bytes: 37120
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

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

long lcm(long a, long b) {
  long g = gcd(a, b);
  return a*b/g;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  long a[n];
  scanf("%ld", a);
  long b = a[0], l = b/2;
  int cnt = 0;
  while (b%2 == 0) {
    cnt++;
    b /= 2;
  }
  for (int i=1; i<n; i++) {
    scanf("%ld", a+i);
    int cnti = 0;
    b = a[i];
    while (b%2 == 0) {
      cnti++;
      b /= 2;
    }
    if (cnt != cnti) {
      printf("0\n");
      return 0;
    }
    l = lcm(a[i]/2, l);
  }
  printf("%ld\n", m/l-m/(2*l));
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n; cin>>n;
  vector<tuple<string,int,int>>vec;
  for(int i=0;i<n;i++){
    string s; int p;
    cin>>s>>p;
    vec.push_back(make_tuple(s,-p,i+1));
  }
  sort(vec.begin(),vec.end());
  for(tuple<string,int,int> ans : vec){
    int y,z; string x;
    tie(x,y,z)=ans;
    cout<<z<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

const long long mod = 1000000007;
long long power[1 << 18];

void init() {
	power[0] = 1;
	for (int i = 1; i < 250000; i++) power[i] = (2LL * power[i - 1]) % mod;
}

int N, A[1 << 18], B[1 << 18], dp[1 << 18];
vector<int> X[1 << 18];

void dfs(int pos) {
	dp[pos] = 1;
	for (int i = 0; i < X[pos].size(); i++) {
		if (dp[X[pos][i]] >= 1) continue;
		dfs(X[pos][i]);
		dp[pos] += dp[X[pos][i]];
	}
}

int main() {
	cin >> N; init();
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	dfs(1);

	long long sum = 0;
	for (int i = 1; i <= N; i++) {
		vector<int> V; int rem = N - 1;
		for (int j = 0; j < X[i].size(); j++) {
			if (dp[X[i][j]] >= dp[i]) continue;
			V.push_back(dp[X[i][j]]);
			rem -= dp[X[i][j]];
		}
		if (rem >= 1) V.push_back(rem);

		long long prob = 1;
		for (int j = 0; j < V.size(); j++) {
			long long prob1 = Div(1, power[N - 1 - V[j]], mod);
			long long prob2 = (mod + 1LL - Div(1, power[V[j]], mod)) % mod;
			prob -= (prob1 * prob2 % mod);
			prob = (prob + mod) % mod;
		}
		prob -= Div(1, power[N - 1], mod);
		prob = (prob + mod) % mod;

		prob = Div(prob, 2, mod);
		sum += prob; sum %= mod;
	}
	cout << sum << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,q,x,y,c,d,depth[100010],num[100010],sum[100010],ans[100010];
int par[20][100010];
vector <int> g[100010];
vector <pair <pii,int> > g2[100010];
vector <pair <pii,pii> > v[100010];

void dfs(int pos,int no,int d)
{
	depth[pos]=d;
	par[0][pos]=no;
	rep(i,g[pos].size()) if(g[pos][i]!=no) dfs(g[pos][i],pos,d+1);
}

int lca(int pos1,int pos2)
{
	if(depth[pos1]<depth[pos2]) swap(pos1,pos2);
	for(int i=18;i>=0;i--) if(depth[pos1]-(int)pow(2,i)>=depth[pos2]) pos1=par[i][pos1];
	for(int i=18;i>=0;i--)
	{
		if(par[i][pos1]!=par[i][pos2])
		{
			pos1=par[i][pos1];
			pos2=par[i][pos2];
		}
	}
	if(pos1==pos2) return pos1;
	return par[0][pos1];
}

void dfs2(int pos,int no,int d)
{
	rep(i,v[pos].size())
	{
		if(v[pos][i].fi.se==1) ans[v[pos][i].fi.fi]+=d-sum[v[pos][i].se.fi]+num[v[pos][i].se.fi]*v[pos][i].se.se;
		else ans[v[pos][i].fi.fi]-=(d-sum[v[pos][i].se.fi]+num[v[pos][i].se.fi]*v[pos][i].se.se)*2;
	}
	rep(i,g2[pos].size())
	{
		if(g2[pos][i].fi.fi==no) continue;
		num[g2[pos][i].fi.se]++;
		sum[g2[pos][i].fi.se]+=g2[pos][i].se;
		dfs2(g2[pos][i].fi.fi,pos,d+g2[pos][i].se);
		num[g2[pos][i].fi.se]--;
		sum[g2[pos][i].fi.se]-=g2[pos][i].se;
	}
}

int main()
{
	cin>>n>>q;
	rep(i,n-1)
	{
		scanf("%d%d%d%d",&x,&y,&c,&d);
		g[x].pb(y);
		g[y].pb(x);
		g2[x].pb(mpr(mpr(y,c),d));
		g2[y].pb(mpr(mpr(x,c),d));
	}
	rep(i,20) rep(j,100005) par[i][j]=-1;
	dfs(1,-1,0);
	rep(i,18)
	{
		repn(j,n)
		{
			if(par[i][j]==-1) continue;
			par[i+1][j]=par[i][par[i][j]];
		}
	}
	rep(qn,q)
	{
		scanf("%d%d%d%d",&c,&d,&x,&y);
		int z=lca(x,y);
		v[x].pb(mpr(mpr(qn,1),mpr(c,d)));
		v[y].pb(mpr(mpr(qn,1),mpr(c,d)));
		v[z].pb(mpr(mpr(qn,-1),mpr(c,d)));
	}
	dfs2(1,0,0);
	rep(i,q) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 36340
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
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;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<int> ans;
    REP(i, 3) {
        int tmp;
        cin >> tmp;
        ans.insert(tmp);
    }
    print(ans.size());
    return 0;
}


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



int main (){

    int a;
    cin >> a ;

    if(a==0){
        cout << 0 << endl;
    }
    else if (a==1){
        cout << 1 << endl;
    }
    else if (a==100){
        cout << 1 << endl;
    }
    else if (a==10){
        cout << 1 << endl;
    }
    else if (a==101){
        cout << 2 << endl;
    }
    else if (a==110){
        cout << 2 << endl;
    }
    else if (a==11){
        cout << 2 << endl;
    }
    else if (a==111){
        cout << 3<< endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=2010;
int n,a[N],d[N],e[N][N];bool vis[N];
void dfs(int x){
    vis[x]=1;
    rep(y,1,n) if(__gcd(a[x],a[y])!=1&&!vis[y]) d[y]=1,e[x][y]=1,dfs(y); 
}
void topsort(){
    priority_queue<int> q;
    rep(i,1,n) if(!d[i]) q.push(i);
    while(!q.empty()){
        int x=q.top();q.pop();printf("%d ",a[x]);
        rep(y,1,n) if(e[x][y]) q.push(y);
    }
}
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",a+i);sort(a+1,a+n+1);
    rep(i,1,n) if(!vis[i]) dfs(i);
    topsort();
    return 0;
}

Measured memory_bytes: 14592
#A
"""
H, W = map(int, input().split())
h, w = map(int, input().split())
print(H*W-h*W-w*H+h*w)
"""
#B
"""
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
ansb = 0
for i in range(n):
    ans = 0
    a = list(map(int, input().split()))
    for k in range(m):
        ans += a[k]*b[k]
    ans += c
    if ans > 0:
        ansb += 1
print(ansb)
"""
#C
"""
n, m = map(int, input().split())
ans = []
ansnum = 0
honsuu = 0
for i in range(n):
    a = list(map(int, input().split()))
    ans.append(a)
ans.sort()
for i in ans:
    if honsuu + i[1] <= m:
        ansnum += i[0] * i[1]
        honsuu += i[1]
    else:
        ansnum += (m - honsuu) * i[0]
        break

print(ansnum)
"""
# D
# 解説AC
# わかるかぼけ
# F(a,b) = F(0,a-1)^F(0,B)
a, b = map(int, input().split())
def F(x):
    tmp1, tmp2 = (x+1) >> 1, x & 1
    rast = 0 if tmp2 else x
    fast = tmp1 & 1
    return rast ^ fast
print(F(a - 1) ^ F(b))

Measured memory_bytes: 38384
#include<iostream>

using namespace std;

int main()
{
    int n,m;
    cin >> n>> m;
    int ara[m],i,total=0;
    for(i=0;i<m;i++){
        cin >> ara[i];
        total+=ara[i];
    }
    if(total>n){
        cout << "-1"<< endl;
    }
    else{
        cout << n - total << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? ((x) : -(x)))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
string str;
int main()
{
	int i, j;
	cin >> M >> str;
	N = str.size();
	for (i = 0; i < N; ++i) {
		int num = str[i] - 'A';
		num = (num + M) % 26;
		str[i] = 'A' + num;
	}
	cout << str;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main() {
    unsigned long long  mon, special_moves , attacks=0 ;
cin >> mon >> special_moves ;
int monh[mon];
for(int i =0 ; i<mon ; i++){
    cin >> monh[i];
}
sort(monh , monh+mon);
if (special_moves>mon){
        
    }
else if (special_moves>=0){
    if (special_moves==0){
        for(int i=0 ; i<mon ; i++){
            attacks+=monh[i];
        }
    }
    else {
        for(int i=0 ; i<mon-special_moves ; i++ ){
            attacks+=monh[i];
        }
    }
}
cout  << attacks << endl ;
    return 0 ;
}


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

#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 debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;



lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;

bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> a >> b;

    if((a-b)%2==0)
    {
        cout << abs(a-b)/2 + min(a,b) << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    //cout << ( ? abs(a-b)/2 : "IMPOSSIBLE" ) << endl;


    //cout <<  0    << endl;


//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int a , b , c ;

int main() {

   cin >> a >> b >> c ;
   int rem = c % b ;

   forn( int , i , 1 , 20000 ){
       if( ( b * i - rem ) % a == 0 ){
        cout << "YES\n" ;
        return 0 ;
       }
   }

   cout << "NO\n" ;

   cerr << "\n\n" << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
   return 0 ;
}


Measured memory_bytes: 256
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2019
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;

int A[13][13];
int C[13];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    for(int i = 0; i < n; ++i) {
        cin >> C[i];
        for(int j = 0; j < m; ++j) {
            cin >> A[i][j];
        }
    }
    int best = INF;
    for(int mask = 0; mask < (1 << n); ++mask) {
        vector<int> gains(m, 0);
        int cur = 0;
        for(int i = 0; i < n; ++i) {
            if(mask & (1 << i)) {
                cur += C[i];
                for(int j = 0; j < m; ++j) {
                    gains[j] += A[i][j];
                }
            }
        }
        if(all_of(gains.begin(), gains.end(), [&](int a) {return a >= x;})) {
            best = min(best, cur);
        }
    }
    cout << (best == INF ? -1 : best) << endl;
    return 0;
    
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100005],b[100005];
priority_queue<ll>pq;
ll sum_minus=0,sum_plus=0;
int ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	cin >>a[i];
	for(int i=1;i<=n;i++)
	cin >>b[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]<b[i])
		{
			sum_minus+=b[i]-a[i];
			ans++;
		}
		else if(a[i]>b[i])
		{
			sum_plus+=a[i]-b[i];
			pq.push(a[i]-b[i]);
		}
	}
	if(sum_minus>sum_plus)
	{
		puts("-1");
		return 0;
	}
	if(sum_minus==0)
	{
		puts("0");
		return 0;
	}
	while(!pq.empty())
	{
		ll x=pq.top();
		pq.pop();
		sum_minus-=x;
		ans++;
		if(sum_minus<=0)
		{
			cout <<ans<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 2428
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using BI = System.Numerics.BigInteger;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		BI ans = (A - B) * (K % 2 == 0 ? 1 : -1);
		Console.WriteLine((ans <= (BI) 1e18 && ans >= - (BI) 1e18) ? ans.ToString() : "Unfair");
		
	}
	BI A,B,C,K;
	public Sol(){
		var d = rla();
		A = d[0]; B = d[1]; C = d[2]; K = d[3];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1e9 + 7;
using namespace std;
int v[10001] = {};

int main()
{
    IOS
    int n,o = 0,cnt = 0;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> v[i];
        while(v[i]%2 == 0)
        {
            v[i]/=2;
            ++cnt;
        }
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

template<typename T>
class SegTree {
public:
    explicit SegTree(int n, T def) : N(calcN_(n)), def(def), mVal(2*calcN_(n)-1, def) {}
    void update(int idx, T value){
        int i = N + idx - 1;
        update_(mVal[i], value);
        while(i > 0){
            i = (i-1)/2;
            mVal[i] = operate(mVal[2*i+1], mVal[2*i+2]);
        }
    }
    T get(int l, int r){
        return getImpl_(l, r, 0, 0, N);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    T getImpl_(int l, int r, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return def;
        if(l <= rangeL && rangeR <= r) return mVal[idx];
        int rangeM = (rangeL+rangeR)/2;
        T a = getImpl_(l, r, 2*idx+1, rangeL, rangeM);
        T b = getImpl_(l, r, 2*idx+2, rangeM, rangeR);
        return operate(a, b);
    }
    T update_(T& data, T val) { data = max(data, val); }
    T operate(T a, T b) { return max(a, b); }
    const int N;
    const T def;
    vector<T> mVal; 
};

int main(){
    int N;
    while(cin >> N){
        vector<long long> X(N), L(N);
        vector<long long> lset;
        vector<pair<long long, long long>> vp;
        for(int i=0;i<N;i++){
            cin >> X[i] >> L[i];
            lset.push_back(X[i]-L[i]);
            lset.push_back(X[i]+L[i]);
            vp.emplace_back(X[i]+L[i], X[i]-L[i]);
        }
        sort(lset.begin(), lset.end());
        lset.erase(unique(lset.begin(), lset.end()), lset.end());
        map<long long, int> dict;
        for(int i=0;i<lset.size();i++){
            dict[lset[i]] = i;
        }
        sort(vp.begin(), vp.end());
        SegTree<int> seg(lset.size()+1, 0);
        for(auto& p : vp){
            int idx = dict[p.second];
            int v = seg.get(0, idx+1);
            seg.update(dict[p.first], v+1);
        }
        cout << seg.get(0, lset.size()+2) << endl;
    }
}


Measured memory_bytes: 19556
#include "vector"
#include "set"
#include "map"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 998244353

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& j: v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os <<j;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

vector<vi> g;
vi p;
vi h;
void dfs(int x, int prev) {
    p[x] = prev;
    h[x] = (prev == -1) ? 0 : h[prev] + 1;

    for (int y : g[x]) {
        if (y != prev) {
            dfs(y, x);
        }
    }
}

struct v {
    int a;
    int b;
    int c;
};

bool comp(const v& x, const v& y) {
    return x.c < y.c;
}

void solve() {
    int n;
    cin >> n;

    ll ans = 0;
    for (int i=1; i<=n; i++) {
        if (i % 3 && i % 5) {
            ans += i;
        }
    }

    cout << ans;
}

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

    if (0) {
        int tests;
        cin >> tests;
        while (tests--) {
            solve();
            cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
import sys
from collections import deque, defaultdict
import copy
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

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


numnum=defaultdict(int)
for i in range(N):
    numnum[a[i]]+=1

if len(numnum) > 3:
    print("No")
    exit()


if len(numnum) == 1:
    for num in numnum:
        if num == 0:
            print("Yes")
        else:
            print("No")
        exit()


for num in numnum:
    if numnum[num] % (N//3) != 0:
        print("No")
        exit()

num3=[]
for num in numnum:
    num3.append(num)

if len(num3) == 2:

    if 0 in num3 and numnum[0] == N//3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()


if num3[0]^num3[1] == num3[2]:
    print("Yes")
    exit()
else:
    print("No")
    exit()


Measured memory_bytes: 57200
import sys

# S = input()
# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    N = input()

    ans = 'No'
    for s in N:
        if int(s) == 7:
            ans = "Yes"

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
n = int(input())
xy = []
for i in range(n):
    a = int(input())
    xy.append([tuple(map(int, input().split())) for _ in range(a)])

# 正直者=1, 嘘つき=0 とする
ans = []
for i in range(1<<n):
    s = ''.join(str(bin(i)).replace('0b', '')).zfill(n)
    for j in range(n):
        if s[j] == '1':
            for word in xy[j]:
                if int(s[word[0]-1]) != word[1]:
                    break
            else:
                continue
            break
    else:
        ans.append(s)
        continue

cnt = 0
for x in ans:
    k = x.count('1')
    if cnt < k:
        cnt = k
print(cnt)

Measured memory_bytes: 45404
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<int> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

	if(A[0] > 0){
		cout << -1 << endl;
		return 0;
	}
	for(int i=0; i<N-1; i++){
		if(A[i]>i || A[i+1]>A[i]+1){
			cout << -1 << endl;
			return 0;
		}
	}

	long long ret = 0;
	for(int i=0; i<N-1; i++){
		if(A[i+1] == A[i]+1)
			ret++;
		else
			ret += A[i+1];
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  int p;
  char s[5];
  bool ac[100010];
  int cntwa[100010];
  int i;
  for(i=0;i<N;i++) {
    ac[i] = false;
    cntwa[i] = 0;
  }
  int cntac = 0;
  for(i=0;i<M;i++) {
    cin >> p >> s;
    if(s[0] == 'A') {
      if(!ac[p-1])cntac++;
      ac[p-1] = true;
    }
    else if(!ac[p-1])cntwa[p-1]++;
  }
  int ans = 0;
  for(i=0;i<N;i++) {
    if(ac[i])ans += cntwa[i];
  }
  cout << cntac << " " << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;

vector<bool> b_sta(1e5+10,false);

ll gcd(ll m, ll n){
  return n ? gcd(n,m%n) : m;
}

ll lcm(ll m,ll n){
  return m / gcd(m,n) * n;
}
int main(){
  ll w,h,x,y;
  cin >> w >> h >> x >> y;

printf("%.10lf",double(w) *  double(h) / 2);
 //中点なら切り方がたくさんある
 cout  << " "<<((x+x==w) && (y+y==h) ? 1 : 0) << endl; 
 
}

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

typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
    vector<int> train[501];

int main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    for(int i=0;i<M;i++){
        int L,R;
        cin >> L >> R;
        train[L].push_back(R-L);
    }
    for(int i=1;i<=N;i++){
        sort(train[i].begin(),train[i].end());
    }
    for(int i=0;i<Q;i++){
        int p,q;
        cin >> p >> q;
        int ans=0;
        for(int c=p;c<=q;c++){
            if(train[c].size()==0) continue;
            ans+=distance(train[c].begin(),upper_bound(train[c].begin(),train[c].end(),q-c));
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
// ARC085E.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 330, INF = 0x3f3f3f3f;

typedef long long ll;

int n, ai[MAX_N], head[MAX_N], current, cur[MAX_N], dep[MAX_N], start_pos, end_pos;

struct edge
{
    int to, nxt, weight;
} edges[MAX_N * MAX_N << 5];

void addpath(int src, int dst, int weight)
{
    edges[current].to = dst, edges[current].nxt = head[src];
    edges[current].weight = weight, head[src] = current++;
}

void addtube(int src, int dst, int weight)
{
    addpath(src, dst, weight), addpath(dst, src, 0);
}

bool bfs()
{
    memset(dep, 0, sizeof(dep));
    queue<int> q;
    q.push(start_pos), dep[start_pos] = 1;
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int i = head[u]; i != -1; i = edges[i].nxt)
            if (edges[i].weight > 0 && dep[edges[i].to] == 0)
                dep[edges[i].to] = dep[u] + 1, q.push(edges[i].to);
    }
    return dep[end_pos] != 0;
}

int dfs(int u, int flow)
{
    if (u == end_pos || flow == 0)
        return flow;
    for (int i = head[u]; i != -1; i = edges[i].nxt)
        if (edges[i].weight > 0 && dep[edges[i].to] == dep[u] + 1)
            if (int di = dfs(edges[i].to, min(flow, edges[i].weight)))
            {
                edges[i].weight -= di, edges[i ^ 1].weight += di;
                return di;
            }
    return 0;
}

ll dinic()
{
    ll ret = 0;
    while (bfs())
        while (int di = dfs(start_pos, INF))
            ret += di;
    return ret;
}

int main()
{
    memset(head, -1, sizeof(head));
    scanf("%d", &n);
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &ai[i]);
        if (ai[i] > 0)
            ans += ai[i];
    }
    start_pos = (n << 1) | 1, end_pos = start_pos + 1;
    for (int i = 1; i <= n; i++)
        if (ai[i] < 0)
            addtube(start_pos, i, -ai[i]);
        else
            addtube(i, end_pos, ai[i]);
    for (int i = 1; i <= n; i++)
        for (int j = (i << 1); j <= n; j += i)
            addtube(i, j, INF);
    printf("%lld\n", ans - dinic());
    return 0;
}

Measured memory_bytes: 3748
class House
        def initialize(f,r)     #floor,room number
                @f = Array.new(f){Array.new(r,0)}
        end

        def move(f,r,v)
                @f[f-1][r-1] += v
        end

        def residents
                str=''
                @f.each{|f|
                        str+=' '
                        f.each{|r|
                                str += r.to_s+' '
                        }
str.chop!
                        str+="\n"
                }
                print str
        end
end

houses = []
4.times{houses << House.new(3,10)}      #4 building

n = gets.to_i
ps = []

n.times{|i|
        ps << gets.split(' ').map(&:to_i)
}

ps.each{|p|
        b=p[0] ; f=p[1] ; r = p[2] ; v = p[3]
        houses[b-1].move(f,r,v)
}

c=0
houses.each{|house|
        print house.residents
        c+=1
        puts "#"*20 unless c==houses.size
}

Measured memory_bytes: 8772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[3010][3010][4];

int main(){
	int R, C, K; scanf("%d %d %d", &R, &C, &K);
	vector<vector<ll> > field(R + 1, vector<ll> (C + 1, 0));
	for(int i = 0; i < K; i++){
		int a, b; ll c; scanf("%d %d %lld", &a, &b, &c);
		field[a][b] = c;
	}
	if(field[1][1]) dp[1][1][1] = field[1][1];
	for(int i = 1; i <= R; i++){
		for(int j = 1; j <= C; j++){
			for(int k = 0; k <= 3; k++){
				if(i != R){
					dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
					if(field[i + 1][j]) dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + field[i + 1][j]);
				}
				if(j != C){
					dp[i][j + 1][k] = max(dp[i][j][k], dp[i][j + 1][k]);
					if(field[i][j + 1] && k != 3) dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k]+ field[i][j + 1]);
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i <= 3; i++) ans = max(ans, dp[R][C][i]);
	printf("%lld\n", ans);
}

Measured memory_bytes: 355948
#include<bits/stdc++.h>
using namespace std;
long long i[300000];
int main(){
  string s;
  int a=1,b=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='R' && a%2!=0 || s[i]=='L' && a%2==0){
      b++;
    }else if(s[i]=='U' || s[i]=='D'){
      b++;
    }
    a++;
  }
  if(b==s.size()){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------
// beetさんの素因数分解
template<typename T>
map<T, ll> factorize(T x){
  map<T, ll> res;
  for(int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}
// 使用例
// vector<int> cnt(111,0);
// for(int i=1; i<=N; i++){
//   for(auto p: factorize(i)){
//     cnt[p.first] += p.second;
//   }
// }

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};

// mint N;



int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  map<ll,ll> LCM;
  for(int i=0; i<N; i++){
    for(auto p: factorize(A[i])){
      if(LCM[p.first] < p.second){
        LCM[p.first] = p.second;
      }
    }
  }
  mint lcm = 1;
  for(auto p: LCM){
    for(int i=0; i<p.second; i++){
      lcm *= p.first;
    }
  }
  mint sum = 0;
  for(int i=0; i<N; i++){
    mint b = lcm/A[i];
    sum += b;
  }
  cout << sum.x << endl;
  return 0;
}


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

int main()
{
	/*?¨???????????????????*/
	int a[10];
	for (int i = 0; i < 10; i++)
		cin >> a[i];
	
	sort(a, a + 10);

		cout << a[9] << endl;
		cout << a[8] << endl;
		cout << a[7] << endl;

	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
typedef long long LL;

const LL MAXN = 1e5 + 7;
LL A[MAXN];

int main() {
    int n, q;
    LL k, tmp;
    cin >> n >> k >> q;
    for (int i = 0; i < n; i++) A[i] = k - q;

    while (q--) {
        cin >> tmp;
        A[tmp - 1]++;
    };


    for (int i = 0; i < n; i++) {
        if (A[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&x);
int A[105];
const int mod = 1e9+7;

/*二進数でbitが立つ時にかけるmod*/
int qp(int n)
{
    int ans = 1;
    int x = 2;
    while(n){
        if(n&1)ans=(ans*x)%mod;
        x = (x*x)%mod;
        n>>=1;
    }
    return ans;
}

int modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int comp(int a,int b,int m){
    if(a<b) return 0;
    if(a==b) return 1;
    if(b>a-b) b=a-b;
    int ans=1,ca=1,cb=1;
    for(int i=0;i<b;i++){
        ca=ca*(a-i)%m;
        cb=cb*(b-i)%m;
    }
    /*modを一度でも使ってしまうと普通の割り算では結果が変わってしまう*/
    /*そのため, modの逆数を算出し, それをかける必要がある*/
    ans = ca * modpow(cb, m - 2, m)%m;
    return ans;
}
signed main()
{
    int ans,n,a,b;
    sc(n)sc(a)sc(b)
    ans = modpow(2, n, mod);
    ans = (ans-1+mod)%mod;
    int x = comp(n,a,mod);
    ans = (ans-x+mod)%mod;
    int y = comp(n,b,mod);
    ans =(ans-y+mod)%mod;
 
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
H, W = map(int, input().split())
s = ["." * (W + 2) for _ in range(H + 2)]

ans = "Yes"

for h in range(H):
    s[h + 1] = "." + input() + "."

for h in range(1, H + 1):
    for w in range(1, W + 1):
        if s[h][w] == "#":
            t = [s[h + 1][w], s[h - 1][w], s[h][w + 1], s[h][w - 1]]
            if "#" not in t:
                ans = "No"
                break
    else:
        continue
    break

print(ans)


Measured memory_bytes: 3188
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   string word,str;
   cin>>word;
   for(int i=0;i<word.length();i++)
   {
     if(word[i]>='A'&&word[i]<='Z') word[i]=('a'+word[i]-'A');        
   }
   int count=0;
   while(cin>>str)
   {
     if(str=="END_OF_TEXT") break;
     else
     {
       for(int i=0;i<str.length();i++)
       {
         if(str[i]>='A'&&str[i]<='Z') str[i]=('a'+str[i]-'A');        
       }
       string kk=word+".";
       if(str==word||str==kk) count++;      
     }                       
   }
   cout<<count<<endl;
   //while(1);
   return 0;
 }

 
 

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

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n;
  cin >> n;
  map<int,int> mp;
  REP(i,n) {
    int a;
    cin >> a;
    if (sz(mp) == 0) {
      mp[a]++;
      continue;
    }
    auto itr = mp.upper_bound(a - 1);
//    cout << (*itr).fi << endl;
    if (itr == mp.begin()) {
      mp[a]++;
    } else {
      itr--;
      int k = (*itr).fi;
      if (mp[k] == 1) {
        mp.erase(k);
        mp[a]++;
      } else {
        mp[k]--;
        mp[a]++;
      }
    }
    // for (auto p: mp) {
    //   cout << p.fi << " ";
    // }
    // cout << endl;
  }
  int ans = 0;
  for (auto p:mp) {
    ans += p.se;
  }
  cout << ans << endl;
}

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

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

Measured memory_bytes: 4864