akhauriyash/Code-Regression huggingface dataset:
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    ll n; cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        ll b = n / i;

        ans += i * b * (b + 1) / 2;
    }
    print(ans);

    return 0;
}

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

using namespace std;

#define ops cout<<"ops"<<endl;
#define freopens freopen("cowpatibility.in", "r", stdin);freopen("cowpatibility.out", "w", stdout);
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define DIM 100007
#define DIMM 100007
#define INF 1000000000007.0
#define X 31
#define eps 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007

const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n,m;
ll v1,v2,res;
ll dp[DIM],vis[DIM];
vector<ll> a[DIM];

ll dfs(ll v){
   vis[v]=1;
   for(auto to:a[v]){
    if(vis[to]==0)dp[to]=dfs(to);
    dp[v]=max(dp[v],(dp[to]+1));
   }
   return dp[v];
}

int main()
{
    //ops;
    //freopens;
    fast;
    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>n>>m;
    for(int i=1;i<=m;i++){
     cin>>v1>>v2;
     a[v1].push_back(v2);
    }
    for(int i=1;i<=n;i++){
     if(vis[i]==0){
      dp[i]=dfs(i);
      res=max(res,dp[i]);
     }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 9344
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;

long long n, m;
int main()
{
	scanf("%lld%lld", &n, &m);
	for(int i = 2; i <= 10; i++){
	if(n * i % m != 0) {printf("%lld\n", i*n);
	return 0;}}
	printf("-1\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
 
int main(void){
   int n, c, k;
   cin >> n >> c >> k;
   
   int tmp[n];
   vector<int> t;
   for(int i = 0; i < n; i++)cin >> tmp[i];
   for(int i = 0; i < n; i++)t.push_back(tmp[i]);
   sort(t.begin(), t.end());
   t.push_back(0);
   
   int index = 0;
   int counter = 0;
   bool isFinished = false;
   
   while(index < n){
       if(t[index + 1] == 0){
           counter++;
           break;
       }
       int fTime = t[index];
       int numOfPeople = 0;
       for(int i = index; i < n; i++){
           if(t[i + 1] == 0){
               isFinished = true;
               counter++;
               break;
           }
           if(numOfPeople + 1 >= c || t[i + 1] - fTime > k){
               counter++;
               index = i + 1;
               break;
           } else {
               numOfPeople++;
           }
       }
       if(isFinished)break;
       
   }
   
   cout << counter << endl;
    
}


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

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

  int min = a+b+c;
  if(a+b<=min) min=a+b;
  if(b+c<=min) min=b+c;
  if(a+c<=min) min=a+c;
  cout << min << endl;
}

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


int main() {
    int n,m; cin >> n >> m;
    vector<ll> h(n),a(m),b(m);
    vector<pair<int,int>> x(m,pair<int,int>(0,0));
    rep(i,n) cin >> h.at(i);
    vector<ll> comp(n,0);
    rep(i,m){
        ll fir,sec;
        cin >> fir >> sec;
        fir--;
        sec--;
        comp.at(fir)=max(h.at(sec),comp.at(fir));
        comp.at(sec)=max(h.at(fir),comp.at(sec));
    }
    int ans=0;
    rep(i,n){
        if(h.at(i)>comp.at(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7200
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int i_index;
int tmp;
int main(){
    int K, S;
    cin >> K >> S;
    rep(i, K + 1) rep(j, K + 1){
        tmp = S - i - j;
        if(tmp <= K && i + j <= S && i <= K && j <= K)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] W = new String[N];

        boolean isValid = true;
        String result = "Yes";

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

        for (int i = 0; i < N - 1; i++) {
            if (W[i].charAt(W[i].length() - 1) != W[i + 1].charAt(0)) {
                isValid = false;
                result = "No";
                break;
            }
            for (int j = i + 1; j < N; j++) {
                if (W[i].equals(W[j])) {
                    isValid = false;
                    result = "No";
                    break;
                }
            }
            if (!isValid) {
                break;
            }
        }

        System.out.println(result);
    }
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s;
    cin  >> s;
    if (s.back() == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s << endl;

    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<stdio.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define pb                  push_back
#define arr                 vector<ll>
#define mem(x,val)          memset(x,val,sizeof(x))
#define vp                 vector<pair<ll,ll>>
#define matrix              vector<vector<ll> >
#define digit(x)            floor(log10(x))+1
#define debug(x)            cerr << #x << " is " << x << endl;
#define all(a)              a.begin(),a.end()
#define fixed               setprecision(15)
// ll dx[]={-1,1,0,0},dy[]={0,0,-1,1}; 4 Sides
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};    8 Sides
using namespace std;
arr read(ll n){
    arr a;
    for (ll i=0;i<n;i++){
        ll x;
        cin>>x;
        a.pb(x);
    }
    return a;
}
  int main(){
      ll n;
      cin >> n;
      if (n%2==0){
          cout<<-1<<endl;
      }else{
          if (n%5==0){
              cout<<-1<<endl;
          }else{
              ll x = 7%n;
              bool ok=0;
              ll ans=-1;
              for (ll i=1;i<=(ll)1e7;i++){
                    if (x == 0){
                        ans = i;
                        break;
                    }
                    x = (x*10 + 7) % n;
              }
              cout<<ans<<endl;
          }
      }
        return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int N;
    int d[100];
    cin >> N;
    REP(i, N) cin >> d[i];

    bool exist[100] = { false };
    REP(i, N){
        exist[d[i] - 1] = true;
    }
    int ans = 0;
    REP(i, 100){
        if(exist[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

/*****************************************************************************/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

ll n, x, ans;

int main() {
    scanf("%lld%lld", &n, &x);
    ans = n;
    ll a = x, b = n-x;
    while (a) {
        ans += (b - (b%a)) * 2;
        ll tmp = b%a;
        b = a;
        a = tmp;
    }
    ans -= b;
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{   float t,d,s;
    cin>>d>>t>>s;
    if(d/s<=t)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    
    
    
	
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    cin>>n;
    string s;
    cin>>s;
    int tW = 0;
    int tR = 0;
    for(char i:s){
        if(i=='R') tR++;
        else tW++;
    }
    int ans = 1e9;
    int w = 0;
    int r = 0;
    for(int i = -1; i<= n; i++){
        int rW = tW-w;
        int rR = tR-r;
        int cur = 0;
        if(i==-1) {
           cur = rR; 
        }else if(i==n){
            cur = w;
        }else{
            if(s[i]=='R') r++;
            else w++;
            int rW = tW-w;
            int rR = tR-r;
            int tW = w;
            int tRR = rR;
            cur += min(tW, tRR);
            tW -= cur;
            tRR -= cur;
            cur += tW + tRR;
        }
        ans = min(cur, ans);
    }
    cout<<ans<<"\n";
}


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

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

    int A, B;
    cin >> A >> B;
    A--;
    B--;

    vector<vector<char> > ans(100, vector<char>(100));

    int a = 0;
    int b = 0;

    for(int i = 1; i < 50; i += 2) {
        for(int j = 1; j < 100; j += 2) {
            if(a == A) break;
            ans[i][j] = '.';
            a++;
        }
    }

    for(int i = 0; i < 50; i++) {
        for(int j = 0; j < 100; j++) {
            if(ans[i][j] != '.') ans[i][j] = '#';
        }
    }

    for(int i = 51; i < 100; i += 2) {
        for(int j = 1; j < 100; j += 2) {
            if(b == B) break;
            ans[i][j] = '#';
            b++;
        }
    }

    for(int i = 50; i < 100; i++) {
        for(int j = 0; j < 100; j++) {
            if(ans[i][j] != '#') ans[i][j] = '.';
        }
    }

    cout << 100 << " " << 100 << endl;

    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < 100; j++) {
            cout << ans[i][j];
        }
        cout << endl;
    }
}

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

int main(){
    
    int N;cin>>N;
    vector<int> S(2*N);
    for(int i=0;i<2*N;i++){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    int sum=0;
    for(int i=0;i<2*N;i+=2){
        sum+=S[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e6 + 9;

int _;

//========================================================================

//========================================================================
int main()
{
    ll n,d,x,y,cnt=0;
    scanf("%lld%lld",&n,&d);
    d=d*d;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&x,&y);
        if(d>=x*x+y*y) cnt++;
    }
    printf("%lld\n",cnt);
    
    return 0;
}


Measured memory_bytes: 3820
#include<stdio.h>
#include<string.h>

int main() {
	
	long N;
	long H[100000];
	long cnt = 0;
	long maxcnt = 0;

	scanf("%d", &N);
	
	for (long i = 0; i < N; i++) {
		scanf("%ld", &H[i]);
		
	}


	for (long i = 0; i < N - 1; i++) {
		if (H[i] >= H[i + 1]) {
			cnt = cnt + 1;
			if (maxcnt < cnt) {
				maxcnt = cnt;
			}
		}
		else {
			cnt = 0;
		}
	}

	printf("%ld", maxcnt);

	return 0;
}



Measured memory_bytes: 896
int preorder[40],inorder[40];
void recover(int fp,int lp,int fi,int li){
    int root=fi;
    for(;root<li;root++)if(preorder[fp]==inorder[root])break;
    if(fi<root)recover(fp+1,fp+(root-fi)+1,fi,root);
    if(root<li-1)recover(fp+(root-fi)+1,lp,root+1,li);
    printf(inorder[root]==preorder[0]?"%d\n":"%d ",inorder[root]);
}
main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",preorder+i);
    for(i=0;i<n;i++)scanf("%d",inorder+i);
    recover(0,n,0,n);
    return 0;
}

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

int main(void)
{
  int N;
  cin >> N;
  
  vector<ll> B(N);
  for(int i=0;i<N-1;i++) cin >> B[i];
  B[N-1]=pow(10,5);
  
  vector<ll> A(N);
  for(int i=0;i<N;i++) A[i]=0;
  
  A[0]=B[0];
  for(int i=1;i<N;i++)
  {
    A[i]=min(B[i-1],B[i]);
  }
  
  cout << accumulate(A.begin(),A.end(),0);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=1005;
int n,m,foo[N][N],bar[N][N],ans[N*200];
vector<int>E[N],Q[N];
void dfs(int u,int c,int *mrk){
	if(mrk[u])return;mrk[u]=c;
	for(int v:E[u])if(!mrk[v])dfs(v,c,mrk);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		E[x].push_back(y);
		Q[x].push_back(i);
	}
	for(int i=1;i<=n;++i){
		foo[i][i]=bar[i][i]=-1;
		for(int j=0;j<E[i].size();++j)
			dfs(E[i][j],j+1,foo[i]);
		for(int j=E[i].size()-1;~j;--j)
			dfs(E[i][j],j+1,bar[i]);
	}
	for(int i=1;i<=n;++i)
		for(int j=0;j<E[i].size();++j){
			int x=(foo[E[i][j]][i]?1:0),y=(foo[i][E[i][j]]<=j)|(bar[i][E[i][j]]>j+1);
			ans[Q[i][j]]=x^y;
		}
	for(int i=1;i<=m;++i)puts(ans[i]?"diff":"same");
	return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<vector<vector<lli>>> box;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

const lli MOD = 1000000007;

lli n,m;
box cond;
lli l,r,x;
box dp;

void add(lli& a,lli& b){
	a = (a+b)%MOD;
}
lli use_color(lli l,lli i,lli j,lli k){
	lli ret = 0;
	if(i >= l) ret++;
	if(j >= l) ret++;
	if(k >= l) ret++;
	return ret;
}
lli ans = 0;


int main(){
	cin >> n >> m;
    cond = box(n+1,mat(4,{n+1,0}));
	for(lli i = 0;i < m;i++){
        cin >> l >> r >> x;
        cond[r][x][0] = min(cond[r][x][0],l);
        cond[r][x][1] = max(cond[r][x][1],l);
	}
	dp = box(n+1,mat(n+1,vll(n+1)));
	dp[0][0][0] = 1;
	for(lli i = 0;i <= n;i++){
		for(lli j = 0;j <= n;j++){
			for(lli k = 0;k <= n;k++){
				lli t = max({i,j,k});
                for(lli x = 1;x <= 3;x++){
                    if(cond[t][x][0] != n+1){
                        if(x != use_color(cond[t][x][0],i,j,k)) dp[i][j][k] = 0;
                    }
                    if(cond[t][x][1] != 0){
                        if(x != use_color(cond[t][x][1],i,j,k)) dp[i][j][k] = 0;
                    }
                }
				if(t == n) add(ans,dp[i][j][k]);
				else{
					add(dp[i][j][t+1],dp[i][j][k]);
					add(dp[i][t+1][k],dp[i][j][k]);
					add(dp[t+1][j][k],dp[i][j][k]);					
				}
			}
		}
	}
	cout << ans << endl;
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int ans = 700;
    for(int i=0; i<3; ++i){
        if(S.substr(i, 1) == "o"){
            ans += 100;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
module Main where

import           Data.List

main :: IO ()
main = do
    [h, w] <- (map read . words) <$> getLine :: IO [Int]
    list   <-
        (map (map read . words)) <$> (sequence . take h . repeat) getLine :: IO
            [[Int]]
    let res1    = (map goRight . enumerate2d) list
    let list2   = (map snd) res1
    let result1 = (flatten . map fst) res1
    let res2    = (map goRight . transpose) list2
    let result2 = (flatten . map fst) res2
    let result  = concat [result1, result2]

    putStr
        $ (unlines . (((show . length) result) :) . map
              (unwords . (\((a, b), (c, d)) -> (map show) [a, b, c, d]))
          )
              result

    return ()
goRight
    :: [((Int, Int), Int)] -> ([((Int, Int), (Int, Int))], [((Int, Int), Int)])
goRight list@[_         ] = ([], list)
goRight (     a : b : xs) = if even (snd a)
    then let res = goRight (b : xs) in (fst res, a : (snd res))
    else
        let res = goRight ((fst b, (snd b) + 1) : xs)
        in  ((fst a, fst b) : (fst res), (fst a, (snd a) - 1) : (snd res))

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d list =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)
        list

flatten :: [[a]] -> [a]
flatten []       = []
flatten (x : xs) = x ++ flatten xs


Measured memory_bytes: 87036
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>

using namespace std;

//벨만포드로
int main(void)
{
	vector <vector<long long int>> graph;
	long long int dist[1001];
	int N, M;
	long long int a,b,c;
	long long int INF = -9999999999999999;
	
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> a >> b >> c;
		graph.push_back({ a,b,c });
	}

	for (int i = 1; i <= N; i++)
	{
		dist[i] = INF;
	}

	dist[1] = 0;
	bool flag = false;
	for (int i = 0; i <= 2*N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			long long int from = graph[j][0];
			long long int  to = graph[j][1];
			long long int cost = graph[j][2];
			if (dist[from] != INF && dist[to] < dist[from] + cost)
			{
				if (to == N && i == 2*N-1)
				{
					cout << "inf" << endl;
					return 0;
				}
				dist[to] = dist[from] + cost;
			}
		}
	}

	cout << dist[N] << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e3 + 10;
const double PI = acos(-1);

double A, B;
int H, M;

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%lf%lf%d%d", &A, &B, &H, &M);
    double totM = H * 60 + M;
    double d1 = totM / 2;
    double d2 = M * 6;
    double d = abs(d1 - d2);
    d = min(d, 360 - d);
    double coss = cos(d / 180 * PI);
    printf("%.16lf\n", sqrt(A * A + B * B - 2 * A * B * coss));


    return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  string S;
  cin >> S;
  bool f = false;
  for(int i = 2; i + 1 < S.size(); i++) {
    if(S[i] == 'C') {
      S[i] = 'c';
      f = true;
      break;
    }
  }
  if(S[0] == 'A' && f) {
    for(int i = 1; i < S.size(); i++) {
      if(isupper(S[i])) {
        cout << "WA" << endl;
        return 0;
      }
    }
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
 var tree = parseInt(lines[0].split(' ')[0],10);
 var range =parseInt(lines[0].split(' ')[1],10);

 var kansi = 1+2*range;
 var count = 0;
  while(tree>=0){

    count++;
  	tree = tree- kansi;
   if(tree<=0){
   	break;
   }

  }
   console.log(count);


  
});

Measured memory_bytes: 29864
s=input()
t=int(input())
a=len(s)
b=0
i=0
while i<a-1:
  if s[i]==s[i+1]:
    b=b+1
    i+=2
  else:
    i+=1
if s[0]!=s[a-1]:
  print(b*t)
else:
  d=1
  i=0
  while i<a-1:
    if s[i]==s[i+1]:
      d+=1 
      i=i+1
    else:
      break
  e=1
  i=0
  while i<a-1:
    if s[a-1-i]==s[a-1-i-1]:
      e+=1
      i=i+1
    else:
      break
  if d+e==a*2:
    print(a*t//2)
  else:
    b-=d//2
    b-=e//2
    print(b*t+d//2+e//2+(d+e)//2*(t-1))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	string s, t;
	cin >> s >> t;
	ll cnt = 0;
	rep(i, s.size()) {
		if (s[i] != t[i]) cnt++;
	}cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    int k = 0;
    cin >> k;
    string s;
    cin >> s;

    if (s.size() <= k)
    {
        cout << s << endl;
    }
    else
    {
        
        for (int i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "...";
    }
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int Left = A + B;
  int Right = C + D;
  if(Left > Right) {
    cout << "Left" << endl;
  }
  else if (Left < Right) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl; 
  }
  
  
}

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

using namespace std;


int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a+=b;
    c+=d;
    if(a>c)cout<<"Left"<<endl;
    if(a==c)cout<<"Balanced"<<endl;
    if(a<c)cout<<"Right"<<endl;
    return 0;
}

Measured memory_bytes: 256
function f()
    A = parse(Int, chomp(readline()))
    B = parse(Int, chomp(readline()))
    C = parse(Int, chomp(readline()))
    D = parse(Int, chomp(readline()))
    E = parse(Int, chomp(readline()))

    arr = [A, B, C, D, E]
    
    arr_10 = arr % 10
    warikiri = sum(arr[arr_10 .== 0])

    warenai = arr[arr_10 .!= 0]

    tmp = (10 - warenai % 10)
    amari = sum(sort(tmp)[1:end-1])

    warenai = sum(warenai)

    goukei = warikiri + warenai + amari
    print(goukei)
end
f()

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

typedef long long ll;

int main()
{
    ll a, b;
    cin >> a >> b;
    if (0 < a && 0 < b)
    {
        cout << "Positive" << endl;
    }
    else if (a < 0 && b < 0)
    {
        if ((abs(b - a + 1) % 2 == 0))
        {
            cout << "Positive" << endl;
        }
        else
        {
            cout << "Negative" << endl;
        }
    }
    else if (a <= 0 && b >= 0)
    {
        cout << "Zero" << endl;
    }
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        private static Dictionary<string,int> dic = new Dictionary<string, int>();

        static void Solve()
        {
            int n = ReadAndParseInt();
            string ans = Calc(n) ? "Yes" : "No";
            Console.WriteLine(ans);
           
        }
        private static bool Calc(int n)
        {
            for (int i = 0; i * 4 <= n; ++i)
            {
                for (int j = 0; j * 7 <= n; ++j)
                {
                    if (i * 4 + j * 7 == n)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
#region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
#endregion
    }
}

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

def euclid( A, B ):
  a = A
  b = B
  r = a % b
  while r != 0:
    a = b
    b = r
    r = a % b
  return b

def factorization(n):
    arr = []
    temp = n
    for i in range( 2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt=0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append( i )

    if temp != 1:
        arr.append( temp )

    if ( n != 1 ) and ( arr == [] ):
        arr.append( n )

    return len( set( arr ) )

D = factorization( euclid( A, B ) )

print( D + 1 )



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int count[12];
    count[a]++;
    count[b]++;
    count[c]++;
    cout << ((count[5] == 2 && count[7] == 1) ? "YES" : "NO") << endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    static int ans[1100][1100];
    ans[1][1] = 1;
    for(int k=1; k<10; k++){
        int W = 1<<k;
        for(int i=0; i<W; i++) for(int j=0; j<W; j++){
            ans[i+W][j] = ans[i][j+W] = ans[i][j];
            ans[i+W][j+W] = ans[i][j]^1;
        }
    }
    const int X = 1<<10;
    for(int i=X-1; i>0; i--) for(int j=X-1; j>0; j--) ans[i][j] ^= ans[i-1][j];
    for(int i=X-1; i>0; i--) for(int j=X-1; j>0; j--) ans[i][j] ^= ans[i][j-1];

    for(int i=1; i<(1<<N); i++){
        for(int j=1; j<(1<<M); j++) cout << ans[i][j];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

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

    vector<vector<pair<int, long long>>> graph(n, vector<pair<int, long long>>(0));
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        graph[a - 1].push_back(make_pair(b - 1, c));
        graph[b - 1].push_back(make_pair(a - 1, c));
    }

    int q, k;
    cin >> q >> k;

    vector<long long> dist(n, 1LL << 48);
    dist[k - 1] = 0;

    priority_queue<pair<long long, int>> que;
    que.push(make_pair(0, k - 1));
    while (!que.empty()) {
        pair<long long, int> p = que.top();
        que.pop();

        for (int i = 0; i < static_cast<int>(graph[p.second].size()); i++) {
            if (dist[graph[p.second][i].first] > dist[p.second] + graph[p.second][i].second) {
                dist[graph[p.second][i].first] = dist[p.second] + graph[p.second][i].second;
                que.push(make_pair(dist[graph[p.second][i].first], graph[p.second][i].first));
            }
        }
    }

    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << dist[x - 1] + dist[y - 1] << endl;
    }
}


Measured memory_bytes: 11120
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
//#include <iostream>
//#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define debd(x) pf("%s = %d\n", #x, x)
#define debs(x) pf("%s = %s\n", #x, s)
#define debll(x) pf("%s = %lld\n", #x, x)
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
//bitmask
int onbit(int x, int pos) {x |= (1 << pos); return pos;}
int offbit(int x, int pos) {x &= ~(1 << pos); return x;}
int test(int x, int pos) {return x & (1 << pos);}
int flip(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int onbitall(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
//    freopen("input.in", "r", stdin);
	int res = 0;
	int n;
	char s[123];
	sf("%d %s", &n, s);
	
	int cur = 0;
	fr(i, 0, strlen(s)) {
		if(s[i] == 'I') cur++;
		else cur--;
		res = max(res, cur);
	}
	pf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
        int a,b;
        scanf("%d %d", &a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::unordered_map<i64, i64> A_tally;
  for (const i64& A_i : A) {
    ++A_tally[A_i];
  }

  i64 answer_base = 0;
  for (const std::pair<i64, i64>& pair : A_tally) {
    answer_base += pair.second * (pair.second - 1) / 2;
  }

  for (const i64& A_i : A) {
    std::cout << answer_base - (A_tally[A_i] - 1) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 9160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		int ans = 0;
		for (int i = 4; i <= m; i++) {
			for (int j = 22; j <= d; j++) {
				if (j % 10 >= 2) {
					if ((j / 10) * (j % 10) == i) {
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 1) {
        a = 14;
    }
    if (b <= 1) {
        b = 14;
    }
    if (a > b) {
        cout << "Alice" << endl;
    }
    else if (a == b) {
        cout << "Draw" << endl;
    }
    else {
        cout << "Bob" << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
H, W = map(int, input().split())
c = [0 for _ in range(10)]
for i in range(10):
  c[i] = list(map(int, input().split()))
A = [0 for _ in range(H)]
for i in range(H):
  A[i] = list(map(int, input().split()))
for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j] = min(c[i][j], c[i][k] + c[k][j])
ans = 0
for i in range(H):
  for j in range(W):
    if A[i][j] != -1:
      ans += c[A[i][j]][1]
print(ans)

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

#define ll long long int

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    s += s;
    vector<vector<int>> pos(26);
    vector<int> cnt(26, 0);
    for(int i = 0; i < s.size(); i++) {
        cnt[s[i] - 'a']++;
        pos[s[i] - 'a'].push_back(i);
    }
    ll ans = 0, p = 0;
    for(int i = 0; i < t.size(); i++) {
        if(!cnt[t[i] - 'a']) {
            cout << -1;
            return 0;
        }
        p = *lower_bound(pos[t[i] - 'a'].begin(), pos[t[i] - 'a'].end(), p) + 1;
        // cout << p << endl;
        if(p >= n) {
            ans += n;
            p -= n;
        }
    }
    ans += p;
    cout << ans << endl;
}

Measured memory_bytes: 1784
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 1e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].fe << " " << v[i].se << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PP(int n) { cout << n << " ";}
inline void PP(int n, int m) { cout << n << " " << m << endl;}
inline void PP(int n, int m, int q) {  cout << n << " " << m << " " << q << endl;}
inline void PP(int n, int m, int q, int u) {  cout << n << " " << m << " " << q << " " << u << endl;}
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <=================================================================================================================================
// <=================================================================================================================================


signed  main() {
    //op();
    lets_go
    int i, j, x, y, u, l;
    //int t; cin >> t; while (t--)
    {
        i = j = x = y = u = l = 0;


        int n;
        cin >> n;
        int a[n+10];
        for ( i = 0; i < n; i++) {
            cin >> x;
            y =y^ x;
            a[i] = x;
        }
        for(i = 0; i <n;i++){
            x = a[i]^y;
            PP(x);
        }
        



        /* */

    }
    return 0;

}


Measured memory_bytes: 5152
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int X,t;

    cin >>X>>t;

    if (X < t) cout << '0' << endl;
    else cout << X-t <<endl;


}


Measured memory_bytes: 256
def digit(n):
    tmp=n//10
    c=1
    while(tmp!=0):
        c+=1
        tmp=tmp//10
    return c
x=int(input())
# print(digit(x))
cnt=0
for i in range(1,x+1):
    if(digit(i)%2==1):
        cnt+=1
print(cnt)

    

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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; ++i)
    {
        cin >> a[i];
        n -= a[i];
    }
    if (n < 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << n << endl;
    }
    return 0;
}


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

int n,a[100001];
long long ans;
int main()
{
	cin>>n;
    for(int i=0;i<n;i++)
    	cin>>a[i];
    for(int i=0;i<n;i++)
    {
        ans+=a[i]/2;
        a[i]%=2;
        if(i<n-1&&a[i]&&a[i+1])
            ans++,a[i]--,a[i+1]--;
	}
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100005
#define LL long long
int main()
{
    LL a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a%2==0||b%2==0||c%2==0)
    {
        printf("0\n");
        return 0;
    }
    printf("%lld\n",min(a*b,min(a*c,b*c)));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int W, H, N;

void Fill(vector<vector<bool>> &size, int x, int y, int a)
{
    if (a == 1)
    {
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < x; j++)
            {
                size[i][j] = true;
            }
        }
    }
    else if (a == 2)
    {
        for (int i = 0; i < H; i++)
        {
            for (int j = x; j < W; j++)
            {
                size[i][j] = true;
            }
        }
    }
    else if (a == 3)
    {
        for (int i = 0; i < y; i++)
        {
            for (int j = 0; j < W; j++)
            {
                size[i][j] = true;
            }
        }
    }
    else if (a == 4)
    {
        for (int i = y; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                size[i][j] = true;
            }
        }
    }
}

int main()
{
    cin >> W >> H >> N;

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

    vector<vector<bool>> S(H, vector<bool>(W));
    for (int i = 0; i < N; i++)
    {
        Fill(S, X[i], Y[i], A[i]);
    }

    int res = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (!S[i][j])
                res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3632
N = int(input())
now = [0, 0, 0]
ans = 'Yes'
for i in range(0, N):
	T, X, Y = map(int, input().split())
	nexttime = T - now[0]
	nextX = abs(X - now[1])
	nextY = abs(Y - now[2])
	if nexttime < nextX + nextY:
		ans = 'No'
		break
	if (nexttime-(nextX+nextY)) % 2 == 1:
		ans = 'No'
		break
	now = [T, X, Y]
print(ans)

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

long n, a[100000], p = 10000000, q = -10000000, s;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        p = min(p, a[i]);
        q = max(q, a[i]);
        s += a[i];
    }
    cout << p << " " << q << " " << s << endl;
}


Measured memory_bytes: 3172
N = int(input())
A = tuple(map(int,input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]

for d in range(1,N+1):
  for l in range(N+1-d):
    r = l+d
    dp[l][r] = max(A[l]-dp[l+1][r], A[r-1]-dp[l][r-1])

print(dp[0][N])

Measured memory_bytes: 112220
#include<iostream>
int64_t N,P,p,r,v,m[1<<20];std::string S;main(){std::cin>>N>>P>>S;if(10%P)for(*m=p=1;N--;r+=m[v=(v+(S[N]-48)*(p=p*10%P))%P]++);else for(;v<N;r+=(S[v++]-8)%P?0:v);std::cout<<r;}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l;
	string a[100];
	cin>>n>>l;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]>a[j]) swap(a[i],a[j]);
		}
	}
	for(int i=0;i<n;i++)
	{
		cout<<a[i];
	}
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,n,t,i,j,k,x,y,m,p,s,mx,mn;
    cin>>t;
    int ar[t],br[t],sum=0;
    for(p=0; p<t; p++)
    {
        cin>>ar[p];
    }
    for(p=0; p<t; p++)
    {
        cin>>br[p];
    }
    for(p=0;p<t;p++)
    {
        if(ar[p]>br[p])
        {
            sum=sum+(ar[p]-br[p]);
        }

    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
const int Mod = 998244353;
const int N = 2e5 + 3;
struct Seg {
    int l, r;
    LL v;
} t[N << 2];
 
void up(int p) {
    t[p].v = t[p << 1].v + t[p << 1 | 1].v;
    t[p].v %= Mod;
}
 
void build(int p, int l, int r) {
    t[p].l = l, t[p].r = r;
 
    if (l == r) {
        t[p].v = 0;
        return;
    }
    int mid =  l + r >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
    up(p);
}
 
void update(int p, int x, LL v) {
    if (t[p].l == t[p].r) {
        t[p].v = (t[p].v + v) % Mod;
        return;
    }
    int mid = t[p].l + t[p].r >> 1;
    if (x <= mid) {
        update(p << 1, x, v);
    }
    else update(p << 1 | 1, x , v);
    up(p);
}
 
LL query(int p, int l, int r) {
    if (l <= t[p].l && r >= t[p].r) return t[p].v;
    int mid = t[p].l + t[p].r >> 1;
    LL res = 0;
    if (l <= mid) res += query(p << 1, l, r);
    if (r > mid) res += query(p << 1 | 1, l, r);
    return res % Mod;
}
pair<int, int> p[11];
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n, k;
    cin >>  n >> k;

    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        p[i] = {a, b};
    }
    build(1, 1, n);
    update(1, 1, 1);
    // for (int k = 1; k <= n; k++) {
    //     cout << query(1, k, k) << ' ';
    // }
    // cout << endl;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < k; j++) {
            int r = i - p[j].first;
            int l = max(1, i - p[j].second);
            if (l > r) continue;
            update(1, i, query(1, l, r));
        }
    //     for (int k = 1; k <= n; k++) {
    //         cout << query(1, k, k) << ' ';
    //     }
    // cout << endl;
    }
    cout << query(1, n, n) << endl;

    return 0;
}

Measured memory_bytes: 11840
w_a = [1,2,4,8,16,32,64,128,256,512]

while True:
    try:
        w_b = int(input())
        b = list(bin(w_b))[::-1]
        w_c = []
        for i in range(len(b)):
            if b[i] == "b":
                break
            elif b[i] == "1":
                w_c.append(w_a[i])
        print(*w_c)
    except:
        break



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

const int MAXN = 4e2+5;
const long long INF = 1e18+7;
#define ll long long
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

ll a[MAXN],dp[MAXN][MAXN],sums[MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

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


    for(int i=1;i<=n;++i) sums[i] = sums[i-1] + a[i];

    for(int len=1;len<=n;++len){
        for(int l=1;l<=n-len+1;++l){

            int r = l + len;
            dp[l][r] = INF;
            for(int f=l;f<=r-1;++f){
                dp[l][r] = min(dp[l][r],sums[r] - sums[l-1] + dp[l][f] + dp[f+1][r]);
            }
        }
    }

    cout << dp[1][n];
}


Measured memory_bytes: 1536