akhauriyash/Code-Regression huggingface dataset:
// ~maqsat~
/*    
**	  “Anyone who has never made a mistake has never tried anything new.”
**    © Albert Einstein
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 2e5 + 345;
const ll MOD = 998244353;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;

    int n;
    cin >> n;

    ll a[N], p[N];
    for(int i = 0; i < n; i++) cin >> a[i];
    p[0] = a[0];
    for(int i = 1; i < n; i++) p[i] = p[i-1] + a[i];

    ll ans = INF;
    for(int i = 0; i < n; i++) {
    	ll x = p[i];
    	ll y = p[n-1] - p[i];
    	ll z = max(x, y) - min(x, y);
    	ans = min(ans, z);
    }

    cout << ans;
    return 0;
}
/*
 
*/


Measured memory_bytes: 3456
#include <stdio.h>

int main()
{
    int a,b,c,d,i,j,k,n,m,x,y,z;

    scanf("%d",&n);
    d=n%10;
    x=n/10;
    c=x%10;
    y=x/10;
    b=y%10;
    a=y/10;

    if(a+b+c+d==7)
    {
        printf("%d+%d+%d+%d=7",a,b,c,d);
    }
    else if(a+b+c-d==7)
    {
        printf("%d+%d+%d-%d=7",a,b,c,d);
    }
    else if(a+b-c-d==7)
    {
        printf("%d+%d-%d-%d=7",a,b,c,d);
    }
    else if(a-b-c-d==7)
    {
        printf("%d-%d-%d-%d=7",a,b,c,d);
    }
    else if(a+b-c+d==7)
    {
        printf("%d+%d-%d+%d=7",a,b,c,d);
    }
    else if(a-b+c+d==7)
    {
        printf("%d-%d+%d+%d=7",a,b,c,d);
    }
    else if(a-b-c+d==7)
    {
        printf("%d-%d-%d+%d=7",a,b,c,d);
    }
    else if(a-b+c-d==7)
    {
        printf("%d-%d+%d-%d=7",a,b,c,d);
    }
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#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 sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
ll modpow(ll b, ll e, ll m) {
  ll r = 1;
  while(e) {
    if(e%2) {
      r*=b;
      r%=m;
    }
    b*=b;
    b%=m;
    e/=2;
  }
  return r;
}
ll inv(ll a) {
  return modpow(a, MOD-2, MOD);
}
int l[10005];
int amt[1000005];
void solve() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    l[i] = x;
    for(int a = 2; a * a <= x; a++) {
      int p = 0;
      while(x%a==0) {
        x/=a;
        p++;
      }
      amt[a] = max(amt[a], p);
    }
    if(x > 1) amt[x] = max(amt[x], 1);
  }
  ll tot = 1;
  for(int i = 2; i <= 1000000; i++) {
    if(amt[i]) {
      tot *= modpow(i, amt[i], MOD);
      tot %= MOD;
    }
  }
  ll ret = 0;
  for(int i = 0; i < n; i++) {
    ret += tot * inv(l[i]);
    ret %= MOD;
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 2816
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define mp     make_pair
#define cont   continue
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 1e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll a[MAXN],b[MAXN],dp[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
ll n,m,k,cnt,sum,ans,mx,mn=INF;
bool y;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}


void solve(){
	cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        dp[i]=INF;

    }
    dp[1]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i>j)dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    cout<<dp[n];
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
     
    while(x!=NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if(z->key < y->key) {
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for (i=0; i<n; i++) {
        cin >> com;
        if(com == "insert") {
            scanf("%d", &x);
            insert(x);
        }else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 26732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct edge{ll from,to,cost;};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m,p;
    cin>>n>>m>>p;
    vector<edge> g(m);
    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        g[i]={a,b,-(c-p)};
    }
    vector<ll> dist(n,inf);
    dist[0]=0;
    rep(_,2*n){
        for(auto e:g){
            if(dist[e.from]!=inf){
                chmin(dist[e.to],dist[e.from]+e.cost);
            }
        }
    }
    vector<bool> flag(n,false);
    rep(_,2*n){
        for(auto e:g){
            if(dist[e.from]!=inf){
                if(chmin(dist[e.to],dist[e.from]+e.cost)){
                    flag[e.from]=flag[e.to]=true;
                }
            }
            if(flag[e.from]) flag[e.to]=true;
        }
    }
    if(!flag[n-1]) cout<<max(0ll,-dist[n-1])<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,x;
	cin>>n>>x;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	ll ret=0;
	FOR(i,1,n) {
		if(a[i]+a[i-1]>x) {
			ret+=a[i]+a[i-1]-x;
			if(a[i]>=a[i]+a[i-1]-x) a[i]-=a[i]+a[i-1]-x;
			else {
				a[i-1]-=a[i]+a[i-1]-x-a[i];
				a[i]=0;
			}
		}
	}
	cout<<ret<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;
string s,t;


int main()
{
    cin >> s >> t;
    int cnt = 0;

    for (int i = 0; i <= s.length()-1; i ++)
    {
        if (s[i] != t[i])
            cnt ++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3876
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;


int main()
{
	int a, b, c, ans = 0;
	string s, t;
	cin >> a;
	for (int i = 1; i <= a/2+1; i++)
	{
		if (i < a - i)ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
/*

  ______      _                _____ 
  |  ____/\   | |        /\    / ____|
  | |__ /  \  | |       /  \  | (___  
  |  __/ /\ \ | |      / /\ \  \___ \
  | | / ____ \| |____ / ____ \ ____) |
  |_|/_/    \_\______/_/    \_\_____/ 
                                            
                                            

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

#define ll long long
#define INF 1000000
#define MOD 1000000007

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;

#define F first
#define S second

#define mp make_pair
#define endl '\n'
#define priority_queue pq

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a, a+n);
    int mid = n/2;
    cout<<max(0, a[mid]-a[mid-1])<<endl;

}



Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long gcd = getGCD(a, b);
		int count = 0;
		for (long i = 2; i <= Math.sqrt(gcd); i++) {
		    if (gcd % i == 0) {
		        if (isPrime(i)) {
		            count++;
		        }
		        while (gcd % i == 0) {
		            gcd /= i;
		        }
		    }
		}
		if (gcd > 1) {
		    if (isPrime(gcd)) {
		        count++;
		    }
		}
		System.out.println(count + 1);
    }
    
    static long getGCD(long a, long b) {
        if (a % b == 0) {
            return b;
        } else {
            return getGCD(b, a % b);
        }
    }
    
    static boolean isPrime(long x) {
        for (long i = 2; i <= Math.sqrt(x); i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}


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

int main() {
  int N;
  cin >> N;
  map<int, int> o, e;
  int n;
  for (int i = 0; i < N; ++i) {
    cin >> n;
    if (i % 2 == 0) {
      o[n]++;
    } else {
      e[n]++;
    }
  }
  vector<pair<int, int>> ov, ev;
  for (auto p : o) {
    ov.emplace_back(make_pair(p.second, p.first));
  }
  ov.emplace_back(make_pair(0, 0));
  sort(ov.begin(), ov.end(), greater<pair<int, int>>());
  for (auto p : e) {
    ev.emplace_back(make_pair(p.second, p.first));
  }
  ev.emplace_back(make_pair(0, 0));
  sort(ev.begin(), ev.end(), greater<pair<int, int>>());
  int count;
  if (ov[0].second != ev[0].second) count = ov[0].first + ev[0].first;
  else if (ov[0].first + ev[1].first > ov[1].first + ev[0].first) count = ov[0].first + ev[1].first;
  else count = ov[1].first + ev[0].first;
  cout << N - count << endl;
}


Measured memory_bytes: 6136
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;
const double PI = acos(-1.0);

const int LEFT = 1;
const int DOWN = 2;

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

	REP(sgz, n) {
		vvi field(16, vi(16, 0));
		bool matatabi[16][16][16][16] = {false};
		
		int gx, gy;
		cin >> gx >> gy;

		int m;
		cin >> m;

		REP(i, m) {
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			matatabi[x1][y1][x2][y2] = matatabi[x2][y2][x1][y1] = true;
		}

		field[0][0] = 1;
		FOR(i, 0, gx) {
			FOR(j, 0, gy) {
				if(i) {
					if(!matatabi[i][j][i-1][j]) {
						field[i][j] += field[i-1][j];
					}
				}
				if(j) {
					if(!matatabi[i][j][i][j-1]) {
						field[i][j] += field[i][j-1];
					}
				}
			}
		}

		if(field[gx][gy]) {
			cout << field[gx][gy] << endl;
		} else {
			cout << "Miserable Hokusai!" << endl;
		}
	}

	return 0;
}

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

int X[100010];

int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> X[i];
  int min_dist = (1<<30);
  for (int i = 0; i < N-K+1; i++) {
    if (X[i+K-1] <= 0) {
      if (-X[i] < min_dist) {
        min_dist = -X[i];
      }
    } else if (X[i] < 0) {
      int dist = min(-X[i] * 2 + X[i+K-1], -X[i] + X[i+K-1] * 2);
      if (dist < min_dist) {
        min_dist = dist;
      }
    } else {
      if (X[i+K-1] < min_dist) {
        min_dist = X[i+K-1];
      }
    }
  }
  cout << min_dist << endl;
}

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

int main() {
	string s;
	int k;

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

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = (int) 2e5 + 100;
vector <int> g[N];
bool used[N];

void dfs(int v)
{
	used[v] = true;
	for (int to : g[v] )
	{
		if (used[to] ) continue;
		dfs(to);
	}
}


int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif


	int n, m;
	scanf("%d%d", &n, &m);

	for (int i = 0; i < n; i++)
	{
		int k;
		scanf("%d", &k);
		for (int j = 0; j < k; j++)
		{
			int x;
			scanf("%d", &x);
			x--;
			g[x + n].push_back(i);
			g[i].push_back(x + n);
		}
	}
	dfs(0);
	for (int i = 0; i < n; i++)
		if (!used[i] )
		{
			printf("NO\n");
			return 0;
		}
	printf("YES\n");



	return 0;
}



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

using namespace std;

#define MAX_N 100000

struct mov
{
    int t, x, y;
};

mov a[MAX_N + 1 + 1];

int n;

int main()
{
    cin >> n;

    a[1] = {0, 0, 0};

    for(int i = 2; i <= n + 1; i ++)
        cin >> a[i].t >> a[i].x >> a[i].y;

    int ok = 1;
    for(int i = 2; i <= n + 1; i ++)
    {
        int t = a[i].t - a[i - 1].t;
        int dist = abs(a[i].x - a[i - 1].x) + abs(a[i].y - a[i - 1].y);

        if(t < dist)
            ok = 0;

        if(t > dist)
        {
            t -= dist;
            if(t & 1)
                ok = 0;
        }
    }

    cout << (ok == 1 ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
  int n,y,sen,gosen,man;
  scanf("%d %d",&n,&y);
  for(sen=0;sen<=n;sen++){
    for(gosen=0;gosen<=n;gosen++){
      man=n-(sen+gosen);
      if(sen*1000+gosen*5000+man*10000==y&&
         sen+gosen+man==n&&man>=0){        
  printf("%d %d %d",man,gosen,sen); return 0; }
    }    
  }
  printf("-1 -1 -1");
    return 0;
  }

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  ll N; cin >> N;
  ll K; cin >> K;
  ll Q; cin >> Q;
  vector<ll> A(N, 0);
  for (int i=0; i<Q; i++){
    int t; cin >> t;
    t--;
    A[t]++;
  }
  for (int i=0; i<N; i++) {
    if (K-Q+A[i] > 0) cout << yes << endl;
    else cout << no << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main (void){
	int a, b;
	int a1, b1;
	int n;
	int gcd, lcm;
	
	while (scanf("%d %d", &a, &b) != EOF){
		a1 = a;
		b1 = b;
	
		while(a % b != 0){
			
			n = b;
			b = a % b;
			a = n;
		}
		
		gcd = b;
		lcm = a1 * (b1 / gcd);
		
		printf("%d %d\n", gcd, lcm);
	}
	return (0);
}

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
    int ss1,ss2,ss3,i;
    ss1=0;ss2=0;ss3=0;
    char s[10];
    char s1[]="Sunny";
    char s2[]="Cloudy";
    char s3[]="Rainy";
    gets(s);
    for(i=0; i<6; i++)
    {
        if(s[i]==s1[i])
        {
            ss1++;
        }
        else
            break;
    }

    for(i=0; i<7; i++)
    {
        if(s[i]==s2[i])
        {
            ss2++;
        }
        else
            break;
    }

    for(i=0; i<6; i++)
    {
        if(s[i]==s3[i])
        {
            ss3++;
        }
        else
            break;
    }
    if(ss1==6)
        printf("Cloudy\n");
    else if(ss2==7)
        printf("Rainy\n");
    else if(ss3==6)
        printf("Sunny\n");
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=[int(i) for i in input().split()]

for i in range(n):
  v =A[i]
  j=i-1
  while (j>=0)&(A[j]>v):
    #print('i=', i)
    #print('j=',j)
    A[j+1]=A[j]
    A[j] = v
    j-=1
  print(*A, sep=' ')


Measured memory_bytes: 5984
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
   ll n,x=0;
   cin>>n;
   ll a[n];
   for(int i=0;i<n;i++)
  { cin>>a[i];
   x=x^a[i];}
   for(int i=0;i<n;i++)
   {
       cout<<(x^a[i])<<" ";
   }}

Measured memory_bytes: 5208
class Dice():
    
    def __init__(self, labels):
        self.__pip = labels
        
    def roll_e(self): # 0352 → 3520
        self.__pip[0], self.__pip[3], self.__pip[5], self.__pip[2] = \
            self.__pip[3], self.__pip[5], self.__pip[2], self.__pip[0]
    
    def roll_n(self): # 0154 → 1540 
        self.__pip[0], self.__pip[1], self.__pip[5], self.__pip[4] = \
            self.__pip[1], self.__pip[5], self.__pip[4], self.__pip[0]

    def roll_s(self): # 0451 →  4510
        self.__pip[0], self.__pip[4], self.__pip[5], self.__pip[1] = \
            self.__pip[4], self.__pip[5], self.__pip[1], self.__pip[0]

    def roll_w(self): # 0253 → 2530
        self.__pip[0], self.__pip[2], self.__pip[5], self.__pip[3] = \
            self.__pip[2], self.__pip[5], self.__pip[3], self.__pip[0]

    def roll_nn(self): # 0154 → 5401
        self.roll_n()
        self.roll_n()
        
    def turn_dice(self): # 1243 → 2431
        self.__pip[1], self.__pip[2], self.__pip[4], self.__pip[3] = \
            self.__pip[2], self.__pip[4], self.__pip[3], self.__pip[1]
            
    def get_right(self, top, front):
        if top != self.__pip[0]:
            if top == self.__pip[1]:
                self.roll_n()
            elif top == self.__pip[2]:
                self.roll_w()
            elif top == self.__pip[3]:
                self.roll_e()
            elif top == self.__pip[4]:
                self.roll_s()
            else:
                self.roll_nn()
        for i in range(3):
            if front == self.__pip[1]:
                break
            self.turn_dice()
        return self.__pip[2]
        
        
def main():
    dice = Dice(list(input().split()))
    n = int(input())
    for i in range(n):
        top, front = input().split()
        right = dice.get_right(top, front)
        print("{}".format(right))
        

if __name__ == "__main__":
    main()



Measured memory_bytes: 5608
#include<stdio.h>
main()
{
    int t,b[9999]={0};
    scanf("%d",&t);
    b[t]++;
    int i=1;
    while(t!=0)
    {
        if(t%2==0){
            t=t/2;
            i++;
            b[t]++;
            if(b[t]>1){
                printf("%d\n",i);
                break;}

        }
        else
        {
            t=(3*t)+1;
            b[t]++;
            i++;
            if(b[t]>1){
                printf("%d\n",i);
                break;}
                }
    }
    return 0;
}


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

string f(long long n){
    if(n == 0){
        return "";
    } else {
        n--;
        return f(n/26) + string(1, 'a' + n%26);
    }
}

int main(void){
    long long n;
    cin >> n;
    cout << f(n) << endl;
    return 0;
}

Measured memory_bytes: 3608
suits = ['S','H','C','D']
 
table = [[False]*14 for i in range(4)]
 
N = int(input())
 
for loop in range(N):
 
    mark,num = input().split()
    num = int(num)
 
    if mark == 'S':
        table[0][num] = True
    elif mark == 'H':
        table[1][num] = True
    elif mark == 'C':
        table[2][num] = True
    else:
        table[3][num] = True
 
for i in range(4):
    for k in range(1,14):
        if table[i][k] == False:
            print("%s %d"%(suits[i],k))


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

using namespace std;
int kb[1000000];
long int f(int x,int y,int z)
{
    long int value;
    value=x*x+y*y+z*z+x*y+x*z+z*y;
    
    kb[value]+=1;
   
    return value;
}

int main()
{
   int n;
   cin>>n;
   int p=sqrt(n)+1;
   for(int i=1;i<=p;i++)
   {
       for(int j=1;j<=p;j++)
       {
           for(int k=1;k<=p;k++)
           {
               if(f(i,j,k)>=n)
               break;
           }
       }
   }
   
   for(int l=1;l<=n;l++)
   cout<<kb[l]<<"\n";
   
   return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n, h, w;
pair<int,pii> pts[125252];

int dat[252521];
int cnt[252521];
int root(int x){
    return dat[x]<0?x:dat[x]=root(dat[x]);
}
void unite(int a, int b){
    a=root(a);b=root(b);
    if(a==b)return;
    if(dat[a]>dat[b])swap(a,b);
    dat[a] += dat[b];
    dat[b] = a;
    cnt[a] += cnt[b];
}

int main(){
    scanf("%d%d%d",&n,&h,&w);
    REP(i,n){
        int r,c,a;
        scanf("%d%d%d",&r,&c,&a);
        --r;--c;
        pts[i] = make_pair(a,pii(r,c));
    }
    sort(pts,pts+n);
    reverse(pts,pts+n);
    fill(dat,dat+(h+w),-1);
    fill(cnt,cnt+(h+w),1);
    ll ans = 0;
    REP(i,n){
        int r,c,a;
        a = pts[i].first;
        tie(r,c) = pts[i].second;
        r = root(r);
        c = root(c+h);
        if(cnt[r]>0 || cnt[c]>0){
            unite(r,c);
            ans += a;
            r = root(r);
            cnt[r]--;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s; cin >> s;
	
	long long ans = 0;
	for(long long i = 0; i < int(s.size()) >> 1; i++){
		if(s[i] != s[int(s.size()) - i - 1]){
			ans++;
		}
	}
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
 
class program
{
    static void Main()
    {
            var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
 
            long X = line[0]; // 現在地
            var K = line[1]; // 移動回数
            var D = line[2]; // 移動距離
 
            long ans = X; // K回後の最小の絶対値
 
            // moveTimesToRoundTrip: 往復移動をするまでに必要な移動回数
            // Xがマイナスでも答えは変わらないため絶対値で計算
            // 切り捨ててもKは整数であるため同じ値になる
            var moveTimesToRoundTrip = Math.Abs(X) / D;
 
            if (moveTimesToRoundTrip >= K)
            {
                // 往復移動をしない場合
                // 現在地から移動回数*移動距離を足し引きして求める
                if (X >= 0)
                {
                    ans = X - K * D;
                }
                else
                {
                    ans = X + K * D;
                }
            }
            else
            {
                // 往復移動をする場合
 
                // distanceBeforeRoundTrip: 往復移動する前の距離
                var distanceBeforeRoundTrip = X % D;
 
                // roundTripTimes: 往復回数
                // 原点近くにたどり着くまでにmoveTimesToRoundTripかかる
                // 残りの回数roundTripTimesは原点をまたいで-D, +Dを繰り返す
                var roundTripTimes = K - moveTimesToRoundTrip;
 
                if (roundTripTimes % 2 == 0)
                {
                    // 偶数回移動するなら
                    // 往復移動しても往復移動する前の距離が答え
                    ans = distanceBeforeRoundTrip;
                }
                else
                {
                    // 奇数回移動するなら
                    // 往復移動する前の距離が正なら移動距離Dを引いて
                    // 往復移動する前の距離が負なら移動距離Dを足す
                    if (distanceBeforeRoundTrip > 0)
                    {
                        ans = distanceBeforeRoundTrip - D;
                    }
                    else
                    {
                        ans = distanceBeforeRoundTrip + D;
                    }
                }
            }
 
            Console.WriteLine(Math.Abs(ans));
                
    }
}


Measured memory_bytes: 28232
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=2e5+500;
const ll mod=1e9+7;
const ll inf=1e9+500;

ll in[maxn];
bool vis[maxn];
ll y;
bool dor[maxn];
bool barg[maxn];
ll anss[maxn];
vector<ll> out[maxn];



void  dfs(ll a){
	if(vis[a]){
		y=a;
		return ;
	}
	vis[a]=1;
	dfs(in[a]);
}
void dfss(ll a){
	if(dor[a]){
		return;
	}
	dor[a]=1;
	dfss(in[a]);
}
ll mexx(ll a){
	vector<ll> b;
	for(ll i=0;i<out[a].size();i++){
		b.pb(anss[out[a][i]]);
	}
	sort(b.begin(),b.end());
	ll ans=0;
	for(ll i=0;i<b.size();i++){
		if(b[i]==ans){
			ans++;
		}
	}
	return ans;
}
void dfsw(ll a){
	for(ll i=0;i<out[a].size();i++){
		dfsw(out[a][i]);
	}
	anss[a]=mexx(a);
}
void dfse(ll a){
	vis[a]=1;
	ll v=in[a];
	if(vis[v]){
		return ;
	}
	anss[v]=mexx(v);
	dfse(v);
}
bool good(ll n){
	for(ll i=0;i<n;i++){
		if(mexx(i)!=anss[i]){
			return 0;
		}
	}
	return 1;
}
int main(){
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>in[i];
		in[i]--;
		out[in[i]].pb(i);
	}
	dfs(0);
	dfss(y);
	for(ll i=0;i<n;i++){
		barg[in[i]]=1;
	}
	for(ll i=0;i<n;i++){
		barg[i]=!barg[i];
	}
	for(ll i=0;i<n;i++){
		if(dor[i]){
			for(ll j=0;j<out[i].size();j++){
				ll v=out[i][j];
				if(dor[v]==0){
					dfsw(v);	
				}
			}
		}
	}
	for(ll i=0;i<40;i++){
		fill(vis,vis+maxn,0);
		anss[y]=i;
		dfse(y);
		if(good(n)){
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
}


Measured memory_bytes: 13952
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind
{
    vector<int> par, rank;
    UnionFind(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; ++i)
            par[i] = i;
    }
    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x), ry = root(y);
        if (rx == ry)
            return;
        if (rank[ry] > rank[rx])
            par[rx] = ry;
        else
            par[ry] = rx;
        if (rank[rx] == rank[ry])
            rank[rx]++;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
};

vector<ll> fac, inv, finv;

void initcom()
{
    fac = inv = finv = vector<ll>(1e6);
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (ll i = 2; i < 1e6; ++i)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll com(int n, int k)
{
    if (n < 0 || k < 0)
        return 0;
    if (n < k)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}
ll mopow(ll a, ll x, ll mod)
{
    ll res = 1;
    while (x > 0)
    {
        if (x & 1)
            res = res * a % mod;
        a = a * a % mod;
        x >>= 1;
    }
    return res;
}

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> p(n),c(n);
    for(int i=0;i<n;++i) cin>>p[i],--p[i];
    for(int i=0;i<n;++i) cin>>c[i];
    
    vector<vector<ll> > next(60,vector<ll>(n));
    vector<vector<ll> > val(60,vector<ll>(n));
    vector<vector<ll> > all(60,vector<ll>(n));
    for(int i=0;i<n;++i){
        next[0][i]=p[i];
        val[0][i]=all[0][i]=c[i];
    }
    for(int d=0;d+1<60;++d){
        for(int i=0;i<n;++i){
            next[d+1][i]=next[d][next[d][i]];
            val[d+1][i]=val[d][i]+val[d][next[d][i]];
            all[d+1][i]=max(all[d][i],val[d][i]+all[d][next[d][i]]);
        }
    }
    ll ans=-INF;
    for(int v=0;v<n;++v){
        ll sum=0;
        ll offset=v;
        for(int d=0;d<60;++d){
            if(k&(1LL<<d)){
                ans=max(ans,sum+all[d][offset]);
                sum+=val[d][offset];
                offset=next[d][offset];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;

ll min(ll a,ll b){
    return (a<=b) ? a : b ;
}

ll max(ll a,ll b){
    return (a<=b) ? b : a ;
}


int main() {

    ll n,a,b,c,d,e ;
    cin >> n >> a >> b >> c >> d >> e ;
    
    vector<ll> num(6) ;
    num[0] = n ;

    ll time = 0 ;
    ll MIN = min({a,b,c,d,e});
    time = (n+MIN-1)/MIN ;
    cout << time+4 << endl ;

    return 0 ;
}


Measured memory_bytes: 3604
use std::io;
use std::io::prelude::*;
use std::io::BufReader;

fn main() {
    let mut lines = BufReader::new(io::stdin()).lines().into_iter();
    let line = lines.next().unwrap().unwrap();
    let n: usize = line.parse().unwrap();
    let mut v: Vec<usize> = lines
        .next()
        .unwrap()
        .unwrap()
        .split(' ')
        .map(|x| x.parse().unwrap())
        .collect();
    v.sort_by(|a, b| b.cmp(a));
    let mut ans = v.iter().take(n + 1 >> 1).sum::<usize>() * 2 - v[0];
    if n & 1 == 1 {
        ans -= v[(n + 1 >> 1) - 1];
    }
    println!("{}", ans);
}

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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    ll n, w, a, b;
    cin >> n >> w;
    vector<ll> A(w + 1, 0);
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        for(int j = w - a; j >= 0; j--)
            A[j + a] = max(A[j + a], A[j] + b);
    }
    cout << A[w] << "\n";
    return 0;
}


Measured memory_bytes: 1024
import math
A,B = map(int,input().split())
a = A / 0.08
b = B / 0.1
#print(a,b)
if a > b:
    if int(a * 0.1) == B:
        print(math.ceil(a))
    else:
        print(-1)
elif b > a:
    if int(b * 0.08) == A:
        print(math.ceil(b))
    else:
        print(-1)
else:
    print(math.ceil(a))


Measured memory_bytes: 38724
from collections import defaultdict,deque
v,n=map(int,input().split())
n+=v-1
es=[[int(x)-1for x in input().split()]for _ in range(n)]
outs=defaultdict(list)
ins=defaultdict(int)
for v1,v2 in es:
    outs[v1].append(v2)
    ins[v2]+=1
q=deque(v1 for v1 in range(v)if ins[v1]==0)
res=[]
p=[0]*v
while q:
    v1=q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        ins[v2]-=1
        if ins[v2]==0:
            q.append(v2)
            p[v2]=v1+1
for t in p:print(t)

Measured memory_bytes: 52488
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long 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;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    int x=800*N;
    int y=(N/15)*200;
    cout << x-y << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
using P = pair<int,int>;
const int INF=1e9;
const int di[]={-1,0,1,0};
const int dj[]={0,-1,0,1};
int main(){
  int h,w;
  cin>>h>>w;
  int si,sj;
  cin>>si>>sj;
  int ti,tj;
  cin>>ti>>tj;
  --si;--sj;--ti;--tj;
  vector<string>s(h);
  rep(i,h)cin>>s[i];
  vector<vector<int>>dist(h,vector<int>(w,INF));
  deque<P>q;
  dist[si][sj]=0;
  q.emplace_back(si,sj);
  while(!q.empty()){
    int i=q.front().first;
    int j=q.front().second;
    int d=dist[i][j];
    q.pop_front();
    if(dist[i][j]!=d)continue;
    rep(v,4){
      int ni=i+di[v],nj=j+dj[v];
      if(ni<0||ni>=h||nj<0||nj>=w)continue;
      if(s[ni][nj]=='#')continue;
      if(dist[ni][nj]<=d)continue;
      dist[ni][nj]=d;
      q.emplace_front(ni,nj);
    }
    for(int ei=-2;ei<=2;++ei){
      for(int ej=-2;ej<=2;++ej){
        int ni=i+ei,nj=j+ej;
        if(ni<0||ni>=h||nj<0||nj>=w)continue;
        if(s[ni][nj]=='#')continue;
        if(dist[ni][nj]<=d+1)continue;
        dist[ni][nj]=d+1;
        q.emplace_back(ni,nj);
      }
    }
  }
  int ans=dist[ti][tj];
  if(ans==INF)ans=-1;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int ans = s.length();
  for (int i = 0; i < (int)s.length() - 1; ++i)
  {
    if (s[i] != s[i + 1])
    {
      ans = min(ans, max(i + 1, (int)s.length() - i - 1));
    }
  }
  cout << ans << endl;
}

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

int main(){
	int w,h,n;
	int x1,x2,y1,y2;
	int x,y,a;
	
	cin >> w >> h >> n;
	x1 = y1 = 0;
	x2 = w;y2 = h;
	while(n--){
		cin >> x >> y >> a;
		if(a==1&&x1<x) x1 = x;
		else if(a==2&&x2>x) x2 = x;
		else if(a==3&&y1<y) y1 = y;
		else if(a==4&&y2>y) y2 = y;
	}
	int ans = (y2-y1)*(x2-x1);
	if(y2>y1&&x2>x1) cout << ans;
	else cout << 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,pas,zx,xc;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	pas=min(a,abs(a-b));
	a%=b;
	pas=min(pas,a);
	pas=min(pas,b-a);
	cout<<pas;
	return 0;
}

Measured memory_bytes: 3644
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))

    a = [0] * m
    c = [0] * m

    for i in range(m):
        a[i], _ = list(map(int, readline().split()))
        t = list(map(int, readline().split()))
        for x in t:
            c[i] += (1 << (x - 1))

    dp = [[INF] * (1 << n) for _ in range(m)]
    dp[0][c[0]] = a[0]

    for i in range(m):
        dp[i][0] = 0

    for i in range(1, m):
        key = c[i]
        price = a[i]
        for j in range(1 << n):
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

    ans = dp[-1][-1]
    if ans == INF:
        ans = -1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 196360
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector <char> v;
vector<int> num;
char cam[51][51];
int main(){
  int N;
  string s = "Three";

  cin >> N;

  for (int i = 0; i<N;i++){
    char c;

    cin >>c;
    if (c == 'Y')s="Four";
  }
  cout << s<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
L = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A.sort(reverse = True)

dp = [0] + ([-1]*N)
for i in range(1, N+1):
    for a in A:
        if L[a] <= i:
            dp[i] = max(dp[i], dp[i-L[a]] * 10 + a)
print(dp[-1])

Measured memory_bytes: 14692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  
  ll count_c=0;
  ll count_d=0;
  ll count_c_d=0;
  
  ll x=C*D;
  ll c=C;
  ll d=D;
  
  if(c<d){
    ll tmp=c;
    c=d;
    d=tmp;
  }
  
  ll r=c%d;
  while(r!=0){
    c=d;
    d=r;
    r=c%d;
  }
  
  ll LCM=x/d;
  
  ll start_c=(A+C-1)/C;
  ll start_d=(A+D-1)/D;
  ll start_c_d=(A+LCM-1)/LCM;
  
  count_c=B/C-start_c+1;
  count_d=B/D-start_d+1;
  count_c_d=B/LCM-start_c_d+1;

  ll ans=B-A+1-(count_c+count_d-count_c_d);
  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>

int main()
{
    long n;
    std::cin >> n;
    for (long i = sqrt(n); i >= 1; i--) {
        if (n % i == 0) {
            std::cout << i + n / i - 2 << std::endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,int>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i]};
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}

int main() {
  IN(ll, K);
  IN(ll, S);
  int count = 0;
  REP(i, K+1){
    REP(j, K+1){
      if (i + j <= S && S - (i+j) <= K)
        count++;
    }
  }
  OUT(count);
}

Measured memory_bytes: 256
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, K = input_number_list()
    ls = [0] * N

    for i in range(K):
        d = input_number()
        L = input_number_list()
        for l in L:
            ls[l - 1] = 1
    print(ls.count(0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a;
  a = 0;
  in(n);
  vector<ll> v(n), c(n);
  rep(i, n)
    in(v[i]);
  rep(i, n)
    in(c[i]);
  rep(i, n){
    if(v[i] - c[i] > 0)
      a = a + v[i] - c[i];
  }
  out(a);
  memi;
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 10

#define N 100005
int arr[N];
void Eratosthenes(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
}

int main(){

    Eratosthenes();
    int valid[100005];
    REP(i,100005) valid[i] = 0;

    for(int i=3;i<=100005; i+=2){
        if(arr[i] && arr[(i+1)/2]){
            valid[i]++;
        }
    }

    REP(i,100004) valid[i+1] += valid[i];

    int Q; cin >> Q;

    REP(i,Q){
        int l,r; cin >> l >> r;
        cout << valid[r]-valid[l-1] << endl;
    }


    return 0;

}


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

string add(string a,string b){
	if(a.size()<b.size())swap(a,b);
	while(a.size()>b.size())b="0"+b;
	int c=0;
	for(int i=a.size()-1;i>=0;i--){
		a[i]+=(b[i]-'0'+c);
		if(a[i]>'9'){
			a[i]-=10;
			c=1;
		}
		else c=0;
	}
	if(c)a="1"+a;
	return a;
}

string x10(string a,int n){
	while(n--)a+="0";
	return a;
}

string mlt(string a,string b){
	string tmp[10];
	tmp[0]="0";
	tmp[1]=a;
	for(int i=2;i<=9;i++)tmp[i]=add(tmp[i-1],a);
	string res=tmp[b[b.size()-1]-'0'];
	for(int i=1;i<b.size();i++){
		res=add(res,x10(tmp[b[b.size()-1-i]-'0'],i));
	}
	return res;
}

string pow(string a,int n){
	string res=a;
	for(n--;n--;)res=mlt(res,a);
	return res;
}

int main(){
	
	string n,t,s;
	while(cin>>n>>t){
		cin>>s;
		vector<string>V;
		string tmp="";
		for(int i=0;true;){
			if(s[i]=='+'){
				V.push_back(tmp);
				tmp="";
			}
			else{
				tmp+=s[i];
			}
			i++;
			if(i>=s.size()){
				V.push_back(tmp);
				break;
			}
		}
		for(int i=0;i<V.size();i++){
			if(V[i][0]=='n' && V[i][2]=='0')V[i]="1";
			else if(V[i][0]=='n')V[i]=pow(n,V[i][2]-'0');
		}
		string ans="0";
		for(int i=0;i<V.size();i++){
			ans=add(ans,V[i]);
		}
		ans=mlt(ans,t);
		if(ans.size()<10)cout<<ans<<endl;
		else if(ans=="1000000000")cout<<ans<<endl;
		else cout<<"TLE\n";
	}
	
	return 0;
}


Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var pp = new int[num];
        for(var i = 0; i < num; i++)
            if (ar[i] % 4 == 0)
                pp[i] = 2;
            else if (ar[i] % 2 == 0)
                pp[i] = 1;
        var ct4 = pp.Count(v => v == 2);
        var ct2 = pp.Count(v => v == 1);
        var res = num - 2 * ct4 - ct2 - (ct2 == 0 ? 1 : 0);
        WriteLine(res <= 0 ? "Yes" : "No");
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

Measured memory_bytes: 19040
n = int(input())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
dif = dict()
data.sort()
for i in range(n):
    for j in range(i+1, n):
        x = data[i][0] - data[j][0]
        y = data[i][1] - data[j][1]
        if (x,y) in dif:
            dif[(x,y)] += 1
        else:
            dif[(x,y)] = 1
if len(dif.keys()) == 0:
    print(n)
    exit()
print(n - max([dif[i] for i in dif.keys()]))
        
        



Measured memory_bytes: 3188