akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
using namespace std;

const int MOD = 924844033;

int main() {
        int n, K;
        scanf("%d%d", &n, &K);
        long long m[2][2001][2] = {};
        bool b = false;
        m[b][0][0] = 1;
        for (int i = 0; i < 2 * K; i ++) {
                for (int j = i; j < n; j += 2 * K) {
                        for (int k = 0; k <= n; k ++) {
                                if (k + 1 <= n && K <= j) {
                                        (m[!b][k + 1][0] += m[b][k][0]) %= MOD;
                                }
                                if (k + 1 <= n && j + K < n) {
                                        (m[!b][k + 1][1] += m[b][k][0]) %= MOD;
                                        (m[!b][k + 1][1] += m[b][k][1]) %= MOD;
                                }
                                (m[!b][k][0] += m[b][k][0]) %= MOD;
                                (m[!b][k][0] += m[b][k][1]) %= MOD;
                                m[b][k][0] = m[b][k][1] = 0;
                        }
                        b = !b;
                }
                for (int k = 0; k <= n; k ++) {
                        (m[b][k][0] += m[b][k][1]) %= MOD;
                        m[b][k][1] = 0;
                }
        }
        long long fact[2001];
        fact[0] = 1;
        for (int k = 1; k <= n; k ++) fact[k] = fact[k - 1] * k % MOD;
        long long ans = 0;
        for (int k = 0; k <= n; k ++) {
                (ans += m[b][k][0] * fact[n - k] % MOD * (k % 2 == 0 ? 1 : MOD - 1) % MOD) %= MOD;
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, k;
    sc(n) sc(k)
    int l[n];
    for (int i = 0; i < n; i++) sc(l[i])
    sort(l, l + n, greater<int>());
    int ans = 0;
    for (int i = 0; i < k; i++) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# input
inp_ls = input().split(" ")
n,m = [int(e) for e in inp_ls[:2]]
h_ls = [int(e) for e in input().split(" ")[:n]]

# calc
raw_obs_dic = {i+1: [] for i in range(n)}
for i in range(m):
	a,b = [int(e) for e in input().split(" ")[:2]]
	raw_obs_dic[a].append(b)
	raw_obs_dic[b].append(a)

# unique
obs_dic = {k:list(set(raw_obs_dic[k])) for k in raw_obs_dic}
# print(obs_dic)

cnt = 0
for o0 in obs_dic:
	# # no obs
	# if len(obs_dic[o0]) < 1:
	# 	flag = True
	# 	continue
	# compare height
	o0_h = h_ls[o0-1]
	flag = True
	for o1 in obs_dic[o0]:
		o1_h = h_ls[o1-1]
		if o0_h <= o1_h: flag = False
	# print(o0, flag)
	if flag is True: cnt += 1

# result
print(cnt)

Measured memory_bytes: 55480
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(a) (a).begin(),(a).end()
#define X first
#define Y second
#define inf 1e18+5
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
int dp[N][2];
vi v[N];
void dfs(int t,int p)
{
    int cnt_b=1,cnt_w=1;
    for(int i=0;i<v[t].size();i++)
    {
        int ch=v[t][i];
        if(ch==p)continue;
        dfs(ch,t);
        cnt_b*=dp[ch][1];
        cnt_w*=(dp[ch][0]+dp[ch][1]);
        cnt_b%=mod; cnt_w%=mod;
    }
    dp[t][0]=cnt_b; dp[t][1]=cnt_w;
    return;
}
void solve()
{
  int n; cin>>n;
  for(int i=1;i<n;i++)
  {
      int a,b; cin>>a>>b;
      --a; --b;
      v[a].pb(b);
      v[b].pb(a);
  }
  dfs(0,-1);
  int ans=(dp[0][0]+dp[0][1])%mod;
  cout<<ans;
  return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 17548
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int cnt = 0;
		while(n != 0)
		{
			n /= k;
			++cnt;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,mod=10007;
vector<int> _bs;
inline int P(int x,int y){
	if(y==0) return 1;
	if(y==1) return x;
	if(y==2) return x*(x-1);
}
inline void add(int &x,int y){
	x+=y;
	x%=mod;
}
int solve(vector<int> x,vector<int> y){
	int K=x.size();
	int dp[17][33][2][2]={};		//	,put,sl,bsl
	bool banx[32]={},bany[32]={};
	bool sl=0,bsl=0;
	rep(i,K){
		if(banx[x[i]]||bany[y[i]]) return 0;
		banx[x[i]]=bany[y[i]]=1;
		if(x[i]==y[i]) bsl=1;
		if(x[i]+y[i]==N-1) sl=1;
	}
	dp[0][0][sl][bsl]=1;
	int L=-N%2,M=(N+1)/2;
	int A=(N-1)/2,B=N/2;
	rep(i,M){//it
		int X=0,Y=0;
		for(int j=A+1;j<=B-1;j++){
			if(!banx[j]) X++;
			if(!bany[j]) Y++;
		}
		rep(j,N+1-K){//put
			rep(k,2) rep(l,2){//sl,bsl
				if(dp[i][j][k][l]==0) continue;
				if(L==-1){
					add(dp[i+1][j][k][l],dp[i][j][k][l]);
					if(!banx[A]&&!bany[A]&&j+1<=N-K) add(dp[i+1][j+1][1][1],dp[i][j][k][l]);
				}else{
					for(int b:_bs){
						bool bs[8]={};
						int C=0;
						rep(a,8) bs[a]=(b>>a)&1;
						rep(a,8) if(bs[a]) C++;
						if(L==0&&(bs[4]||bs[5]||bs[6]||bs[7])) continue;
						if(banx[A]&&(bs[0]||bs[4]||bs[1])) continue;
						if(banx[B]&&(bs[2]||bs[6]||bs[3])) continue;
						if(bany[A]&&(bs[3]||bs[7]||bs[0])) continue;
						if(bany[B]&&(bs[1]||bs[5]||bs[2])) continue;
						int ad=P(Y-j,bs[4]+bs[6])*P(X-j,bs[5]+bs[7])%mod*dp[i][j][k][l];
						if(ad) add(dp[i+1][j+C][k|bs[1]||bs[3]][l|bs[0]|bs[2]],ad);
					}
				}
			}
		}
		A--,B++,L+=2;
	}
/*	rep(i,M+1) rep(j,N+1-K) rep(k,2) rep(l,2){
		printf("dp[%d][%d][%d][%d]=%d\n",i,j,k,l,dp[i][j][k][l]);
	}
	puts("");*/
	return dp[M][N-K][1][1];
}
int xx[8],yy[8];
int main(){
	rep(i,1<<8){
		bool b[8]={};
		rep(j,8) b[j]=(i>>j)&1;
		bool ok=1;
		if(b[0]+b[4]+b[1]>1) ok=0;
		if(b[1]+b[5]+b[2]>1) ok=0;
		if(b[2]+b[6]+b[3]>1) ok=0;
		if(b[3]+b[7]+b[0]>1) ok=0;
		if(ok) _bs.pb(i);
	}
	int K;
	cin>>N>>K;
	rep(i,K) cin>>xx[i]>>yy[i];
	int ans=0;
	rep(i,1<<K){
		vector<int> x,y;
		rep(j,K) if((i>>j)&1) x.pb(xx[j]),y.pb(yy[j]);
		int t=1;
		if(x.size()%2) t=-1;
		int tmp=solve(x,y)*t;
//		show(i);
//		show(tmp);
		add(ans,tmp);
	}
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 1228
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

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 main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);


    string s;
    cin >> s;
    vector<ll> a(2019, 0);
    ll  dg = 1;
    ll  res = 0;

    REP(i, s.size()){
        res = (res + (s[s.size()-1-i]-'0') * dg) % 2019;
        dg = (dg * 10) % 2019;
        a[res]++;
    }

    ll ans = 0;
    REP(i, 2019){
        if(i==0){
            ans+= ((a[0]+1) * a[0] /2);
        }else{
            ans += a[i] * (a[i]-1) /2;
        }
    }

    cout <<  ans << "\n"; 

    return 0;



}


Measured memory_bytes: 3744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderPre
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var count = 0;
            for (int i = 0; i < N; i++)
                if (p[i] != i + 1)
                    count++;
            Console.WriteLine(count <= 2 ? "YES": "NO");
        }

    }
}



Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(x,y) for(lli i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,m;
    cin>>n>>m;
    lli ans=(n*(n-1))/2+(m*(m-1))/2;
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int digit(int x) {
    if (x == 0) return 0;
    int cnt = 1;
    while (x / 10) {
        x /= 10;
        cnt++;
    }
    return cnt;
}

int main() {
    IOS
    ll n;
    cin >> n;
    int x = sqrt(n);
    int mind = 1e5;
    for (int i = 1; i <= x; i++) {
        if (n % i == 0) {
            int j = n / i;
            int maxd = max(digit(i), digit(j));
            mind = min(mind, maxd);
        }
    }
    cout << mind << endl;
}

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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int cc[100005], cnc[100005], nb[100005];
int n, m;

int main() {
    scanf("%d %d", &n, &m);
    FO(i,1,n+1) {
        cc[i] = i==1;
        cnc[i] = i!=1;
        nb[i] = 1;
    }
    FO(z,0,m) {
        int x, y; scanf("%d %d", &x, &y);
        cc[y] = cc[y] || cc[x];
        cnc[y] = cnc[y] && (cnc[x] || nb[x] > 1);
        nb[y]++;
        if (nb[x] == 1) {
            nb[x] = 0;
            cc[x] = 0;
            cnc[x] = 1;
        } else {
            nb[x]--;
            cnc[x] = 1;
        }
    }
    int res = 0;
    FO(i,1,n+1) if (cc[i]) res++;
    printf("%d\n", res);
}



Measured memory_bytes: 1408
import java.util.*;

class Main{
  static int[] dx={1,0,0,-1};
  static int[] dy={0,1,-1,0};
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int h=sc.nextInt();
    int w=sc.nextInt();
    String[] a=new String[h];
    for(int i=0;i<h;i++){
      a[i]=sc.next();
    }
    Xy startXy=null;
    Deque<Xy> dq=new ArrayDeque<>();
    int ans=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(a[i].charAt(j)=='.'){
          startXy=new Xy(j,i);
          ans=Math.max(calc(h,w,startXy,a),ans);
        }
      }
    }
    System.out.println(ans);
  }
  static class Xy{
    int x;
    int y;
    Xy(int a,int b){
      x=a;
      y=b;
    }
    public String toString(){
      return "["+String.valueOf(x)+","+String.valueOf(y)+"]";
    }
  }
  static int calc(int h,int w,Xy startXy,String[] a){
//    System.out.println(startXy+" "+h+" "+w);
    int[][] l=new int[h][w];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        l[i][j]=-1;
      }
    }
    Deque<Xy> dq=new ArrayDeque<>();
    dq.addLast(startXy);
    l[startXy.y][startXy.x]=0;
    while(!dq.isEmpty()){
      Xy here=dq.pollFirst();
      int hx=here.x;
      int hy=here.y;
      for(int i=0;i<4;i++){
        int nx=hx+dx[i];
        int ny=hy+dy[i];
        if(nx<0||w<=nx||ny<0||h<=ny){
          continue;
        }
        if(a[ny].charAt(nx)=='.'&&l[ny][nx]==-1){
          l[ny][nx]=l[hy][hx]+1;
          dq.addLast(new Xy(nx,ny));
        }
      }
    }
    int res=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        res=Math.max(l[i][j],res);
      }
    }
    return res;
  }
}


Measured memory_bytes: 27004
import itertools
n=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
num = []
for i in range(1,n+1):
    num.append(i)
ans = []
for i in list(itertools.permutations(num)):
    ans.append(i)
print(abs(ans.index(P)-ans.index(Q)))



Measured memory_bytes: 45296
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

vector<ll>adj[21 * 21];
ll vis[21 * 21], lev[21 * 21], ans = 0, n, m;

void bfs(ll node)
{
	for(int i=0;i<n*m;i++) vis[i] = lev[i] = 0;
	vis[node] = 1;
	lev[node] = 0;
	queue<ll>q;
	q.push(node);
	while(!q.empty())
	{
		ll p = q.front();
		q.pop();
		for(auto it : adj[p])
		{
			if(vis[it]) continue;
			lev[it] = lev[p] + 1;
			q.push(it);
			vis[it] = 1;
		}
	}
	for(int i=0;i<n*m;i++) ans = max(ans, lev[i]);
}

int main()
{
	FAST_IO;

 	cin >> n >> m;
 	vector<string>a;
 	for(int i=0;i<n;i++)
 	{
 		string b;
 		cin >> b;
 		a.pb(b);
 	}   
 	for(int i=0;i<n;i++)
 	{
 		for(int j=0;j<m;j++)
 		{
 			if(a[i][j] == '.')
 			{
 				if(i > 0 && a[i - 1][j] == '.') adj[m * i + j].pb(m * i + j - m);
 				if(j > 0 && a[i][j - 1] == '.') adj[m * i + j].pb(m * i + j - 1);
 				if(i < n - 1 && a[i + 1][j] == '.') adj[m * i + j].pb(m * i + j + m);
 				if(j < m - 1 && a[i][j + 1] == '.') adj[m * i + j].pb(m * i + j + 1);
 			}
 		}
 	}
 	for(int i=0;i<n*m;i++) bfs(i);
 	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

/*小数点以下の長さを指定
cout << fixed << setprecision(15) << y << endl;
*/

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


int main() {
	int n, k, d;
	cin >> n >> k;

	map<int,int>x;
	rep(i, k) {
		int temp;
		cin >> temp;
		rep(j, temp) {
			int a;
			cin >> a;
			x[a]++;
		}
	}
	
	int cnt = 0;
	rep(i, n) {
		if (x[i + 1] == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  for(int i = 1; i < 4; ++i){
    if(S[i] == S[i-1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _086_2
{
    class Program
    {
        static void Main(string[] args)
        {
      
          
            string[] str = Console.ReadLine().Split(' ');
           
             int c = Convert.ToInt32(str[0] + str[1]);

            int d = (int)Math.Sqrt(c);

            int count = 0;
            for (int i = 0; i <= d; ++i)
            {
              
            if (c == i * i)
                {
                    count = count + 1;
                }
             
            }
            if (count == 1)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
            

            


           

        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
const int maxn=5e3+7;
const int mod=1e9+7;
typedef long long ll;
ll dp[maxn][maxn];
ll quick(ll a,ll b)
{
 ll ret=1;
 while(b)
 {
  if(b&1) ret=ret*a%mod;
  a=a*a%mod;
  b>>=1;
 }
 return ret;
}
int main() {
int n;
string s;
cin>>n>>s;
dp[0][0]=1;
for(int i=1;i<=n;i++)
{
 for(int j=0;j<=i;j++)
 {
  if(!j)
   dp[i][j]=(dp[i-1][j]+dp[i-1][j+1])%mod;
  else
   dp[i][j]=(dp[i-1][j-1]*2+dp[i-1][j+1])%mod;
 }
}
 cout<<dp[n][s.length()]*quick(quick(2,s.length()),mod-2)%mod<<endl;
	return 0;
}

Measured memory_bytes: 194048
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vb b(n, false);
    b[0] = true;
    vi c(n, 1);
    int x, y;
    REP(i, m) {
        cin >> x >> y;
        x--; y--;
        if (b[x]) b[y] = true;
        c[x]--;
        c[y]++;
        if (c[x] == 0) b[x] = false;
    }
    int ans = 0;
    REP(i, n) if (b[i] and c[i] > 0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3728
# Problem https://atcoder.jp/contests/abc082/tasks/abc082_a
# Python 3rd Try
from math import ceil


def ceil2number(a, b):
    result = 0
    c = (a + b) / 2
    result = ceil(c)
    return result


if __name__ == "__main__":
    answer = 0
    a, b = map(int, input().split(' '))
    answer = ceil2number(a, b)
    print(answer)


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (int NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  int n;cin >> n;
  vector<int> h(n+5,INF);
  REP(i,n) cin >> h[i];
  vector<int> dp(n+5);
  
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  
  FOR(i,2,n){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var n = o.a();
  console.log( 180 * (n - 2));
}


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


Measured memory_bytes: 21956
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << '\n';
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

#include <complex>
typedef complex<double> Point;
const double EPS = 1e-8;

// 入力ストリームから実数二つをとって Point へ
istream& operator >> ( istream &s, Point &a )
{
	double r, i;
	s >> r >> i;
	a = Point( r, i );
	return s;
}

// 内積（ドット積）
double dot( const Point &a, const Point &b )
{
	return a.real() * b.real() + a.imag() * b.imag();
}

// 外積（クロス積）
double cross( const Point &a, const Point &b )
{
	return a.real() * b.imag() - a.imag() * b.real();
}

// 直線 ( p1, p2 ) と点 q の距離
// include : cross
double distance_line_point( const Point &p1, const Point &p2, const Point &q )
{
	return abs( cross( p2 - p1, q - p1 ) ) / abs( ( p2 - p1 ) );
}

// 線分 ( p1, p2 ) と点 q の距離
// include : dot, distance_line_point
double distance_segment_point( const Point &p1, const Point &p2, const Point q )
{
	if ( EPS < dot( p2 - p1, q - p1 ) && EPS < dot( p1 - p2, q - p2 ) ) // 垂線が交わる
	{
		return distance_line_point( p1, p2, q );
	}
	else
	{
		return min( abs( p1 - q ), abs( p2 - q ) );
	}
}

// 線分 ( p1, p2 ) と円 ( q, r ) が交差するか
// include : distance_segment_point
bool segment_circle_intersect( const Point &p1, const Point &p2, const Point &q, const double r )
{
	if ( abs( p1 - q ) + EPS < r && abs( p2 - q ) + EPS < r )
	{
		return false;
	}
	else if ( r + EPS < abs( p1 - q ) && r + EPS < abs( p1 - q ) )
	{
		return distance_segment_point( p1, p2, q ) <= r + EPS;
	}
	else
	{
		return true;
	}
};

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

	for ( int n; cin >> n, n; )
	{
		vector<Point> walls( n );
		vector<double> rs( n );
		REP( i, 0, n )
		{
			cin >> walls[i] >> rs[i];
		}

		int m;
		cin >> m;
		REP( i, 0, m )
		{
			Point t, s;
			cin >> t >> s;

			bool safe = false;
			REP( j, 0, n )
			{
				safe |= segment_circle_intersect( t, s, walls[j], rs[j] );
			}
			cout << ( safe ? "Safe" : "Danger" ) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1252
import sys
readline = sys.stdin.readline

N, K, C = map(int, readline().split())
S = readline().rstrip()

O = 'o'
X = 'x'


l2r = [None] * N

offset = 0
count = 0
while True:
    i = offset
    while i < N:
        if S[i] == O:
            offset = i + C + 1
            l2r[i] = 1
            count += 1
            break
        i += 1

    if i >= N:
        break

if count > K:
    exit(0)

r2l = [None] * N
count = 0
offset = N - 1
while True:
    i = offset
    while i > -1:
        if S[i] == O:
            offset = i - C - 1
            r2l[i] = 1
            count += 1
            break
        i -= 1
    if i <= -1:
        break


for i in range(N):
    if l2r[i] == 1 and r2l[i] == 1:
        print(i + 1)

Measured memory_bytes: 51020
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    int ans = N - K + 1;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    std::string S;

int main(){
    cin>>S;
    for(auto x:S){
        if(x=='9'){
            cout<<"Yes";
            return 0;
        }
    }

    cout<<"No";
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, i;
	
	scanf("%d %d", &a, &b);
	
	if(a<b){
		for(i=0; i<b; i++){
			printf("%d", a);
		}
	}
	else if(a==b){
		for(i=0; i<b; i++){
			printf("%d", a);
		}
	}
	else if(a>b){
		for(i=0; i<a; i++){
			printf("%d", b);
		}
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
r,g,b,n=map(int,input().split())
lista = [r,g,b]
lista.sort()
l = lista[-1]
m = lista[-2]
s = lista[-3]
ans = 0
for i in range((n//l)+1):
    for j in range(((n-i*l)//m)+1):
        if (n-i*l-j*m)%s==0:
            ans+=1
print(ans)

Measured memory_bytes: 40428
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, m;
	cin >> n >> m;

	int res = (1900 * m + 100 * (n - m)) * pow(2, m);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
//ProblemC.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemC.cpp

#define MAXN 110

void Impossible() {
	op << "Impossible" << endl;
	exit(0);
}
void Possible() {
	op << "Possible" << endl;
	exit(0);
}


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

	int n;
	int a[MAXN];

	ip >> n;
	for (int i = 0; i < n; ++i) ip >> a[i];

	int c[MAXN];
	for (int i = 0; i < n; ++i) c[i] = 0;
	int maxd = 0;
	int mind = n;

	for (int i = 0; i < n; ++i) {
		++c[a[i]];
		maxd = MAX(maxd, a[i]);
		mind = MIN(mind, a[i]);
	}

	bool rst = true;

	if (maxd == 1) {
		if(n == 2) Possible();
		else Impossible();
	}

	if(mind != (maxd + 1) / 2) Impossible();

	if (maxd % 2 == 0 && c[mind] != 1)
		Impossible();
	else if (maxd % 2 != 0 && c[mind] != 2)
		Impossible();

	for (int i = mind + 1; i <= maxd; ++i) {
		if(c[i] < 2)
			Impossible();
	}

	Possible();

	return 0;
}
/***************************************************************/


Measured memory_bytes: 256
#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
char _;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,ans=0;
	cin>>n;
	
	for(int i=1;i<=n;i++){
		int foo;
		cin >> foo;
		if(i&1 && foo&1) ans++;
	}
	cout << ans << endl;
	return 0;
}



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

int main() {
    int a, b, c, s, t;
    cin >> a >> b >> c >> s >> t;
    int ans1 = a * s + b * t;
    int ans2 = 2*c * max(s, t);
    int ans3;
    if (s < t) ans3 = 2*c * s + b * (t - s);
    else ans3 = 2*c * t + a * (s - t);
    cout << min({ans1, ans2, ans3}) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

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

sum = [0]
for i in range(N):
    sum.append(sum[i] + A[i])

sum.sort()
dict = defaultdict(int)
for i in range(N + 1):
    dict[sum[i]] += 1

ans = 0
for key, val in dict.items():
    ans += val * (val - 1) // 2

print(ans)


Measured memory_bytes: 41696
#include<stdio.h>
int main(void)
{
		int t,n,x[4],i,j;
		for(i=0;i<4;i++){
			scanf("%d %d",&t,&n);
		if(t==1){
			x[i]=n*6000;
			}
		if(t==2){
			x[i]=n*4000;
			}
		if(t==3){
			x[i]=n*3000;
			}
		if(t==4){
			x[i]=n*2000;
			}
		}	
		for(j=0;j<4;j++){
			printf("%d\n",x[j]);
			}
		return 0;
}	

Measured memory_bytes: 1028
#include<stdio.h>
#define swap(X,Y){int Z; Y = X; X = Z}
int main()
{
	int  n=1,m=1,i;
	while(true)
	{
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)
		{
			break;
		}
		if(n>m)
		{
			i=m; 
			m=n; 
			n=i; 
		}
		printf("%d %d\n",n,m);
	}
    return 0;
} 


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
const int tam = 51;
int n, a;
int v[tam];
long long dp[tam*tam][tam][tam];

long long solve(int sum, int idx, int cant) {
    if( idx == n ) return cant != 0 && sum%cant == 0 && sum/cant == a;
    long long &ans = dp[sum][idx][cant];
    if(ans != -1) return ans;
    ans = 0;
    ans += solve(sum, idx+1, cant);
    ans += solve(sum + v[idx], idx+1, cant+1);
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> a;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0, 0) << '\n';
    return 0;
}

Measured memory_bytes: 53120
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F0(i, n) for (int i = 0; i < n; i++)
#define F1(i, n) for (int i = 1; i < n; i++)
#define Fi(n, a) for (int i = 0; i < n; i++) a[i] = gi()
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define MD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    I(h1);
    I(m1);
    I(h2);
    I(m2);
    I(k);
    h1 = h1*60+m1;
    h2 = h2*60+m2;
    cout << (h2-h1-k) << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N;
    cin>>N;
    cout<<N/3<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>

int main(){
  int i,n,j;
  long a[200000],b[200000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%ld",&a[i]);
  j=0;
  for(i=n-1;i>=0;i--){
    if(j%2==0){
      b[j/2]=a[i];
    }
    else{
      b[n-1-(j/2)]=a[i];
    }
    j++;
  }
  for(i=0;i<n;i++)
    printf("%ld ",b[i]);
  printf("\n");
}

Measured memory_bytes: 5248
from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
q = [int(input()) for _ in range(q)]
for qi in q:
    qans = 10**18
    ai = bisect_left(s, qi)
    bi = bisect_left(t, qi)
    ac = []
    bc = []
    for i in range(2):
        if (0 <= ai + i < a):
            ac.append(ai + i);
        if (0 <= ai - i < a):
            ac.append(ai - i);
    for i in range(2):
        if (0 <= bi + i < b):
            bc.append(bi + i);
        if (0 <= bi - i < b):
            bc.append(bi - i);
    for i in ac:
        for j in bc:
            aa = s[i];
            bb = t[j];
            if (max(aa, bb) <= qi):
                qans = min(qans, qi - min(aa, bb))
            elif (qi <= min(aa, bb)):
                qans = min(qans, max(aa, bb) - qi)
            else:
                qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))
    print(qans)


Measured memory_bytes: 90584
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		List<Integer> d = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			d.add(Integer.parseInt(sc.next()));
		}

		long ans = d.stream()
					.distinct()
					.count();

		System.out.println(ans);
	}
}


Measured memory_bytes: 28112
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int grid[3][3];
int sumCom , digonal1 , diagonal2;
int main() {

    for(int i=0;i<3;++i)
    {
        for(int j=0;j<3;++j)
        {
            cin >> grid[i][j];
            sumCom += grid[i][j];
        }
    }

    digonal1 = grid[0][0] + grid[1][1] + grid[2][2];
    diagonal2 = grid[0][2] + grid[1][1] + grid[2][0];

    if(sumCom == digonal1*3 && sumCom == diagonal2*3)
        puts("Yes");
    else
        puts("No");


	return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
s = Counter("".join(sorted(list(input()))) for _ in range(N))

def func(k):
    w = 1
    for x in range(2, k+1):
        w *= x
    return w
ans = 0
for k in s:
    ans += s[k] * (s[k] - 1) // 2

print(ans)


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

using namespace std;

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  string answer = "";
  answer += toupper(A[0]);
  answer += toupper(B[0]);
  answer += toupper(C[0]);
  cout << answer;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	string s[n], t;
	for(int i=0; i<n; i++) cin >> s[i];
	cin >> t;
	vector<int> cnt(3, 0);
	for(int i=0; i<n; i++){
		string sa, sz;
		bool nohatena=true;
		for(int j=0; j<s[i].length(); j++){
			if(s[i][j]=='?'){
				sa+='a';
				sz+='z';
				nohatena=false;
			}else{
				sa+=s[i][j];
				sz+=s[i][j];
			}
		}
		//あり得る最小値
		//(?がない単語であってtより前の数(等号含まず))+(?を全てzにしたときにtより前になる語の数(等号含まず))
		//あり得る最大値
		//(?がない単語であってtより前の数(等号含む))+(?を全てaにした時にtより前になる単語の数(等号含む))
		if(nohatena){
			if(s[i]<t) cnt[0]++;
			if(s[i]<=t) cnt[1]++;
		}else{
			if(sz<t) cnt[2]++;
			if(sa<=t) cnt[3]++;
		}
	}
	int l=cnt[0]+cnt[2], r=cnt[1]+cnt[3];
	for(int i=l; i<=r; i++){
		cout << i+1;
		if(i!=r) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 896
N,M,X=map(int,input().split())
A=list(map(int,input().split()))

count1=0
for i in range(X,N):
    for j in A:
        if i == j:
            count1 +=1
            
count2=0            
for i in range(X+1):
    for j in A:
        if i == j:
            count2 +=1
        
print(min(count1,count2))    

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CAntiDivision {

    ll lcm(int x, int y) {
        return (ll) x * y / __gcd(x, y);
    }

    ll f(ll n, int x, int y) {
        return n - n / x - n / y + n / lcm(x, y);
    }

public:
    void solve(std::istream &in, std::ostream &out) {
        ll a, b;
        int c, d;
        in >> a >> b >> c >> d;
        ll res = f(b, c, d) - f(a - 1, c, d);
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CAntiDivision solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

int main() {
int a, b;
  cin >> a >> b;
  if(a<6) cout << 0 << endl;
  else if(a>=6 && a<=12) cout << b/2 << endl;
  else  if( a>=13) cout << b << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1);
    rep(i,n){
        sum[i+1] = sum[i]+a[i];
        sum[i+1] %= MOD;
    }
    ll ans = 0;
    rep(i,n-1){
        ans += a[i]*(sum[n]-sum[i+1])%MOD;
        ans %= MOD;
        if(ans < 0) ans += MOD;
    }
    cout << ans << endl;
}



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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

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

    int N; cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    int max_i = -1;
    bool different = false;
    rep(i, N) {
        if(A[i] > B[i] and max_i < 0) max_i = i;
        if(max_i >= 0 and A[i] > B[i] and (B[max_i] > B[i])) max_i = i;
        different |= A[i] != B[i];
    }
    if(not different) {
        cout << 0 << endl;
        return 0;
    }
    assert(max_i >= 0);
    ll sum = 0;
    rep(i, N) if(i != max_i) sum += A[i];
    sum += A[max_i] - B[max_i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
ary = []
mod = []
5.times do
  a = gets.to_i
  ary << a
  mod << ((a.to_f/10).ceil)*10
end
kouho = []
sum = mod.sum
5.times do |i|
  kouho << sum-((ary[i].to_f/10).ceil)*10+ary[i]
end
puts kouho.min

Measured memory_bytes: 14404
/**
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=10000+10;
int N,M;
int a[maxn],b[maxn];
int main()
{
#ifdef _WY
freopen("0905.in","r",stdin);
#endif // _WY
	scanf("%d",&N);
	LL cancontain=0;
	LL needcontain=0;
	for(int i=1;i<=N;++i){ scanf("%d",&a[i]); }
	for(int i=1;i<=N;++i){
		scanf("%d",&b[i]);
		if(a[i]<=b[i]) cancontain+=(b[i]-a[i])/2;
		else{
			needcontain+=(a[i]-b[i]);
		}
	}
	if(needcontain<=cancontain) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 384
N,K,C=map(int,input().split())
S=input()
forward=[]
back=[]
ans=[]
tmp=0
for i in range(len(S)):
    if tmp:
        tmp-=1
        continue
    if S[i]=="o":
        forward.append(i+1)
        tmp=C
tmp=0
for i in range(len(S)-1,-1,-1):
    if tmp:
        tmp-=1
        continue
    if S[i]=="o":
        back.append(i+1)
        tmp=C
    if len(back)==K:
        break
back.sort()
for i in range(K):
    if forward[i]==back[i]:
        print(forward[i])
        


Measured memory_bytes: 20640