akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

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

class Edge {
public:
	ll source, target, cost;
	Edge(ll source = 0, ll target = 0, ll cost = 0) :
		source(source), target(target), cost(cost) {}
	bool operator<(const Edge &e)const {
		return cost < e.cost;
	}
};
 
ll kruskal(ll N, vector<Edge> &edges) {
	ll totalCost = 0;
	sort(edges.begin(), edges.end());
	union_find uni(N);
	ll source, target;
	for (ll i = 0; i < edges.size(); i++) {
		Edge e = edges[i];
		if (!uni.same(e.source, e.target)) {
			totalCost += e.cost;
			uni.unite(e.source, e.target);
		}
	}
	return totalCost;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<Edge> es;
	rep(i,m){
        ll s, t, w;
		cin >> s >> t >> w;
        es.push_back(Edge(s, t, w));
	}
	cout << kruskal(n, es) << endl;
	return 0;
}


Measured memory_bytes: 5932
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
#define N 100005
#define fr(i,x,y) for(int i=x;i<=y;i++)
#define ms(x,y) memset(x,y,sizeof(x))
int dp[500][500];
int a[4][4]={{0,0,0,1},{0,0,1,1,},{1,1,1,0},{1,1,0,0}};
int x,y;
int dfs(int x,int y)
{
    if (dp[x][y]!=-1) return dp[x][y];
    int yy=0;
    fr(i,1,x/2)
        if (dfs(x-2*i,y+i)==0) {yy=1;}
    fr(i,1,y/2)
        if (dfs(x+i,y-2*i)==0) {yy=1;}
    if (yy) dp[x][y]=1;
    else dp[x][y]=0;
    return dp[x][y];
}
void doit()
{
    if (x>y)swap(x,y);
    if (x==0&&y==0) {puts("Brown");return;
}
    if (x==0&&y==1) {puts("Brown");return;
}
    if (x==0) {
        puts("Alice");
        return;
    }
    if (y==x||y==x-1||y==x+1) puts("Brown");else
    puts("Alice");

}
void pre()
{
    memset(dp,255,sizeof(dp));
    int n=50;

    fr(i,0,n)
        fr(j,0,n)
            dfs(i,j);
    fr(i,0,n){
        fr(j,0,n)
            printf("%d ",dp[i][j]);printf("\n");printf("\n");}
//    if (!dp[i][j])
//        printf("%d %d\n",i,j);
}
int main() {
    //pre();
    while (scanf("%d%d",&x,&y)!=EOF)
    {
        doit();
    }
    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
#define Maxn 100000
int head[Maxn+5],arrive[Maxn<<1|5],nxt[Maxn<<1|5],tot;
void add_edge(int from,int to){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	head[from]=tot;
}
int dis[Maxn+5];
bool vis[Maxn+5];
bool on[Maxn+5];
int pre[Maxn+5],suf[Maxn+5];
int n;
void min_dist(int s){
	memset(dis,0x3f,sizeof dis);
	memset(vis,0,sizeof vis);
	dis[s]=0;
	vis[s]=1;
	queue<int> q;
	q.push(s);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=head[u];i;i=nxt[i]){
			if(vis[arrive[i]]){
				continue;
			}
			vis[arrive[i]]=1;
			dis[arrive[i]]=dis[u]+1;
			q.push(arrive[i]);
		}
	}
}
void find_path(int s,int t){
	on[t]=1;
	while(t!=s){
		for(int i=head[t];i;i=nxt[i]){
			if(dis[arrive[i]]+1==dis[t]){
				pre[t]=arrive[i];
				suf[arrive[i]]=t;
				t=arrive[i];
				break;
			}
		}
		on[t]=1;
	}
}
int ans[2][Maxn+5],ans_len;
int main(){
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	min_dist(1);
	int s=1,t;
	for(int i=1;i<=n;i++){
		if(dis[i]>dis[s]){
			s=i;
		}
	}
	min_dist(s);
	t=s;
	for(int i=1;i<=n;i++){
		if(dis[i]>dis[t]){
			t=i;
		}
	}
	find_path(s,t);
	memset(vis,0,sizeof vis);
	for(int i=1;i<=n;i++){
		if(on[i]){
			vis[i]=1;
			for(int j=head[i];j;j=nxt[j]){
				vis[arrive[j]]=1;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			puts("-1");
			return 0;
		}
	}
	int now,tot=0;
	for(int i=s;i;i=suf[i]){
		now=++tot;
		for(int j=head[i];j;j=nxt[j]){
			if(on[arrive[j]]){
				continue;
			}
			ans[0][++ans_len]=++tot;
		}
		ans[0][++ans_len]=now;
	}
	ans_len=tot=0;
	for(int i=t;i;i=pre[i]){
		now=++tot;
		for(int j=head[i];j;j=nxt[j]){
			if(on[arrive[j]]){
				continue;
			}
			ans[1][++ans_len]=++tot;
		}
		ans[1][++ans_len]=now;
	}
	for(int i=1;i<=n;i++){
		if(ans[0][i]!=ans[1][i]){
			if(ans[0][i]<ans[1][i]){
				for(int j=1;j<=n;j++){
					printf("%d ",ans[0][j]);
				}
				puts("");
			}
			else{
				for(int j=1;j<=n;j++){
					printf("%d ",ans[1][j]);
				}
				puts("");
			}
			return 0;
		}
	}
	for(int i=1;i<=n;i++){
		printf("%d ",ans[0][i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,T,a[200007];
long long ans,now;
int main()
{
	n=read(),T=read();
	for (int i=1;i<=n;i++) a[i]=read();
	ans=-a[1],now=a[1];
	for (int i=2;i<=n;i++)
	{
		if (a[i]>=now+T)
		{
			ans+=now+T-a[i];
			now=a[i];
		} else now=a[i];
	}
	now+=T;
	ans+=now;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#include<vector>
#include <string>
int main () {

  int res = 0;
  int N;
  cin >> N;
  vector<string> s(N);
  int nB__A = 0;
  int n__A = 0;
  int nB__ = 0;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    int nsize = s[i].size();
    int ninside = (int)s[i].find("AB");
    while (ninside > -1) {
      // cout<<res<<endl;
      res++;
      ninside = s[i].find("AB", ninside+1);
    }
    
    if (s[i].at(0) == 'B' && s[i].back() == 'A') {
      nB__A++;
    } else if (s[i].at(0) == 'B') {
      nB__++;
    } else if (s[i].back() == 'A') {
      n__A++;
    }
  }

  if (nB__A == 0) {
    if (nB__ > n__A) {
      res += n__A;
    } else {
      res += nB__;
    }
  } else {
    res += nB__A - 1;
    if (n__A == 0 && nB__ == 0) {
    } else if (n__A > nB__) {
      res += nB__ + 1;
    } else {
      res += n__A + 1;
    } 
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 768
# region
import sys

DEBUG = True if (len(sys.argv) > 1 and sys.argv[1] == "DEBUG") else False


def dp(value):
    if DEBUG:
        print(value)
    return


def input_text(split=" "):
    # 入力
    result = []
    while True:
        try:
            row = list(
                map(lambda x: int(x) if x.isdecimal() else x, input().split(split))
            )
            result.append(row)
        except EOFError:
            break
    return result


# endregion
it = input_text()

n = it[0][0]
row = len(it)

s = set()
i = 1
while row >= i * 2:
    s = s | (set(it[i * 2]))
    i += 1

print(n - len(s))


Measured memory_bytes: 68020
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    X = LS()
    S_ = X[0]
    T = X[1]
    A, B = MI()
    U = S()
    if U == S_:
        print(A - 1, B)
    else:
        print(A, B - 1)


if __name__ == "__main__":
    main()



Measured memory_bytes: 74200
#include<iostream>

using namespace std;

int main() {
	int N;
	int x = 0;//支払った額
	int y = 0;//もらった額

	//入力
	cin >> N;

	//支払った額を計算
	for (int i = 0; i < N; i++) {
		x = x + 800;
	}

	//もらった額を計算
	for (int i = 0; i < N; i++) {
		if ((i + 1) % 15 == 0) {
			y = y + 200;
		}
	}

	//出力
	cout << x - y << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1001];

	scanf("%s", &str);

	int temp;
	for (int i = 0; i < strlen(str); i++) {
		temp = str[i];
		if (temp == 67) {
			temp = 65 + 25 + 3;
		}
		else if (temp == 66) {
			temp = 65 + 24 + 3;
		}
		else if (temp == 65) {
			temp = 65 + 23 + 3;
		}

		printf("%c", temp - 3);
	}

	puts("");

	return 0;
}

Measured memory_bytes: 948
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;
vector<int> g[200010];
bool v[200010];
int dfs(int s){
int res=1;
v[s]=true;
for(int i:g[s]){
    if(!v[i]){
        v[i]=true;
        res+=dfs(i);
    }
}
return res;
}

int cnctd(){
int res=0;
for(int i=1; i<=n; i++){
    if(!v[i]){
        res=max(res, dfs(i));
    }
}
return res;
}


int32_t main(){
INIT
cin>>n>>m;
for(int i=1; i<=m; i++){
    int u, v; cin>>u>>v; g[u].pb(v); g[v].pb(u);
}
int gr=cnctd();
cout<<gr;
return 0;
}





Measured memory_bytes: 24144
import sys
from collections import deque
from operator import itemgetter
input = sys.stdin.readline
N = int(input())
S = [0]*N
P = [0]*N
Dic = []
for i in range(N):
    S[i], P[i] = input().split()
   
for i in range(N):
    Dic.append([S[i], int(P[i]), i+1])

Dic.sort(key=itemgetter(1), reverse=True)
Dic.sort(key=itemgetter(0))

for i in range(N):
    print(Dic[i][2])


Measured memory_bytes: 3316
#include<stdio.h>

int main(){
int i;
int a,b,c;
int yaku=0;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++){
	if(c % i == 0){
		yaku++;
	}
}

printf("%d\n",yaku);

return 0;
}


Measured memory_bytes: 2092
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> a(5);
    REP(i, 5) cin >> a[i];

    ll amin = *min_element(ALL_OF(a));
    cout << (n + amin - 1) / amin + 4 << "\n";

}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    lint A,B,C,K;
    cin >> A >> B >> C >> K;
    if(abs(A-B)>1e18){
        cout << "Unfair" << endl;
        return 0;
    }else{
        if(K%2==0) cout << (A-B) << endl;
        else cout << (B-A) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int mp[20][20];
int bfs(int n,int s,int g){
  vector<int> dis(n);
  queue<int> q;
  rep(i,n)dis[i]=INF;
  dis[s]=0;
  q.push(s);

  int u;

  while(!q.empty()){
    u=q.front(),q.pop();
    rep(i,n){
      if(dis[i]>dis[u]+mp[u][i]){
        dis[i]=dis[u]+mp[u][i];
        q.push(i);
      }
    }
  }
    return dis[g];
}

signed main(){
  int n,m;
  cin>>n>>m;
  char x;
  rep(i,n)rep(j,n)mp[i][j]=INF;
  rep(i,m){
    int a,b,c,d;
    cin>>a>>x>>b>>x>>c>>x>>d;
    a--;b--;
    mp[a][b]=c;
    mp[b][a]=d;
  }
  int s,g,v,p;
  cin>>s>>x>>g>>x>>v>>x>>p;
  s--;g--;

  int sum1=bfs(n,s,g);
  int sum2=bfs(n,g,s);

  
  cout<<v-p-sum1-sum2<<endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>

using namespace std;

using ull = unsigned long long;

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

int main(int argc, const char *argv[])
{
  ull a, b, c, d;
  cin >> a >> b >> c >> d;

  ull lcm = c * d / gcd(c, d);
  ull ans = b - a + 1;
  ull divisable = b / c + b / d - b / lcm;
  a--;
  divisable -= a / c + a / d - a / lcm;
  cout << ans - divisable << "\n";
  return 0;
}

Measured memory_bytes: 256
// Aizu 1173: The Balance of the World
// 2017.9.13 bal4u@uu

#include <stdio.h>

char buf[110], *p;

int parse()
{
//	printf("%s\n", p);
	if (*p == ')' || *p == ']') return 0;
	while (*p) {
		if (*p == '(') {
			if (*(p+1) == ')') p+=2;
			else if (*(p+1) == ']') return 0;
			else { p++;
				if (!parse()) return 0;
				if (*p++ != ')') return 0;
			}
		} else if (*p == '[') {
			if (*(p+1) == ']') p+=2;
			else if (*(p+1) == ')') return 0;
			else { p++;
				if (!parse()) return 0;
				if (*p++ != ']') return 0;
			}
		} else return 1;
	}
	return 1;
}

int main()
{
	int f;
	char t[120], *q;

	while (1) {
		fgets(t, 110, stdin); if (t[0] == '.' && (!t[1] || !t[2])) break;
		p = buf, q = t; while (*q) {
			if (*q == '(' || *q == ')' || *q == '[' || *q == ']') *p++ = *q++;
			else q++;
		}
		*p = 0, p = buf;
		f = parse(); if (*p == ')' || *p == ']') f = 0;
		puts(f ? "yes" : "no");
	}
	return 0;
}

Measured memory_bytes: 1736
#!/usr/bin/env python3

import re

a = input()
a = re.split(" ",a)
c = []
b = max(int(a[0]), int(a[1]))
if(b == int(a[0])):
    c.append(int(a[0])-1)
    c.append(int(a[1]))
if(b == int(a[1])):
    c.append(int(a[1])-1)
    c.append(int(a[0]))

d = max(int(c[0]),int(c[1]))
ans = b + d
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int par[100000];
int ran[100000];

void init(int n){
    for(int i=0; i<n; i++){
        par[i] = i;
        ran[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(ran[x] < ran[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(ran[x] == ran[y]){
            ran[x]++;
        }
    }
    return;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
    }

    init(N);
    for(int i=0; i<M; i++){
        unite(A[i]-1, B[i]-1);
    }

    vector<int> C(N, 0);

    for(int i=0; i<N; i++){
        int j = find(i);
        if(C[j] == 0){
            C[j] = 1;
        }
    }

    int ans = accumulate(C.begin(), C.end(), 0);

    cout << ans -1  << endl;

    return 0;



}

Measured memory_bytes: 5068
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn main() {
    let (n, m) = read_two::<usize>();
    let h: Vec<i32> = read_vec();
    let mut v: Vec<bool> = vec![true; n];
    for i in 0..m {
        let (a, b) = read_two::<usize>();
        if h[a - 1] > h[b - 1] {
            v[b - 1] = false;
        } else if h[a - 1] < h[b - 1] {
            v[a - 1] = false;
        } else {
            v[a - 1] = false;
            v[b - 1] = false;
        }
    }
    let a: Vec<bool> = v.into_iter().filter(|x| *x == true).collect();
    println!("{}", a.len());
}


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

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

  if (n == 3) {
    puts("2 5 63");
    return 0;
  }
  if (n == 4) {
    puts("2 5 20 63");
    return 0;
  }

  vector<int> a[3];
  for (int i = 2; i <= 30000; ++i) {
    if (i % 6 == 0)
      a[2].push_back(i);
    else if (i % 2 == 0)
      a[0].push_back(i);
    else if (i % 3 == 0)
      a[1].push_back(i);
  }

  vector<int64_t> r[2];
  for (int idx = 0; idx < 2; ++idx) {
    r[idx].resize(a[idx].size());
    r[idx][0] = a[idx][0];
    for (int i = 1; i < a[idx].size(); ++i) {
      r[idx][i] = r[idx][i - 1] + a[idx][i];
    }
  }

  vector<int> s;
  for (int i = 0; i < a[0].size(); ++i) {
    bool f = false;
    for (int j = 0; j < a[1].size(); ++j) {
      if ((r[0][i] + r[1][j]) % 6 == 0 && n - (i + j + 2) <= a[2].size()) {
        s.insert(s.end(), a[0].begin(), a[0].begin() + i + 1);
        s.insert(s.end(), a[1].begin(), a[1].begin() + j + 1);
        s.insert(s.end(), a[2].begin(), a[2].begin() + n - (i + j + 2));

        f = true;
        break;
      }
    }

    if (f) break;
  }

  for (int i = 0; i < n; ++i) {
    cout << s[i] << (i + 1 == n ? "\n" : " ");
  }
}


Measured memory_bytes: 768
//43
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    double g[100][100]={{}};
    for(int y=0;y<n;y++){
      for(int x=0;x<n;x++){
	cin>>g[y][x];
      }
    }
    double r[101][100]={{}};
    fill(r[0],r[1],1);
    for(int i=0;i<m-1;i++){
      for(int j=0;j<n;j++){
	for(int k=0;k<n;k++){
	  r[i+1][j]=max(r[i+1][j],r[i][k]*g[k][j]);
	}
      }
    }
    cout<<fixed<<setprecision(2)<<*max_element(r[m-1],r[m])<<endl;
  }
  return 0;
}

Measured memory_bytes: 1448
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>();
    println!(
        "{}",
        match s.as_str() {
            "Sunny" => "Cloudy",
            "Cloudy" => "Rainy",
            "Rainy" => "Sunny",
            _ => unreachable!(),
        }
    )
}


Measured memory_bytes: 2036
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

#ifdef DEBUG
#include <fmt/format.h>
#endif
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using s64 = int64_t;
using u64 = uint64_t;
// }}}

int A, B, C;

void solve()
{
    if(A % 2 == 0 && B % 2 == 0 && C % 2 == 0 &&
       A == B && B == C && C == A) {
        cout << -1 << "\n";
        return;
    }

    int cnt = 0;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        int a = (B+C) / 2;
        int b = (C+A) / 2;
        int c = (A+B) / 2;
        A = a;
        B = b;
        C = c;
        ++cnt;
    }

    cout << cnt << "\n";
}

int main()
{
    cin >> A >> B >> C;

    solve();

    return 0;
}


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

using namespace std;

int main(void) {
    int n;
    
    cin >> n;
    
    int a[n];
    
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    
    for(int i=0; i<n-1; i++) {
        cout << a[n-1-i] << " ";
    }
    cout << a[0] << endl;
    
    return 0;
}

Measured memory_bytes: 3092
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

#[allow(unused_macros)]
macro_rules !max {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::max ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::max ($a ,max !($($rest ) ,+) ) } } ;}
#[allow(unused_macros)]
macro_rules !chmax {($base :expr ,$($cmps :expr ) ,+$(,) *) =>{{let cmp_max =max !($($cmps ) ,+) ;if $base <cmp_max {$base =cmp_max ;true } else {false } } } ;}

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        ab: [(Usize1, usize); h]
    }

    let mut s = (0..w).map(|i| (i, i)).collect::<BTreeSet<(usize, usize)>>();
    let mut v = (0..w).map(|i| (0, i)).collect::<BTreeSet<(usize, usize)>>();

    for (i, &(a, b)) in ab.iter().enumerate() {
        let update = s
            .range((a, 0)..(b, 0))
            .map(|&(i, j)| (i, j))
            .collect::<Vec<(usize, usize)>>(); // total: O(w)log w
        if !update.is_empty() {
            let mut x = 0;
            for (end, start) in update {
                chmax!(x, start);
                s.remove(&(end, start));
                v.remove(&(end - start, start));
            }
            if b != w {
                s.insert((b, x));
                v.insert((b - x, x));
            }
        }
        if let Some((m, _)) = v.iter().next() {
            println!("{}", m + i + 1);
        } else {
            println!("-1");
        }
    }
}


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

int main(){
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	for(int i=0;i<a;i++){
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No";
			cout<<endl;
			return 0;
		}
	}
	if(s[a]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=a+1;i<a+1+b;i++){
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No";
			cout<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n = int(input())
    A = [[], []]
    for i in range(2):
        A[i] = LI()

    for i in range(2):
        for j in range(1, n):
            A[i][j] += A[i][j - 1]

    summation = []
    summation.append(A[0][0] + A[1][n - 1])
    for i in range(1, n):
        summation.append(A[0][i] + A[1][n - 1] - A[1][i - 1])

    print(max(summation))


solve()

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int64_t n, a, c = 0, res = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    res += (a + c) / 2;
    c = a ? (a + c) % 2 : 0;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
from decimal import Decimal
from sys import stdin
 
 
def get_result(data):
    A, B, C = data
    r_a = Decimal(A**Decimal(0.5))
    r_b = Decimal(B**Decimal(0.5))
    r_c = Decimal(C**Decimal(0.5))
    return 'Yes' if r_a + r_b < r_c else 'No'
 
 
if __name__ == '__main__':
    data = stdin.readline().rstrip().split(' ')
    data = list(map(int, data))
    result = get_result(data)
    print(result)

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

#define ll long long

int n;
string s;

void solve(){
    cin>>n;
    cin>>s;
    if(n%2==1){
        cout<<"No"<<endl;
        return;
    }
    if(s.substr(0, n/2) == s.substr(n/2, n/2))
        cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
def f(p,N):
    res=0
    while N>=p:
        N//=p
        res+=N
    return res

N=int(input())
ps=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
A=[len([p for p in ps if f(p,N)>=k]) for k in [2,4,14,24,74]]

a,b,c,d,e=A[0],A[1],A[2],A[3],A[4]

ans=0
# 3*5^2
ans+=b*(b-1)//2*(a-2)
# 3*25
ans+=d*(a-1)
# 5*15
ans+=c*(b-1)
# 75
ans+=e

print(ans)

Measured memory_bytes: 39760
#include<string.h>
#include<stdio.h>
int main(void){
  int A,B;
  char S[11],T[11],U[11];
  scanf("%s %s",&S,&T);
  scanf("%d %d",&A,&B);
  scanf("%s",&U);
  if(strcmp(S,U)==0){
    printf("%d %d",A-1,B);
  }
  else{
    printf("%d %d",A,B-1);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
set<int>q[26];
int n,t,x,l,r,cnt,i,j,len;
string s;
char c;
int main(){
	cin>>n>>s;
	len=s.size();
	for(i=0;i<len;i++)q[s[i]-97].insert(i);
	cin>>n;
	while(n--){
		cin>>t;
		if(t==1){
			cin>>x>>c;
			x--;
			q[s[x]-97].erase(x);
			s[x]=c;
			q[c-97].insert(x);
		}
		else{
			cin>>l>>r;
			l--;r--;
			cnt=0;
			for(j=0;j<26;j++)if(*q[j].lower_bound(l)<=r&&q[j].lower_bound(l)!=q[j].end())cnt++;
			cout<<cnt<<endl;
		}
	}
}


Measured memory_bytes: 24256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,k; cin >> n >> k;
  int x[n];
  REP(i,n) cin >> x[i];

  int ans = INF;
  for (int l = 0; l < n-k+1; l++) {
    int r = l+k-1;
    int totl = abs(x[l]) + abs(x[r]-x[l]);
    int totr = abs(x[r]) + abs(x[r]-x[l]);
    ans = min(ans, min(totl, totr));
  }
  COUT(ans);
  return 0;
}

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


int main()
{
	int K, X;
	cin >> K >> X;

	int left = X - K + 1;
	int right = X + K - 1;

	for (int i = left; i <= right; i++) {
		if (i != left) {
			cout << " ";
		}
		cout << i;
	}

	return 0;
}

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

#define ull unsigned long long int
using namespace std;

ull mod = 1000000007;

vector<ull> A;

ull binv(ull x, ull y) {
    ull answer = 1;
    while(y) {
        if(y & 1) {
            answer = (answer * x) % mod;
        }
        x = (x * x) % mod;
        y >>= 1;
    }
    return answer;
}

int main() {
    ull sum = 0;
    int N; cin >> N;
    A.resize(N); 

    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum = (sum + A[i]) % mod;
    }

    // cout << sum << "\t---\n";

    unsigned long long int answer = 0, temp;
    for(int i = 0; i < N; i++) {
        if(A[i] > sum) {
            temp = sum + mod - A[i];
        }
        else {
            temp = sum - A[i];
        }

        answer = (answer + (temp * A[i]) % mod ) % mod;
    }

    cout << (answer * binv(2, mod-2)) % mod  << "\n";

    return 0;
}

Measured memory_bytes: 4408
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

unsigned long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0,startp=0,endp=0,checker=0;
std::vector<unsigned long long int> vec{}, vecsec{};
int iremono[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji,moji2;
bool okada = false,okada2=false;
std::string output, output2, input, one, two;
char cutcount[201];
int kakunou2[50][50] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{

	cin >> a;
	rep(i, a) {
		cin >> one;
		if (one[0] == 'M') {
			M++;
		}
		if (one[0] == 'A') {
			A++;
		}
		if (one[0] == 'R') {
			R++;
		}
		if (one[0] == 'C') {
			C++;
		}
		if (one[0] == 'H') {
			H++;
		}
	}
	
	cout << M * A*R + M * A*C + M * A*H + M * R*C + M * R*H + M * C*H + A * R*C + A * R*H + A * C*H + R * C*H << endl;
	
}

	
	





Measured memory_bytes: 256
target = raw_input()

command = []
for _ in range(int(raw_input())):
    command += [raw_input()]

for c in command:
    cmd = c.split()
    if 'replace' == cmd[0]:
        target = target[0:int(cmd[1])] + cmd[3] + target[int(cmd[2])+1:len(target)]
    if 'reverse' == cmd[0]:
        target = target[0:int(cmd[1])] + target[int(cmd[1]):int(cmd[2])+1][::-1] + target[int(cmd[2])+1:len(target)]
    if 'print' == cmd[0]:
       print target[int(cmd[1]):int(cmd[2])+1]

Measured memory_bytes: 6472
n=int(input())
l=list(map(int,input().split()))
dp=[0 for i in range(n)]
dp[0]=0
dp[1]=abs(l[0]-l[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
#print(l,dp)
print(dp[-1])

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007


int main(void){

    int N;
    cin >> N;

    int x = N /1.08;
    int xxx[3] = {x - 1, x, x + 1};

    bool OK = false;
    int ans;
    for (int i = 0; i < 3; i++){
        int t = xxx[i] * 1.08;
    //    cout << xxx[i] * 1.08 << endl;
        if (t == N){
            OK = true;
            ans = xxx[i];
        }
    }
    if(OK)
        cout << ans << endl;
    else
        cout << ":(" << endl;

    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    cin >> n;
    double sum = 0.0, a;
    
    for(int i = 1; i <= n; i++){
        cin >> a;
        sum += 1.0 / a;
    }
    sum = 1.0 / sum;
    cout << setprecision(16) << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,ans=100000;
  cin >>n;
  while(n--){
    ans = (int)(ans*1.05);
    if(ans>(ans/1000)*1000) ans = (ans/1000)*1000+1000;
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

void func_A() {

    int n;
    cin >> n;

    while (n > 0) {
        if (n % 10 == 7) {
            cout << "Yes";
            return;
        }

        n /= 10;
    }

    cout << "No";
}

void func_B() {

    unsigned long long n;
    cin >> n;

    unsigned long long sum = 0;
    for (unsigned long long i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) sum += i; 
    }

    cout << sum;
}

int gcd(int x, int y) {

    if (y == 0) return x;

    return gcd(y, x % y);
}

void func_C() {

    int k;
    cin >> k;

    int sum = 0;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    cout << sum;

}

int main()
{
    //func_A();
    //func_B();
    func_C();

    return 0;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define for1(i, m, n) for (int i = m; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx, y = ty - sy;
    rep(i, y)
    {
        cout << "U";
    }
    rep(i, x)
    {
        cout << "R";
    }
    rep(i, y)
    {
        cout << "D";
    }
    rep(i, x)
    {
        cout << "L";
    }

    cout << "L";
    rep(i, y + 1)
    {
        cout << "U";
    }
    rep(i, x + 1)
    {
        cout << "R";
    }
    cout << "D";

    cout << "R";
    rep(i, y + 1)
    {
        cout << "D";
    }
    rep(i, x + 1)
    {
        cout << "L";
    }
    puts("U");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
   ll n; cin >> n;
   vector<ll> a(5);
   ll max_count = 0;
   rep(i,5){
      cin >> a[i];
      max_count = max((n + a[i] - 1)/a[i],max_count);
   }
   print(4 + max_count);
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
	 public static void main (String[] args) throws IOException	{
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));                  
	     int joi,ioi;
	     byte[] line;
	     String str="";
	     while((str=br.readLine()) != null){
	    	 line=str.getBytes();
	    	 joi=0;
	    	 ioi=0;
	    	 for(int i=0;i<line.length-2;i++){
	    		 if(str.charAt(i)=='J'&&str.charAt(i+1)=='O'&&str.charAt(i+2)=='I')	joi++;
	    		 if(str.charAt(i)=='I'&&str.charAt(i+1)=='O'&&str.charAt(i+2)=='I') ioi++;
	    	 }
	    	 System.out.println(joi);
	    	 System.out.println(ioi);
	     }
	 }
}

Measured memory_bytes: 17892
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    ll ans = 0, sum = 0;
    REP(i, n){
        ll d;
        cin >> d;
        ans += sum * d;
        sum += d;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import heappop, heappush
N, M = map(int, input().split())
graph = [[] for i in range(N)]
root = [-float("inf")] * N
for i in range(M):
  l, r, d = map(int, input().split())
  graph[l - 1].append([r - 1, d])
  graph[r - 1].append([l - 1, -d])
  
  
for i in range(N):
  if root[i] < -10 ** 10:
    root[i] = 0
    queue = [i]
    while queue:
      now = heappop(queue)
      for j, k in graph[now]:
        if root[j] < - 10 ** 10:
          root[j] = root[now] + k
          heappush(queue, j)
        elif root[j] == root[now] + k:
          continue
        else:
          print("No")
          quit()
          
print("Yes")


    
    
    
    
    
    

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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	int x = 0;
	int N;
	cin >> N;
	char S[101];
	cin >> S;

	int max = 0;
	Rep(i, N){
		if(S[i] == 'I'){
			x++;
		}else{
			x--;
		}
		if(x > max){
			max = x;
		}
	}
	PrintLn(max);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a[3][3];
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(a[j][k]==b[i]){
                    a[j][k] = 0;
                }
            }
        }
    }
    bool flag = false;
    rep(i,3){
        if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0){
            flag = true;
        }
    }
    rep(i,3){
        if (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0){
            flag = true;
        }
    }
    if(a[1][1] == 0 && a[2][2] == 0 && a[0][0] == 0){
        flag = true;
    }
    if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0){
        flag = true;
    }
    if(flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 3e2 + 5;
int n, a[N][N], b[N][N];

int main () {
	File();

	n = read();
	For (i, 1, n) For (j, 1, n) a[i][j] = read();

	For (k, 1, n) For (i, 1, n) For (j, 1, n) {
		int tmp = a[i][k] + a[k][j];
		if (a[i][j] > tmp) return puts("-1"), 0;
		if (a[i][j] == tmp && i != k && j != k) b[i][j] = true;
	}

	long long ans = 0;
	For (i, 1, n) For (j, i + 1, n) ans += a[i][j] * (!b[i][j]);
	printf ("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void B_task();

int main()
{
	B_task();
	fflush(stdout);
	return 0;
}

static void B_task()
{
	char S[101] = { 0 };
	getstring(S);

	int ans = 0;
	int center = strlen(S) / 2;
	int len = strlen(S);
	for (int i = 0; i < center; i++) {
		if (S[i] != S[len - i - 1]) {
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define lowbit(x) ((x)&(-(x)))

using namespace std;

const int maxn = 1000000;
int a[maxn], f[maxn], r, c, q;
int fr[maxn], fc[maxn];
int r1, r2, c1, c2;

void init(){
    int pos;
    for (int i = 1; i <= r; i++)
        for (int j = 1; j <= c; j++){
            pos = (i - 1) * c + j;
            fr[pos] = fc[pos] = a[pos];
            for (int k = 1, l = lowbit(i); k < l; k <<= 1)
                fc[pos] = min(fc[pos], fc[(i-1-k)*c+j]);
            for (int k = 1, l = lowbit(j); k < l; k <<= 1)
                fr[pos] = min(fr[pos], fr[(i-1)*c+j-k]);
            f[pos] = fc[pos];
            for (int k = 1, lk = lowbit(j); k < lk; k <<= 1){
                f[pos] = min(f[pos], fr[(i-1)*c+j-k]);
                for (int p = 1, lp = lowbit(i); p < lp; p <<= 1)
                    f[pos] = min(f[pos], f[(i-p-1)*c+j-k]);
            }
        }
}

int query(){
    int ans = 0x7fffffff, ll, rr;
    while (1){
        ll = r1, rr = r2;
        while (1){
            ans = min(ans, a[(rr-1)*c + c2]);
            if (rr == ll) break;
            for (rr--; rr - lowbit(rr) >= ll; rr -= lowbit(rr))
                ans = min(ans, fc[(rr-1)*c + c2]);
        }
        if (c2 == c1) break;
        for (c2--; c2 - lowbit(c2) >= c1; c2 -= lowbit(c2)){
            ll = r1; rr = r2;
            while (1){
                ans = min(ans, fr[(rr-1)*c+c2]);
                if (rr == ll) break;
                for (rr--; rr - lowbit(rr) >= ll; rr -= lowbit(rr))
                    ans = min(ans, f[(rr-1)*c+c2]);
            }
        }
    }
    return ans;
}

int main(){
      while (scanf("%d%d%d", &r, &c, &q) && r + c + q){
          int *p = a;
          for (int i = 1; i <= r; i++)
              for (int j = 1; j <= c; j++)
                  scanf("%d", ++p);
          init();
          while (q--){
              scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
              r1++, c1++, r2++, c2++;              
              printf("%d\n", query());
          }
      }

      return 0;
}

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

int main() {
	string S;
	cin >> S;
	int N = S.length();
	stack<char> Stack;
	int ans = 0;
	for (char c : S) {
		if (Stack.empty()) Stack.push(c);
		else {
			if (Stack.top() != c) {
				Stack.pop();
				ans += 2;
			}
			else Stack.push(c);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
using namespace std;
int main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	rep(i, n) {
		cout << s[i] << t[i] << flush;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include<string>
#include <cstdlib>
using namespace std;

int main() {
	string s;
	int n;
	long double x, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> s;
		sum += ((s == "JPY") + (s == "BTC") * 380000)*x;
	}
	printf("%llf\n", sum);
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
C = []
D = []
for i in range(m):
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)

for i in range(n):
    a = A[i]
    b = B[i]
    min_dist = 10 ** 9
    min_num = -1
    for j in range(m):
        c = C[j]
        d = D[j]
        dist = abs(a-c)+abs(b-d)
        if min_dist > dist:
            min_dist = dist
            min_num = j+1
    print(min_num)


Measured memory_bytes: 3064
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N;
int GM[110][110];
vector<int> GL[110];

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++)
      GM[i][j] = 0;
  }
  int u, k;
  for (int i = 1; i <= N; i++) {
    cin >> u >> k;
    int t;
    for (int j = 0; j < k; j++) {
      cin >> t;
      GM[i][t] = 1;
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++)
      cout << GM[i][j] << (j == N ? '\n' : ' ');
  }
}



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

int main() {
    int N; cin >> N;
    for (int i=1; i<=9; i++) {
        if (N % i == 0 && N / i <= 9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

int main(){
	int k,t;
	cin >> k >> t;
	int a[t+1];
	for(int i=0; i<t; i++) {
		cin >> a[i];
	}
	sort(a, a+t, greater<int>());
	for(int i=1; i<t; i++){
		a[0]-=a[i];
	}
	if(a[0]<=0){
		cout << "0" << endl;
	}else{
		cout << a[0]-1 << endl;
	}
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> drink(n);
    for(int i=0; i<n; i++){
        int a,b;
        cin >> a >> b;
        pair<int, int> p=make_pair(a,b);
        drink.at(i) = p;
    }
    sort(drink.begin(), drink.end());
    int count=0;
    ll ans=0;
    for(int i=0; i<n; i++){
        pair<int, int> p = drink.at(i);
        int a,b;
        a = p.first;
        b = p.second;
        int buy = min(m-count, b);
        count += buy;
        ans += (ll)a*buy;
        if(count == m) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3960
#include <iostream>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include<queue>
#include <string>
#define N 250000
#define MOD 1000000007
using namespace std;
int cas;
int n,m;
int main()
{
    long long ans=1;
    cin>>n>>m;
    
    if(n>m+1||m>n+1){cout<<0;return 0;}
    for(int i=1;i<=n;i++)ans=(ans*i)%MOD;
    for(int i=1;i<=m;i++)ans=(ans*i)%MOD;
    if(n==m)ans=(ans*2)%MOD;
    cout<<ans<<endl;
}




Measured memory_bytes: 256