akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){
  string s;
  cin >> s;
  int q;
  cin >> q;
  char s1[200000],s2[200000];
  int tail1 = 0, tail2 = 0, mode = 1;
  rep(i,q){
    int t;
    cin >> t;
    if(t == 1){
      if(mode == 1) mode = 2;
      else mode = 1;
    }
    else{
      int f;
      char c;
      cin >> f >> c;
      if((mode+f)%2 == 0)s1[tail1++] = c;
      else s2[tail2++] = c;
    }
  }

  if(mode == 1){
    rep(i,tail1)cout << s1[tail1-1-i];
    rep(i,s.length())cout << s[i];
    rep(i,tail2)cout << s2[i];
    cout << endl;
  }
  else{
    rep(i,tail2)cout << s2[tail2-1-i];
    rep(i,s.length())cout << s[s.length()-1-i];
    rep(i,tail1)cout << s1[i];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
/********************************************************************************
	
	Code by a weak man named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

int tot;
int pri[5010];
int chk[5010];

inline void Sieve(int n) {
	chk[1] = 1;
	for(int i = 2; i <= n; i++) {
		if(!chk[i]) pri[++tot] = i;
		for(int j = 1; j <= tot; j++) {
			if(i * pri[j] > n) break;
			chk[i * pri[j]] = 1;
			if(i % pri[j] == 0) break;
		}
	}
}

inline int check(int x) {
	if(x <= 5000) return !chk[x];
	for(int *p = pri + 1;; ++p) {
		if((*p) * (*p) > x) return 1;
		if(x % (*p) == 0) return 0;
	}
}

vector<int>to[210];
int vis[210];
int arr[210];
int p[210];
int tim, N;

inline int Try(int x) {
	for(auto u : to[x]) {
		if(arr[u] == tim) continue;
		arr[u] = tim;
		if(!vis[u] || Try(vis[u])) {
			vis[u] = x;
			vis[x] = u;
			return 1;
		}
	} return 0;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif

	Sieve(5000);
	int n = ri, ce = 0, co = 0;

	for(int i = 1; i <= n; i++) {
		int x = ri;
		if(p[N] == x) --N;
		else p[++N] = x;
		p[++N] = x + 1;
	}

	for(int i = 1; i <= N; i++) 
		p[i] & 1 ? ++co : ++ce;

	for(int i = 1; i <= N; i++)
		for(int j = i + 1; j <= N; j++)
			if(((p[i] ^ p[j]) & 1) && check(p[j] - p[i]))
				to[i].push_back(j), to[j].push_back(i);

	int res = 0;
	for(int i = tim = 1; i <= N; ++i, ++tim)
		if((p[i] & 1) && Try(i))
			--co, --ce, ++res;

	res += (co / 2 + ce / 2) << 1;
	if((co | ce) & 1) res += 3;

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 384
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    const k  = (a + b) / 2;
    if( Number.isInteger(k) ){
        console.log(k);
    }else {
        console.log('IMPOSSIBLE');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(all(a));
  vector<bool> flg(a[n - 1] + 1, false);
  REP(i, n) {
    if (!flg[a[i]]) {
      int k = 2 * a[i];
      while (k <= a[n - 1]) {
        flg[k] = true;
        k += a[i];
      }
    }
  }
  int ans = 0;
  REP(i, n) {
    if (i == 0) {
      if (!flg[a[i]] && a[i] != a[i + 1]) {
        ans++;
      }
    } else if (i == n - 1) {
      if (!flg[a[i]] && a[i] != a[i - 1]) {
        ans++;
      }
    } else if (!flg[a[i]] && a[i] != a[i - 1] && a[i] != a[i + 1]) {
      ans++;
    }
  }

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


Measured memory_bytes: 4012
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;
  if(s=="AAA"||s=="BBB")No;
  else Yes;
  return 0;
}


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

vector<int> edges[100010];
int dp[100010];

const int MOD = 1000000007;
int mult_mod(int a, int b){
	return (long)a * b % MOD;
}

pair<int, int> dfs(int i, int parent){
	int all_white = 1;
	int involve_black = 0;
	for(auto x: edges[i]) {
		if(x == parent) continue;
		pair<int, int> p = dfs(x, i);
		int temp = all_white;
		all_white = mult_mod(all_white, p.second);
		involve_black = (mult_mod(temp, p.first) + mult_mod(involve_black, p.first + p.second)) % MOD;
	}
	return make_pair(all_white, (all_white + involve_black) % MOD);
}

int main(){
	int n, x, y;
	scanf("%d", &n);
	for(int i = 0; i < n-1; i++) {
		scanf("%d%d", &x, &y);
		edges[x-1].push_back(y-1);
		edges[y-1].push_back(x-1);
	}
	int p = 0, temp = -1;;
	for(int i=0; i < n; i++) {
		if(temp < (int)edges[i].size()) {
			temp = (int)edges[i].size();
			p = i;
		}
	}
	pair<int, int> res = dfs(p, -1);
	printf("%d\n", (res.first + res.second) % MOD);
}

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

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

long findIndex(vector<long> vec, long value)
{
    vector<long>::iterator iter = std::find(vec.begin(), vec.end(), value);
    size_t index = distance(vec.begin(), iter);
    if(index == vec.size())
    {
        return -1;
    }
    return index;
}

int main()
{
    long a, b, k;
    cin >> a >> b >> k;

    vector<long> vec;
    for (long i = a; i <= min(a+k-1, b); i++)
    {
        vec.push_back(i);
    }

    for (long i = b; i >= max(b-k+1, a); i--)
    {
        if (findIndex(vec, i) == -1)
        {
            vec.push_back(i);
        }
    }
    
    sort(vec.begin(), vec.end());
    for (long i = 0; i < vec.size(); i++)
    {
        cout << vec[i] << endl;
    }
}

Measured memory_bytes: 256
while True:
    n=input()
    if n==0:break
    cnt=0
    L=[input() for i in range(n)]
    for j in range(n):
        for i in range(n-j-1):
            if L[i]>L[i+1]:
                L[i],L[i+1]=L[i+1],L[i]
                cnt+=1
    print cnt

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

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  bool found = false;
  if(e - d > k)found = true;
  if(e - c > k)found = true;
  if(e - b > k)found = true;
  if(e - a > k)found = true;
  if(d - c > k)found = true;
  if(d - b > k)found = true;
  if(d - a > k)found = true;
  if(c - b > k)found = true;
  if(c - a > k)found = true;
  if(b - a > k)found = true;
  if(found) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

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

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

int main() {
    vector<int> a(3);
    vector<int> b(3);

    rep(i, 3) {
        cin >> a.at(i) >> b.at(i);
    }
    vector<int> sum(4);
    for (int i = 0; i < 3; i++) {
        sum.at(a.at(i) - 1)++;
        sum.at(b.at(i) - 1)++;
    }

    string ans = "YES";
    for (int i = 0; i < 4; i++) {
        if (sum.at(i) == 1 || sum.at(i) == 2) {
            continue;
        }
        else {
            ans = "NO";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
const int mx=1e5+4;
int weight[103+2],values[103+2];
ll dp[mx];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,cap;
    cin >> n >> cap;
    ll total_cap=0;
    for(int i=0;i<n;i++){
        cin >> weight[i] >> values[i];
        total_cap+=values[i];
    }
    for(int i=0;i<=total_cap;i++)
        dp[i]=1e9+7;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=total_cap;j>=values[i];j--){
           // cout << j << " " << values[i]  << " " <<  j-values[i] << endl;
            dp[j]=min(dp[j],dp[j-values[i]]+weight[i]);
        }
    }   
    ll ans=0;
    for(int i=0;i<=total_cap;i++){
        //cout << dp[i] << endl;
        if(dp[i]<=cap){
            ans=i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s,t;
	cin >>n >>s >>t;
	
	int mx=0;
	rep2(i,1,n+1){
		string p1=t.substr(0,i);
		string p2=s.substr(n-i,i);
		if(p1==p2) mx = max(mx,i);
	}
	
	cout << 2*n-mx << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=100010,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const db eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

int k,n;

#ifdef FILE
const int RS=1<<20;
char buf[RS],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,RS,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	k=read();
	if(k==1)
	{
		printf("1\n1\n");
		return 0;
	}
	n=(k-1>>2)+1<<1;
	printf("%d\n",n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			int val=(i+j-2)%n+(i&1^1)*n+1;
			printf("%d ",val>k?val-n:val);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx4 10005
#define mx5 100005
#define mx52 200005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[mx4][101] = {};

ll compute(string k, int d) {
    ll ans = 0;
    int tag = 0;
    int l = k.length();
    for (int i = 0; i < l; i++) {
        for (int digit = 0; digit < k[i]-'0'; digit++)
            ans = (ans + dp[l-i-1][(d - (digit + tag) % d) % d]) % mod;
        tag = (tag + (k[i] - '0') % d) % d;
    }
    if (tag != 0) {
        ans = (ans + mod - 1) % mod;
    }
    return ans;
}

int main() {
    nfs
    int i, d, l;
    string k;
    cin >> k >> d;
    l = k.length();
    dp[0][0] = 1;
    
    for (int i = 1; i <= l; i++)
        for (int r = 0; r < d; r++)
            for (int digit = 0; digit < 10; digit++)
                dp[i][r] = (dp[i][r] + dp[i-1][(r + (d - digit%d)%d)%d]) % mod;
    
    cout << compute(k, d);
}

Measured memory_bytes: 11580
/*
2
10 100
100 270
2
10 100
100 280
3
100 150
10 360
40 450
3
100 150
10 360
40 440
2
100 10
50 200
2
100 100
50 110
1
15 10
4
1 10
2 20
3 100
90 200
0
*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>

using namespace std;

int INF;

int n;
int p[100];
int t[100];
int f[100][5];

int main(){
    while (1){
        scanf("%d",&n);
        if (n==0) return 0;
        for (int i=1;i<=n;i++) scanf("%d%d",&p[i],&t[i]);
        memset(f,127,sizeof(f));
        INF=f[0][0];
        if (p[1]<=t[1]) f[1][1]=p[1];
        for (int i=2;i<=n;i++){
                if ((f[i-1][1]!=INF)&&((t[i]-t[i-1])>=(p[i]+p[i-1]*2))) f[i][1]=min(f[i][1],f[i-1][1]+(p[i]+p[i-1]));
                if ((f[i-1][2]!=INF)&&((t[i]-t[i-1])>=(p[i]+p[i-1]*3))) f[i][1]=min(f[i][1],f[i-1][2]+(p[i]+p[i-1]));
                if ((f[i-1][3]!=INF)&&((t[i]-t[i-1])>=(p[i]+p[i-1]*4))) f[i][1]=min(f[i][1],f[i-1][3]+(p[i]+p[i-1]));
                if ((f[i-1][1]!=INF)&&((t[i]-t[i-1])>=abs(p[i]-p[i-1])*2)) f[i][2]=f[i-1][1]+abs(p[i]-p[i-1]);
                if ((f[i-1][2]!=INF)&&((t[i]-t[i-1])>=abs(p[i]-p[i-1])*3)) f[i][3]=f[i-1][2]+abs(p[i]-p[i-1]);
        }
        if (min(f[n][1],min(f[n][2],f[n][3]))==INF){
                printf("NG ");
                for (int i=1;i<=n;i++) if (min(f[i][1],min(f[i][2],f[i][3]))==INF){
                        printf("%d\n",i);
                        break;
                }
        }
        else{
                printf("OK %d\n",min(f[n][1],min(f[n][2],f[n][3]))+p[n]);
        }
    }
    return 0;
}

Measured memory_bytes: 1028
t[9999],W,N,a,b,i;main(c){for(;scanf("%d%d",&W,&N)-1;printf("Case %d:\n%d\n%d\n",c++,t[W],i),bzero(t,W*9)){for(;N--&&scanf("%d,%d",&a,&b);)for(i=W;i>=b;i--)t[i]=fmax(t[i],t[i-b]+a);for(i=0;t[++i]-t[W];i);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int dp[100001];

int totalCost(int h[], int n) {
	if (n == 0)
		return 0;
	if (n == 1)
		return abs(h[1] - h[0]);
	if (n < 0)
		return INT_MAX;
	if (dp[n] != -1)
		return dp[n];
	int step1 = abs(h[n] - h[n-1]) + totalCost(h, n-1);
	int step2 = abs(h[n] - h[n-2]) + totalCost(h, n-2);
	return dp[n] = min(step1, step2);
}

void solve() {
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
    	cin >> h[i];
    	dp[i] = -1;
    }
    cout << totalCost(h, n-1);
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 13032
<?php
const INI_INF = 1001001001;
const MOVE_CROSS = [
    [-1,  0], // 左
    [ 0, -1], // 上
    [ 1,  0], // 右
    [ 0,  1], // 下
];

class Pair {
    public $x;
    public $y;

    function __construct($x, $y) {
        $this->x = $x;
        $this->y = $y;
    }
}

# 入力
list($h, $w) = explode(' ', trim(fgets(STDIN)));

$maze = [];
for ($i=0; $i<$h; $i++) {
    $maze[$i] = trim(fgets(STDIN));
}

$ans = 0;
for ($si=0; $si<$h; $si++) {
    for ($sj=0; $sj<$w; $sj++) {
        if ($maze[$si][$sj] == '#') { continue; }
        $queue = [];
        $dist = array_fill(0, $h, array_fill(0, $w, INI_INF));
        $updateFunc = function($di, $dj, $d) use($maze, &$dist, &$queue) {
            if ($dist[$di][$dj] != INI_INF) { return; }
            $dist[$di][$dj] = $d;
            array_push($queue, new Pair($di, $dj));
        };

        $updateFunc($si, $sj, 0);

        while (!empty($queue)) {
            //echo json_encode($queue)."\n";
            $cell = array_shift($queue);
            foreach (MOVE_CROSS as list($dx, $dy)) {
                $nx = $cell->x + $dx;
                $ny = $cell->y + $dy;
                //echo sprintf("move to %d, %d, %s \n",$nx, $ny, json_encode($maze[$nx][$ny]));
                if ( !isset($maze[$nx][$ny]) ) { continue; }
                if ($maze[$nx][$ny] == '#') { continue; }
                $updateFunc($nx, $ny, $dist[$cell->x][$cell->y]+1);
            }
        }

        // foreach ($dist as $distt) {
        //     echo implode(',', $distt)."\n";
        // }
        // echo "\n";

        for ($i=0; $i<$h; $i++) {
            for ($j=0; $j<$w; $j++) {
                if ( $dist[$i][$j] == INI_INF) { continue; }
                $ans = max($dist[$i][$j], $ans);
            }
        }
    }
}

echo "$ans\n";

Measured memory_bytes: 4984
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    

n,m=map(int,input().split())
p=[int(i)-1 for i in input().split()]
tree=UnionFind(n)
for _ in range(m):
    x,y=map(int,input().split())
    tree.union(x-1,y-1)

ans=0
for i in range(n):
    #print(p[i],tree.members(i))
    if tree.same(p[i],i):
        ans+=1
print(ans)

Measured memory_bytes: 88556
x1,y1,x2,y2 = map(int, input().split())
x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x3 - (y3-y2)
y4 = y3 + (x3-x2)
print(x3,y3,x4,y4)


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

int main(){
	int n, m, l;
	int i, j, k;
	int A[100][100], B[100][100];
	long  C[100][100]={0};
	
	cin >> n >> m >> l;
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	
	for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			for(k = 0; k < m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			cout << C[i][j];
			if(j != l - 1){
			cout << " ";
			}
		}
		cout <<endl;
	}
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<ll>> E(N);
    for(int i = 0; i < N - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    vector<ll> V(N, 0);
    for(int i = 0; i < Q; i++) {
        ll p, x;
        cin >> p >> x;
        p--;
        V[p] += x;
    }
    vector<int> L(N, 0);
    queue<ll> q;
    q.push(0);
    L[0] = 1;
    while(!q.empty()) {
        ll u = q.front();
        q.pop();
        for(ll v : E[u]) {
            if(L[v] == 0) {
                L[v] = 1;
                V[v] += V[u];
                q.push(v);
            }
        }
    }
    for(int i = 0; i < N; i++) {
        if(i == 0)
            cout << V[i];
        else
            cout << " " << V[i];
    }
    cout << endl;
}

Measured memory_bytes: 19680
//Patwari26
//#include template<t> as mine
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,d,x,y;
    cin>>n>>d;
    d*=d;
    ll ans=0;
    rep(i,0,n-1){
        cin>>x>>y;
        if((x*x+y*y<=d))
            ans++;
    }
    cout<<ans<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

Measured memory_bytes: 3656
N, M = map(int, raw_input().split())
matrix = []
array = []
for n in range(N):
    tmp = map(int, raw_input().split())
    if len(tmp) > M:
        print 'error'
    matrix.append(tmp)

for m in range(M):
    tmp = input()
    array.append(tmp)

for n in range(N):
    multi = 0
    for m in range(M):
        multi += matrix[n][m] * array[m]
    print multi

Measured memory_bytes: 6568
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int MAXN=3010;

ll dp[MAXN][MAXN][4],a[MAXN][MAXN],INF=1e18,n,m;
bool vis[MAXN][MAXN][4];

ll solve(int x, int y, int did){
	if(x==n||y==m) return x==n-1||y==m-1?0:-INF;
	ll &r=dp[x][y][did];
	if(vis[x][y][did])return r;
	vis[x][y][did]=1;
	
	r=max(solve(x+1,y,0), solve(x,y+1,did));
	
	//use
	if(did<3) r=max(r,a[x][y]+max(solve(x+1,y,0),solve(x,y+1,did+1)));
	return r;
}

int main(){FIN;
	int k; cin>>n>>m>>k;
	fore(i,0,k){
		int x,y,w; cin>>x>>y>>w; x--; y--;
		a[x][y]=w;
	}
	
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,0,0)<<"\n";
}

Measured memory_bytes: 392724
#include <bits/stdc++.h>
#define ll long long
#define foi(n) for(ll i=0;i<n;i++)
#define foj(n) for(ll j=0;j<n;j++)
#define pb push_back
using namespace std;

ll a[200005];
vector<ll> v[200005];
bool visited[200005]={false};

void bfs(ll i,ll cnt){
	visited[i]=true;
	a[i]=cnt;
	foj(v[i].size()){
		if(!visited[v[i][j]]) bfs(v[i][j],cnt);
	}
}

int main(){
 
 ll n,m;
 cin>>n>>m;
 
 ll cnt=1;
 while(m--){
 	ll x,y;
 	cin>>x>>y;
 	v[x].pb(y);
 	v[y].pb(x);
 	
 }
 for(ll i=1;i<=n;i++){
 	if(!visited[i]) {bfs(i,cnt); cnt++;}
 }
 sort(a+1,a+n+1);
 map<ll,ll> ma;
 foi(n){
 	ma[a[i+1]]++;
 }
 
 ll ans=0;
 for(auto it:ma){
 	ans=max(ans,it.second);
 }
 cout<<ans<<endl;
 
 
  
}

Measured memory_bytes: 25640
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int dp[100010];
int h[100005];
const int INF = 1e9 * 2;
int main() {
  int n,k;
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> h[i];
  fill(dp,dp+n+1,INF);

  dp[0] = 0;

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

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


Measured memory_bytes: 1024
#include <stdio.h>
#define N 101
void Search(int);
 
int num,G[N][N],d[N],cnt=0,k=0;
int f[N] = {0};
	 
	  
int main(void){
	int i,j,k,l,u,a,t;
	
	for(i = 0;i < num;i++){
		d[i] = 0;
	}
		
	scanf("%d",&num);
	
	for(i = 0;i <= num;i++){
		for(j = 0;j <= num;j++){
			G[i][j] = 0;
		}
	}
	
	for(i = 0;i < num;i++){
		scanf("%d %d ",&k,&u);
		for(j = 0;j < u;j++){
			scanf("%d",&a);
			G[k - 1][a - 1] = 1;
		}
	}
	
	for(i = 0;i < num;i++){
		if(d[i] == 0)
		Search (i);
	}
	
	for(i = 0;i < num;i++){
		printf("%d %d %d\n",i+1,d[i],f[i]);
	}
	
	return 0;
}
	 
	 
void Search(int u){
	int i,j,v;
	cnt++;
	d[u] = cnt;
	
	for(v = 0;v < num;v++){
		if(G[u][v] == 1 && d[v] == 0 ){
			Search(v);
		}
	}
	cnt++;
	f[u] = cnt;
}

Measured memory_bytes: 636
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const list1 = input.split('\n')[0].split(' ');

const list2 = input.split('\n')[1].split(' ');

const list3 = input.split('\n')[2].split(' ');

const list = list1.concat(list2).concat(list3);

const targetList = [1, 2, 3, 4];

const one = list.indexOf('1');
const two = list.indexOf('2');
const three = list.indexOf('3');
const four = list.indexOf('4')

const output = () => {
  if (one === -1 || two === -1 || three === -1 || four === -1) {
    console.log('NO');
  } else {
    list.splice(one, 1, 0);
    list.splice(two, 1, 0);
    list.splice(three, 1, 0);
    list.splice(four, 1, 0);

    var arr = list.filter(e => e !== 0);

    if (arr[0] === arr[1]) {
      console.log('NO');
    } else {
      console.log('YES')
    }
  }
};

output();


Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, k, r, b, mod = 1e9 + 7;
vector< vector< long long > > c( 2005, vector< long long >( 2005 ) );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	c[ 0 ][ 0 ] = 1;
	for( int i = 1; i <= 2004; ++i )
	{
		c[ i ][ 0 ] = c[ i ][ i ] = 1;
		for( int j = 1; j <= i - 1; ++j )
		{
			c[ i ][ j ] = ( c[ i - 1 ][ j - 1 ] + c[ i - 1 ][ j ] ) % mod;
		}
	}
	cin >> n >> k;
	b = k;
	r = n - k;
	for( int i = 1; i <= k; ++i )
	{
		cout << ( c[ r + 1 ][ i ] * c[ b - 1 ][ i - 1 ] ) % mod << "\n";
	}
	return 0;
}

Measured memory_bytes: 31744
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
	int N;
	string S;
	cin >> N >> S;

	vector<int> e(N), w(N), re(N), rw(N);
	for(int i = 1; i < N; ++i) {
		e[i] = e[i-1] + (S[i-1] == 'E' ? 1: 0);
		w[i] = w[i-1] + (S[i-1] == 'W' ? 1: 0);
	}
	for(int i = N-2; i >= 0; --i) {
		re[i] = re[i+1] + (S[i+1] == 'E' ? 1: 0);
		rw[i] = rw[i+1] + (S[i+1] == 'W' ? 1: 0);
	}

	int res = N;
	for(int i = 0; i < N; ++i) {
		res = min(res, w[i] + re[i]);
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 5380
def main():
    n = int(input())
    v = list(map(int, input().split()))
    d = v[0]
    x = v[1]
    a = []

    for i in range(n):
        a.append(int(input()))

    answer = 0

    for i in range(len(a)):
        eat = 0
        day = 1
        while day <= d:
            eat += 1
            day += a[i]
        answer += eat

    answer += x

    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const ll mod=998244353;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}


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

  ll n,s;
  cin >> n >> s;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<vector<ll> > dp(n+1, vector<ll>(s+1,0));
  dp[0][0] = pw(2,n);
  rep(i,n){
    rep(j,s+1){
      dp[i+1][j] = dp[i][j];
      if(j-a[i]>=0) dp[i+1][j] = ad(dp[i+1][j],dv(dp[i][j-a[i]],2));
      // cout << "i j " << i << " " << j << " " << dp[i+1][j] << endl;
    }
  }
  cout << dp[n][s] << endl;
  
  return 0;
    

}


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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe";
    }
    else{
        cout<<"safe";
    }
    
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

dp = [[-1, -1] for _ in range(N)]
dp[0] = [(1000, 0), (1000%A[0], 1000//A[0])]
for i in range(1, N):
    dp[i][0] = max((dp[i-1][0][0]+dp[i-1][0][1]*A[i], 0),
                   (dp[i-1][1][0]+dp[i-1][1][1]*A[i], 0))
    dp[i][1] = max((dp[i-1][0][1]+dp[i-1][0][0]//A[i], dp[i-1][0][0]%A[i]), 
                   (dp[i-1][1][1]+dp[i-1][1][0]//A[i], dp[i-1][1][0]%A[i]))[::-1]
# print(dp)
print(max(dp[-1])[0])

Measured memory_bytes: 9240
package main
 
import (
	"fmt"
)
 
func main() {
	var A string
	fmt.Scan(&A)
	s := []byte(A)
	var ans int
	var cnt [26]int
	for i := 0; i < len(s); i++ {
		ans += (i - cnt[s[i]-'a'])
		cnt[s[i]-'a']++
		// log.Println(ans)
	}
	fmt.Println(ans + 1)
}

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

using namespace std;
const int maxn = 200010 + 10;
typedef long long int lli;
typedef pair<int, int> pii;
struct node {
    int v, nxt;
};
node edge[200010];
int tot = 1;
int head[maxn];
short vis[maxn];

void addedge(int u, int v) {
    edge[tot] = (node) {v, head[u]};
    head[u] = tot++;
    edge[tot] = (node) {u, head[v]};
    head[v] = tot++;
}

int main() {
    memset(head, -1, sizeof(head));
    memset(vis, 0, sizeof(vis));
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        addedge(u, v);
    }
    queue<int> Que;
    Que.push(1);
    Que.push(n);
    vis[1] = 1;
    vis[n] = 2;
    while(!Que.empty()){
        int x = Que.front();
        Que.pop();
        for (int i = head[x]; i > 0; i = edge[i].nxt){
            int v = edge[i].v;
            if(vis[v] != 0) continue;
            vis[v] = vis[x];
            Que.push(v);
        }
    }
    int p = 0,q = 0;
    for(int i = 1;i <= n;i ++){
        if(vis[i] == 1) p ++;
        else            q ++;
    }
    if(p <= q)          printf("Snuke\n");
    else                printf("Fennec\n");
    return 0;
}

Measured memory_bytes: 2944
using System;

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string a = input.Split(' ')[0];
            string b = input.Split(' ')[1];
            if(a == b)
            {
                Console.WriteLine('H');
            }
            else if (a == "H" & b == "D")
            {
                Console.WriteLine('D');
            }
            else
            {
                Console.WriteLine('D');
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int x, res;
bool a[110];
int main() {
    cin >> x;
    if (!a[x]) {
        ++res;
        a[x] = 1;
    }
    
    cin >> x;
    if (!a[x]) {
        ++res;
        a[x] = 1;
    }
    
    cin >> x;
    if (!a[x]) {
        ++res;
        a[x] = 1;
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
$input = STDIN;

$n = intval(trim(fgets($input)));
$x = array_map("intval", explode(' ', trim(fgets($input))));
$y = array_map("intval", explode(' ', trim(fgets($input))));

$d1 = 0;    // Manhattan distance
$d2 = 0;    // Euclidean distance
$d3 = 0;    // Minkowski's distance(p = 3)
$d4 = [];    // Minkowski's distance(p = inf)

for ($i = 0; $i < $n; $i++) {
    $x_i = $x[$i];
    $y_i = $y[$i];
    
    $diff = abs($x_i - $y_i);
    $d1 += $diff;
    $d2 += $diff ** 2;
    $d3 += $diff ** 3;
    $d4[] = $diff;
}

$d2 = sqrt($d2);
$d3 = pow($d3, 1 / 3);
$d4 = max($d4);

print "{$d1}\n{$d2}\n{$d3}\n{$d4}\n";


Measured memory_bytes: 9384
houses = Array.new(4) { Array.new(3) { Array.new(10, 0) } }

n = gets.to_i
n.times do
  b, f, r, v = gets.split.map(&:to_i)
  houses[b - 1][f - 1][r - 1] += v
end

houses.each_with_index do |house, i|
  house.each do |floor|
    puts ' ' + floor.join(' ')
  end
  puts '#' * 20 unless i == houses.size - 1
end



Measured memory_bytes: 6884
#include<iostream>

#define mp  make_pair
#define pb  push_back

using namespace std;

typedef pair<int,int> pii;

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

int main(){
    char board[30][31],nextboard[30][30];
    int chk[30][30];
    
    for(int w,h;cin>>w>>h,w;){
        for(int i=0;i<h;i++) cin>>board[i];
        
        int man=0;
        for(int i=0;i<h;i++)for(int j=0;j<w;j++){
            if(board[i][j]!='.' && board[i][j]!='X' && board[i][j]!='#'){
                if     (board[i][j]=='E')    board[i][j]=0;
                else if(board[i][j]=='N')    board[i][j]=1;
                else if(board[i][j]=='W')    board[i][j]=2;
                else if(board[i][j]=='S')    board[i][j]=3;
                man++;
            }
        }
        
        int ans=-1;
        for(int t=0;t<=180;t++){
            if(man==0){ ans=t; break; }
            
            for(int i=0;i<h;i++)for(int j=0;j<w;j++)  chk[i][j]=777;
            
            for(int i=0;i<h;i++)for(int j=0;j<w;j++){
                if(board[i][j]>3) continue;
                for(int k=0,l=(board[i][j]+3)%4;k<4;k++,l=(l+1)%4){
                    int y=i+dy[l],x=j+dx[l];
                    if(0<=y && y<h && 0<=x && x<w && (board[y][x]=='.' || board[y][x]=='X')){
                        board[i][j]=l;
                        chk[y][x]=min(chk[y][x],(l+2)%4);
                        break;
                    }
                }
            }
            
            for(int i=0;i<h;i++)for(int j=0;j<w;j++)  nextboard[i][j]=board[i][j];
            
            for(int i=0;i<h;i++)for(int j=0;j<w;j++){
                if(board[i][j]>3) continue;
                int y=i+dy[board[i][j]],x=j+dx[board[i][j]];
                if(0<=y && y<h && 0<=x && x<w && chk[y][x]==(board[i][j]+2)%4){ 
                    if(board[y][x]=='.') nextboard[y][x]=board[i][j];
                    else if(board[y][x]=='X')    man--;
                    else{while(1);}
                    nextboard[i][j]='.';
                }
            }
            for(int i=0;i<h;i++)for(int j=0;j<w;j++)  board[i][j]=nextboard[i][j];
        }
        
        if(ans >= 0)    cout<<ans<<endl;
        else        cout<<"NA"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

const ll MAX=200001;
ll fac[MAX],inv[MAX],finv[MAX];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  FOR(i,2,MAX){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=(MOD-(MOD/i)*inv[MOD%i])%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(ll n,ll k){
  if(n<k){
    return 0;
  }
  else if(min(n,k)<0){
    return 0;
  }
  else{
    return ((fac[n]*finv[k])%MOD*finv[n-k])%MOD;
  }
}

int main() {
  COMinit();
  ll n,k;
  cin >> n >> k;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll ans=0;
  rep(i,n){
    ans+=(a[i]*COM(i,k-1))%MOD;
    ans%=MOD;
  }
  rep(i,n){
    ans-=(a[i]*COM(n-i-1,k-1))%MOD;
    ans%=MOD;
  }
  cout << (ans+MOD)%MOD << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int dp=1;
  for (int i=0;i<N;i++){
    if (dp>K){
      dp+=K;
    }
    else{
      dp*=2;
    }
  }
  cout << dp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    vector<int> a(5);
    rep(i,5)cin>>a.at(i);
    int ans=INF;
    do {
        int tmp=0;
        rep(i,4){
            tmp+=a.at(i);
            tmp=(tmp+9)/10*10;
        }
        tmp+=a.back();
        chmin<int>(ans, tmp);
    } while (next_permutation(all(a)));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static bool[] cardState = new bool[9];
        static int[] card = new int[9];
        static void Main(string[] args)
        {
            for (var i = 0; i < 3; i++)
            {
                var tmp = Console.ReadLine().Split(' ');
                for (var j = 0; j < 3; j++)
                {
                    card[3 * i + j] = int.Parse(tmp[j]);
                }
            }
            var n = int.Parse(Console.ReadLine());
            for (var i = 0; i < n; i++)
            {
                TakeNum();
            }

            Console.WriteLine(Bingo() ? "Yes" : "No");
        }

        private static void TakeNum()
        {
            var num = int.Parse(Console.ReadLine());
            for (var i = 0; i < 9; i++)
            {
                if (card[i] == num)
                {
                    cardState[i] = true;
                }
            }
        }
        private static bool Bingo()
        {
            return cardState[4] && (cardState[0] && cardState[8]
                || cardState[1] && cardState[7] || cardState[2]
                && cardState[6] || cardState[3] && cardState[5]) ||
                cardState[0] && (cardState[1] && cardState[2] || cardState[3] && cardState[6]) ||
                cardState[8] && (cardState[7] && cardState[6] || cardState[5] && cardState[2]);
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

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

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

int iabs(int x)
{
    if (x > 0) {
        return x;
    } else {
        return -x;
    }
}

int main(int argc, char const* argv[])
{
    int A, B, T;
    cin >> A >> B >> T;
    cout << (int)((T + 0.5) / A) * B << "\n";
}


Measured memory_bytes: 256
def main():
    N = int(input())
    if N == 0:
        print('0')
    l = []
    while N:
        l.insert(0, str(-(N % (-2))))
        if l[0] == '1':
            N -= 1
        N = N // -2
    print("".join(l))

if __name__ == "__main__":
    main()



Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int n;

void solve() {
  int one = n % 10;
  if (one == 3) {
    cout << "bon" << endl;
  } else if (one == 0 || one == 1 || one == 6 || one == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}

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


Measured memory_bytes: 3632
from heapq import *

def dijkstra(s, edges):
    dist = [INF] * len(edges)
    dist[s], h = 0, []
    heappush(h, (0, s))
    while (len(h)):
        dv, v = heappop(h)
        if dv > dist[v]:
            continue
        for u in edges[v]:
            if dv+1 < dist[u]:
                dist[u] = dv+1
                heappush(h, (dv+1, u))
    return dist

INF = 10**9
N, M = map(int, input().split())
es = [[] for i in range(N)]
for i in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    es[a].append(b)
    es[b].append(a)
f = [-1]*N
d = dijkstra(0, es)
for v in range(1, N):
    dv = d[v]
    for u in es[v]:
        if d[u] < dv:
            f[v] = u+1
print('Yes')
print(*f[1:], sep='\n')


Measured memory_bytes: 100604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define BIG 100000000
#define N 10000
int main()
{



   ll n;
   cin>>n;
   ll sum1,sum2;
   sum1=n/5;
   ll tot1=sum1*5;
   sum2=n/500;
   ll tot2=sum2*500;
   cout<<tot1+tot2<<endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int H,W,i,j;
	while(cin>>H>>W){
		if(H==0&&W==0){
			break;
		}
		for(i=0; i<H;i++){
			for(j=0;j<W;j++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
		return 0;
}



Measured memory_bytes: 3092
import sys

input = sys.stdin.readline

def main():
    ans = 0
    a, b, c = map(int, input().split())
    while a%2 == b%2 == c%2 == 0:
        ans += 1
        ta = a//2
        tb = b//2
        tc = c//2
        a = tb + tc
        b = ta + tc
        c = ta + tb
        if a == b == c:
            ans = -1
            break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<vector<int>> edges(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edges[a].emplace_back(b);
	}

	auto bfs = [&](int st) {
		
		// stからの最短経路 bfs, stが出てきたらloopにメモ
		vector<int> dist(N, INF), prev(N, -1), loop;
		dist[st] = 0;
		queue<int> que;
		que.emplace(st);
		while (!que.empty()) {
			int now = que.front(); que.pop();
			for (const auto &e : edges[now]) {
				if (e == st) loop.emplace_back(now);
				if (dist[e] != INF) continue;
				prev[e] = now;
				dist[e] = dist[now] + 1;
				que.emplace(e);
			}
		}

		vector<int> res;
		int cyc = INF, minidx = -1;
		for (const auto &e : loop) if(chmin(cyc, dist[e])) minidx = e;
		if (minidx == -1) res =  vector<int>(N + 1);
		else {
			res.emplace_back(minidx);
			while (dist[minidx] > 0) res.emplace_back(minidx = prev[minidx]);
		}

		return res;

	};

	vector<int> ans(N + 1);
	for (int st = 0; st < N; st++) {
		auto tmp = bfs(st);
		if (ans.size() > tmp.size()) ans = move(tmp);
	}

	if (ans.size() == N + 1) cout << -1 << "\n";
	else {
		cout << ans.size() << "\n";
		for (const auto &e : ans) cout << e + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int long long
#define ld long double
#define endl "\n"


signed main()
{
    FAST;
    int t;
    t=1;
    
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        
        cin>>l>>r>>d;
        
        temp = r/d - l/d;
        
        if(r%d==0 && l%d==0) temp++;
        
        cout<<temp<<endl;
        
       
    }
        
    
    
    
    
}

Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());

        long ans = 0;
        for(int i = 1; i <= n; i++)
        {
            if (i % 3 == 0) continue;
            if (i % 5 == 0) continue;
            ans = ans + i;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += A.at(i);
    }
    int P;
    P = sum / N;
    int ans1;
    ans1 = 0;
    for(int i = 0; i < N; i++){
        ans1 += (A.at(i) - P)*(A.at(i) - P);
    }
    int ans2;
    ans2 = 0;
    for(int i = 0; i < N; i++){
        ans2 += (A.at(i) - P - 1)*(A.at(i) - P - 1);
    }
    if(ans2 > ans1){
        cout << ans1 << endl;
    }
    else{
        cout << ans2 << endl;
    }
    return 0;
}

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

int main()
{
    int coun=0,n,N;
    string S,b,d="SUNMONTUEWEDTHUFRISAT";
    cin>>S;
    n=d.find(S);
    b=d.erase(0,n+3);
    n=d.length();
    cout<<(n/3)+1;
    
}


Measured memory_bytes: 256