akhauriyash/Code-Regression huggingface dataset:
def Find(x, par):
  if par[x] < 0:
    return x
  else:
    # 経路圧縮
    par[x] = Find(par[x], par)
    return par[x]

def Unite(x, y, par, rank):
  x = Find(x, par)
  y = Find(y, par)
  
  if x != y:
    # rankの低い方を高い方につなげる
    if rank[x] < rank[y]:
      par[y] += par[x]
      par[x] = y
    else:
      par[x] += par[y]
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1
    
def Same(x, y, par):
  return Find(x, par) == Find(y, par)
 
def Size(x, par):
  return -par[Find(x)]

n, k, l = map(int, input().split())
rpar = [-1]* n
tpar = [-1]* n
rrank = [0]*n
trank = [0]*n

for i in range(k):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, rpar, rrank) 

for i_ in range(l):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, tpar, trank)

d = {}
IDs = [0]*n
for j in range(n):
  ID = Find(j, rpar)+(Find(j, tpar)+1)*10**8
  IDs[j] = ID
  if ID in d:
    d[ID] += 1
  else:
    d[ID] = 1

ans = ''
for j_ in range(n):
  if j_ != 0:
    ans += ' '
  ans += str(d[IDs[j_]])
print(ans)

Measured memory_bytes: 36200
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int n = sc.nextInt();

    int max = Math.max(h,w);
    int min = Math.min(h,w);
    int count = 0;

    for (int i = 1; i <= min; i++) {
      count++;
      if (i*max >= n) {
        break;
      }
    }

    System.out.println(count);

  }

}


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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/



constexpr ll Q_MAX = 2;
constexpr ll T_I_MAX = 1000000000;
constexpr ll X_I_MAX = 1000000000;
constexpr ll D_Q_MAX = 1000000000;

class Event{
public:
	ll d;//イベント発生までの時間
	ll x;//停止する座標
	ll type;//0insert,1delete,2query
	Event(ll d,ll x,ll type):d(d),x(x),type(type){}
	bool operator < (const Event &another) const {
		if(d==another.d){
			return type<another.type;
		}
		return d<another.d;
	}
};

ll N, Q;

vector<Event> a;
void input() {
	scanf("%lld%lld", &N, &Q);
	rep(i, N) {
		ll s,t,x;
		scanf("%lld%lld%lld", &s, &t, &x);
		a.push_back(Event(s-x,x,0));
		a.push_back(Event(t-x,x,1));
	}
	rep(i, Q) {
		ll d;
		scanf("%lld", &d);
		a.push_back(Event(d,d,2));
	}
}

void solve() {
	sort(all(a));
	multiset<ll> s;//同じ数字を複数格納する可能性があるのでsetでなくmultiset
	vector<ll> ans;
	rep(i,a.size()){
		if(a[i].type==0){
			s.insert(a[i].x);
		}else if(a[i].type==1){
			s.erase(s.lower_bound(a[i].x));//a[i].xをただ１つだけ消すためにイテレータで指定する
			//s.erase(a[i].x);//これだとa[i].xと同じ数字全て消えてしまう
		}else if(a[i].type==2){
			if(s.size()) ans.push_back(*(s.begin()));
			else ans.push_back(-1);
		}
	}

	rep(i,Q)p(ans[i]);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 28644
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int x, y;

//inputします
void input() {
    cin >> x >> y;
}

//ライブラリ置き場

//割り算に対するあまりの処理(フェルマーのなんちゃら定理）
i64 divmod(i64 aa26, i64 bb26, i64 pp26) {//aa:割る数 bb:pp-2 pp:余りを取る数
    if (bb26 == 0) {
        return 1;
    }
    else if (bb26 % 2 == 0) {
        i64 dd26 = divmod(aa26, bb26 / 2, pp26);
        return (dd26 * dd26) % pp26;
    }
    else {
        return (aa26 * divmod(aa26, bb26 - 1, pp26)) % pp26;
    }
}

i64 commod(i64 aa27, i64 bb27, i64 pp27) {//aaCbb mod pp
    if (aa27 < bb27)return 0;
    if (2 * bb27 > aa27)bb27 = aa27 - bb27;
    if (bb27 == 0)return 1;
    i64 ans27 = 1;
    ff(ii27, 0, bb27) {
        ans27 *= aa27 - ii27;
        ans27 %= pp27;
    }
    ff(ii27, 1, bb27 + 1) {
        ans27 *= divmod(ii27, pp27 - 2, pp27);
        ans27 %= pp27;
    }
    return ans27;
}

//main
int main() {
    input();
    i64 ans = 0;
    int a, b,c;
    c = (x + y) / 3;
    if ((x < c || y < c)||(x+y)%3!=0) {
        cout << 0 << endl;
        return 0;
    }
    a = x - c;
    b = y - c;
    ans = commod(c, a, inf);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main(){
   int n,k;
   string s;
   cin>>n>>k>>s;
   ll cnt=0;
   for (int i = 0; i < n-1; i++)
   {
       if(s[i]!=s[i+1]) cnt++;
   }
   //cerr<<cnt<<endl;
   cout<<n-1-max(0LL,(cnt-2*k))<<endl;
   
   
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';

    cout << s;
    
}

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

int main (){
	int h1, m1, h2, m2, k;
	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
	printf("%d\n", (h2 * 60 + m2) - (h1 * 60 + m1) - k);
	return 0;
}


Measured memory_bytes: 3792
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char s[100005];
int main()
{
	while(~scanf("%s",s)){
		int len=strlen(s);
		char c=s[len-1];
		int num=0;
		for(int i=len-2;i>=0;i--){
			if(s[i]!=c){
				num++;
				c=s[i];
			}
			
		}
		printf("%d\n",num);
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()

int main(){
    int n,l,r;
    while(cin>>n>>l>>r,n){
        int sum=0;
        int a[55];
        rep(i,n)cin>>a[i];
        for(int i=l;i<=r;i++){
            a[n]=i;
            for(int j=0;j<=n;j++){
                if(i%a[j]==0){
                    if(j%2==0)sum++;
                    break;
                }
            }
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3084
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    K, N = map(int, input().split())
    A = list(map(int,input().split()))

    md = 0
    ans = 0
    for i in range(N - 1):
        d = A[i+1] - A[i]
        ans += d
        md = max(md, d)

    d = (K - A[-1]) + A[0]
    ans += d
    md = max(md, d)

    ans -= md

    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 25880
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin >> k>>a>>b;
  int i;
  string s="NG";
  for(i=0;i<1000;i++){
    if(k*i>=a && k*i<=b){
      s="OK";
    }
    
  }
  cout << s;
}
  

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

//map of jewelries and check and pick it 
class Jewel {
	private int px, py;

	Jewel(Integer[] p) {
		px = p[0];
		py = p[1];
	}

	public boolean match(int lx, int ly) {
		if (px == lx && py == ly)
			return true;
		else
			return false;
	}

	public void picked() {
		px = -1;
		py = -1;
	}
}

// operate robot
class Robt {
	private int lx, ly;
	private int picked = 0;

	public void locate(int x, int y, Jewel[] jewel) {
		lx = x;
		ly = y;
	}

	private void moveOne(int dx, int dy, Jewel[] jewel) {
		lx += dx;
		ly += dy;
		for (int i = 0; i < jewel.length; i++)
			if (jewel[i].match(lx, ly)) {
				picked++;
				jewel[i].picked();
			}
	}

	public void move(String com, Jewel[] jewel) {
		String[] dd = com.split(" ");
		int dist = Integer.valueOf(dd[1]);
		for (int m = 0; m < dist; m++) {
			switch (dd[0]) {
			case ("N"):
				moveOne(0, 1, jewel);
				break;
			case ("E"):
				moveOne(1, 0, jewel);
				break;
			case ("S"):
				moveOne(0, -1, jewel);
				break;
			case ("W"):
				moveOne(-1, 0, jewel);
				break;
			}
		}
	}

	public int getPicked() {
		return picked;
	}
}

public class Main {

	public static void main(String[] args) throws Exception {
		// BufferedReader br = new BufferedReader(new FileReader(new
		// File("c:\\2000.txt")));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (doMain(br))
			;
		System.exit(0);
	}

	private static boolean doMain(BufferedReader br) throws Exception {
		Integer[] head = inpInt(br);
		if (head[0] == 0)
			return false;

		Jewel[] jewel = new Jewel[head[0]];
		for (int i = 0; i < head[0]; i++) {
			jewel[i] = new Jewel(inpInt(br));
		}
		Robt r = new Robt();
		r.locate(10, 10, jewel);

		Integer[] rob = inpInt(br);
		for (int i = 0; i < rob[0]; i++) {
			r.move(inp(br), jewel);
		}

		if (head[0] == r.getPicked())
			System.out.println("Yes");
		else
			System.out.println("No");
		return (true);

	}

	// input from StdIn and get each element as Integer delimited by space
	private static Integer[] inpInt(BufferedReader br) throws IOException {
		String s = inp(br);
		// System.out.println(s);
		String[] se;
		se = s.split(" ");

		Integer[] ie = new Integer[se.length];
		for (int i = 0; i < se.length; i++)
			ie[i] = Integer.valueOf(se[i]);
		return ie;
	}

	// input text line from StdIn
	private static String inp(BufferedReader br) throws IOException {
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));

		return br.readLine();

	}

}

Measured memory_bytes: 31584
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    scanf("%d",&N);
    char s[N];
    scanf("%s",s);
    int i,j,c,p;
    vector<int>d(N),e(N),w(N);
    w[0]=0;
    for(i=1;i<N;i++)w[i]=w[i-1]+(s[i-1]=='W');
    e[N-1]=0;
    for(i=N-2;i>=0;i--)e[i]=e[i+1]+(s[i+1]=='E');
    for(i=0;i<N;i++)w[i]+=e[i];
    printf("%d\n",*min_element(w.begin(),w.end()));
}

Measured memory_bytes: 4096
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e4;
LL dp[N + 5];
LL pref[N + 5];
LL s[N + 5], p[N + 5];

void hora(int tc) {
	int c,n,m;
	cin>>c>>n>>m;
	for(int i = 0;i < n;i++) cin>>s[i]>>p[i];
	memset(dp, -1, sizeof dp);
	dp[0] = 0;
	for(int i = 0;i < n;i++) {
		for(int j = c;j >= s[i];j--) if(dp[j - s[i]] != -1) dp[j] = max(dp[j], dp[j - s[i]] + p[i]);
	}
	pref[0] = 0;
	for(int i = 1;i <= c;i++) pref[i] = max(pref[i - 1], dp[i]);
	for(int i = 1;i <= m;i++) {
		cout<<pref[c / i] * i<<endl;
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}





Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}

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

int main(){
  int a1,b1,a2,b2;
  cin >> a1 >> b1 >> a2 >> b2;
  if(a1==a2){
    cout << 0 << endl;
    return 0;
  }
  else{
    cout << 1 << endl;
    return 0;
  }
}


Measured memory_bytes: 256
/////////////==========================
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================


int main(){
    int k, n;
    cin >> k >> n;
    int arr[n], maxdiff = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }

    for (int i = 1; i < n; i++)
    {
        maxdiff = max(maxdiff, arr[i] - arr[i-1]);
    }   
    maxdiff = max(maxdiff, arr[0] + k - arr[n-1]);

    cout <<  k - maxdiff;
    
    
    
}

Measured memory_bytes: 1024
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;
char str[55];

int main() {
   // freopen("in.txt", "rt", stdin);
    int l;
    scanf("%d", &l);
    int x = l;
    int sz = 0;
    while (x) {
        str[sz] = char('0' + (x % 2));
        x /= 2;
        ++sz;
    }
    str[sz] = 0;
   // printf("%s\n",str);
    vector<pair<int, pair<int, int>>> vec;
    int cnt = str[0] == '1';
    for (int i = 1; i < sz; ++i) {
        vec.push_back({i, {i - 1, 0}});
        vec.push_back({i, {i - 1, (1 << (i - 1))}});
        cnt += str[i] == '1';
    }
    if (cnt != 1) {
        int cur = l;
        for (int i = 0; i + 1 < sz; ++i) {
            if (str[i] == '1') {
                vec.push_back({sz-1, {i, cur - (1 << (i))}});
                cur -= (1 << (i));
            }
        }
    }
    printf("%d %d\n", sz, (int) vec.size());
    for (auto e:vec) {
        printf("%d %d %d\n", sz - e.first, sz - e.second.first, e.second.second);
    }
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
D={}
for i in range(N):
    if A[i] not in D:
        D[A[i]]=1
    else:
        D[A[i]]+=1
        
MAX=0
for a,b in D.items():
    MAX+=b*(b-1)//2
#print(MAX)

for i in range(N):
    ans=MAX-D[A[i]]*(D[A[i]]-1)//2 + (D[A[i]]-1)*(D[A[i]]-2)//2
    print(ans)

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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int m1, d1, m2, d2;
	cin>>m1>>d1>>m2>>d2;
	if(m1!=m2 && d1!=1)
		cout<<1;
	else
		cout<<0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define ll long long

using namespace std;

const ll INF = LLONG_MAX / 2 - 1;


struct Edge {
	ll t;
	ll c;
	Edge(ll to, ll cost):t(to),c(cost){}
	Edge(){}
};

vector<ll> weigh;
ll R, C;

bool DFS(ll node, vector<vector<Edge> >& edge, ll& xmin, ll& ymin) {
	if (node < R) xmin = min(xmin, weigh[node]);
	else ymin = min(ymin, weigh[node]);
	for (auto &to : edge[node]) {
		if (weigh[to.t] == INF) {
			weigh[to.t] = to.c - weigh[node];
			if (not DFS(to.t, edge, xmin, ymin)) return false;
		}
		else {
			if (weigh[to.t] + weigh[node] != to.c) return false;
		}
	}
	return true;
}
int main() {
	cin >> R >> C;
	ll N;
	cin >> N;
	weigh.resize(R + C, INF);
	vector<vector<Edge> > edge(R+C);
	for(int i = 0; i < N; i++){
		ll r, c, a; cin >> r >> c >> a;
		--r; --c;
		edge[r].push_back(Edge(R+c,a));
		edge[R+c].push_back(Edge(r, a));
	}

	bool res = true;
	ll xmin, ymin;
	for(int i = 0; i < R + C; i++){
		if(weigh[i] == INF and edge[i].size() > 0) {
			xmin = ymin = numeric_limits<int>::max();
			weigh[i] = 0;
			if (not DFS(i,edge,xmin,ymin) or xmin+ymin < 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 19584
for i in range(1,3000):
    nums=input()
    n_list=nums.split()
    x=int(n_list[0])
    y=int(n_list[1])
    if x==0 and y==0:
        break
    if x<y:
        print(x,y)
    else:
        print(y,x)




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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	vi a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;cin>>k;
	cout<<a[k-1]<<endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  int ans=0;
  int n=1;
  int m=1;
  for (int i=N;i>N-2;i--){
      n*=i;
  }
  for (int j=M;j>M-2;j--){
      m*=j;
  }
  if (N==0 || N==1){
      n=0;
  }
  if (M==0 || M==1){
      m=0;
  }
  cout << n/2+m/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<utility>
#include<tuple>
#include<algorithm>
using namespace std;
#define INF 1e9

int main(){
    int a,b,c,k;cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<endl;
    }else if(k<=b){
        cout<<a<<endl;
    }else{
        cout<<a-(k-a-b)<<endl;
    }
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,m,f=1,i,j,indx,val;
    cin>>n>>m;
    int a[n+1];
    for(i=0;i<=n;i++) a[i]=-1;
    if(n==1 && m==0) {
        cout<<0<<endl;
        return 0;
    }
    for(i=0;i<m;i++)
    {
        cin>>indx>>val;
        
        if(n>1 && indx==1 && val==0 ) f=0;
        else if(a[indx]==-1 || a[indx]==val )
                a[indx]=val;

        else f=0;
       // cout<<a[indx]<<endl;
    }
    if(f==0) cout<<-1<<endl;
    else{
        for(i=1;i<=n;i++)
        {
            if(a[i]==-1 && i==1) a[i]=1;

            else if(a[i]==-1) a[i]=0;
            cout<<a[i];
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
using namespace std;

int a[3];
int b;

int main() {

	cin >> a[0] >> a[1] >> a[2];
	b = a[2];
	sort(a, a + 3);

	if (a[1] == b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
const ll N=26,mod=1000000007;
vector<ll> v[26];
signed main()
{
    fast;
    ll pro=1,temp,n,t,i,m,k,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=1,i1=-1,i2=-1;
    string s1,s2;
    string conc;
    cin>>s1>>s2;
    conc=s1+s1;
    x=s1.length();
    y=s2.length();
    rep(i,0,2*x-1)
    {
    	ind=conc[i]-'a';
    	v[ind].pb(i);
    }
    curr=-1;
    rep(i,0,y-1)
    {
    	temp=s2[i]-'a';
    	ind=upper_bound(all(v[temp]),curr)-v[temp].begin();
    	if(ind==v[temp].size())
    	{
    		return cout<<-1,0;
    	}
    	ind=v[temp][ind];
    	ans+=(ind-curr);
    	ind%=x;
    	curr=ind;
    }
    cout<<ans<<endl;
    return 0;
} 

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if (b >= a * c) {
    cout << c;
  } else {
    cout << b / a;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    long a = input.nextLong();
    long b = input.nextLong();
    long c = input.nextLong();
    long k = input.nextLong();
    
    int ans = 0;
    if (k <= a) {
      System.out.println(k);
      return;
    }
    
    ans += a;
    k -= a;
    if (k <= b) {
      System.out.println(ans);
      return;
    }
    k -= b;
    ans -= k;
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 35612
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#define Max 1000
#define INF 1000000000000000000
using namespace std;



int main(){

	int n,i;
	char s[Max];
	scanf("%d",&n);
	scanf("%s",s);
	int c = 0;
	for(i=0;i<n-2;i++){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
			c++;
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int kotae=INT_MAX;
  sort(a.begin(),a.end());
  for(int i=a[0];i<=a[n-1];i++){
    int sa=0;
    for(int j=0;j<n;j++){
      sa+=(a[j]-i)*(a[j]-i);
    }
    kotae=min(kotae,sa);
  }
  cout<<kotae<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;

void solve()
{
    int n;
    cin>>n;
    vi a(n),cnt(100001,0);
    ll su=0;
    fo(i,0,n) {cin>>a[i]; su+=a[i]; cnt[a[i]]++; }
    int q;
    cin>>q;
    while(q--)
    {
        int pre,nex;
        cin>>pre>>nex;
        su+=(nex-pre)*cnt[pre];
        cnt[nex]+=cnt[pre];
        cnt[pre] = 0;
        cout<<su<<"\n";
    }
    //cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a,b;
    cin >> a;
    char c;
    cin >> c;
    cin >> b;
    if(c == '+')cout << a + b << endl;
    else cout << a - b << endl;
    return 0;
}

Measured memory_bytes: 256
const main = (input) => {
  const [s, t] = input.trim().split('\n')
  let ans = 0
  for (let i=0; i<s.length; i++) if (s[i] !== t[i]) ans++
  return console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 32844
#include<cstdio>
using namespace std;
int main(void){
	char s[3];
	int cnt;
	
	scanf("%s",s);
	cnt=0;
	if(s[0]=='1')	cnt++;
	if(s[1]=='1')	cnt++;
	if(s[2]=='1')	cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static final long x = (long) Math.pow(10, 18);

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x[][] = new int[n][n];

		for (int i = 0; i < n; i++) {
			Arrays.fill(x[i], 0);
		}

		for (int i = 0; i < m; i++) {
			int y = sc.nextInt();
			int z = sc.nextInt();
			x[y - 1][z - 1] += 1;
			x[z - 1][y - 1] += 1;
		}

		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j < n; j++) {
				sum += x[i][j];
			}
			System.out.println(sum);
		}


		sc.close();
	}

}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	double r;
	cin >> r;
	double ans = PI * 2 * r;
	printf("%.6f\n", ans);
}


Measured memory_bytes: 3784
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll r[3][2],memo[25252525];
bool done[25252525];

ll solve(int n){
	int i;
	if(n<0){
		return -INFLL;
	}
	if(done[n]){
		return memo[n];
	}
	done[n] = true;
	memo[n] = n;
	for(i=0; i<3; ++i){
		memo[n] = max(memo[n],solve(n-r[i][0])+r[i][1]);
	}
	return memo[n];
}

int main(void){
	int n,i,j,m;
	cin >> n;
	for(i=0; i<2; ++i){
		for(j=0; j<3; ++j){
			cin >> r[j][i];
		}
	}
	m = solve(n);
	for(i=0; i<3; ++i){
		swap(r[i][0],r[i][1]);
	}
	fill(done,done+25252525,false);
	cout << solve(m) << endl;
	return 0;
}


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

using namespace std;

const int N = 100000 + 77;
int n , k , a[N];
bool W[N];
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n >> k;
   for(int i = 1;i <= n;++ i)
      cin >> a[i];
   for(int i = 1;i <= k;++ i){
      for(int j = 1;j <= n;++ j){
         if(a[j] > i)
            continue ;
         W[i] |= ! W[i - a[j]];
      }
   }
   if(W[k])
      cout << "First";
   else
      cout << "Second";
   return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> v[i];
        ans += v[i];
    }
    cout << ans - n << endl;
}

Measured memory_bytes: 256
// AtCoder Beginner Contest 127 - Problem A: Ferris Wheel (https://atcoder.jp/contests/abc127/tasks/abc127_a)
#include <bits/stdc++.h>

using namespace std;

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

    cout << (A >= 13 ? B : (A >= 6 ? B / 2 : 0)) << endl;

    return 0;
} 


Measured memory_bytes: 256
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def read_into(*A):
    for arr, a in zip(A, read_ints()):
        arr.append(a)


def solve():
    """
    dp[400][400] = 160.000*10 = 1.600.000

    dp[x+a[i]][y+b[i]] = min(dp[x+a[i]][y+b[i]], c[i]+dp[x][y])
    dp[0][0] = 0
    """
    n, ma, mb = read_ints()
    A, B, C = [], [], []
    for _ in range(n):
        read_into(A, B, C)
    dp_upper_A, dp_upper_B = max(A)*n+1, max(B)*n+1
    dp = [
        [[math.inf]*dp_upper_B for _ in range(dp_upper_A)] for _ in range(n+1)
    ]
    dp[0][0][0] = 0
    for i in range(n):
        for x in range(dp_upper_A):
            for y in range(dp_upper_B):
                if dp[i][x][y] == math.inf:
                    continue
                dp[i+1][x][y] = min(dp[i+1][x][y], dp[i][x][y])
                dp[i+1][x+A[i]][y+B[i]] = min(dp[i+1][x+A[i]][y+B[i]], C[i]+dp[i][x][y])
    i = 1
    min_cost = math.inf
    while i*ma < dp_upper_A and i*mb < dp_upper_B:
        min_cost = min(min_cost, dp[n][i*ma][i*mb])
        i += 1
    return -1 if min_cost == math.inf else min_cost


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 138856
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
#pragma endregion


// Effective std
#pragma region ESTD

template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }

template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }

template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }

template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }

template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }

template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }

#pragma endregion


// ??°?????????????????¬??????
#pragma region GRAPH

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

#pragma endregion

// ?´???°
#pragma region PRIME
bool is_prime(unsigned n) {
  switch(n) {
    case 0:
    case 1: return false;
    case 2: return true;
  }
  if (n%2==0) return false;
  for (unsigned i=3; i*i<=n; i+=2)
    if (n%i==0) return false;
  return true;
}
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion

int main() {
  int n, min;
  int ans = INT_MIN;
  cin >> n;
  cin >> min;
  rep(i,n-1) {
    int x;
    cin >> x;
    int p = x - min;
    if(p>ans) ans = p;
    if(x<min) min = x;
  }
  P(ans);

  return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
// string s;

int main() {
    VVi a(3, Vi(3));
    REP(i, 3) REP(j, 3) cin >> a[i][j];
    V<V<bool>> x(3, V<bool>(3, false));

    cin >> n;
    REP(cnt, n) {
        int b; cin >> b;
        REP(i, 3) REP(j, 3) {
            if (a[i][j] == b) {
                x[i][j] = true;
            }
        }
    }

    REP(i, 3) {
        bool g = true;
        REP(j, 3) g &= x[i][j];
        if (g) {
            std::cout << "Yes" << '\n';
            return 0;
        }
    }

    REP(i, 3) {
        bool g = true;
        REP(j, 3) g &= x[j][i];
        if (g) {
            std::cout << "Yes" << '\n';
            return 0;
        }
    }

    bool g = true;
    REP(i, 3) g &= x[i][i];
    if (g) {
        std::cout << "Yes" << '\n';
        return 0;
    }
    g = true;
    REP(i, 3) g &= x[i][2-i];
    if (g) {
        std::cout << "Yes" << '\n';
        return 0;
    }

    std::cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	ll k,ans;
    cin >> k;
    queue<ll> q;
    for(int i=1;i<10;i++){
    	q.push(i);
    }
    for(int i=0;i<k;i++){
    	ans = q.front();
        q.pop();
        if(ans%10!=0){
        	q.push(10*ans+ans%10-1);
        }
        q.push(10*ans+ans%10);
        if(ans%10!=9){
        	q.push(10*ans+ans%10+1);
        }
    }
    cout << ans;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())

m = n + 1
l = k - 1

ans = m * (m**2 + 5) // 6
ans += l * (2 * l**2 + 3 * l - 5 - 3 * m * (l + 1)) // 6
ans = ans % (10**9 + 7)

print(ans)


Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

// 全パターンのvectorを返す
vector<vector<int>> get_all_combinations(int n){
    vector<vector<int>> ret;
    for(int bit = 0; bit < (1 << n); ++bit){
        vector<int> S;
        for(int i = 0; i < n; ++i){
            if(bit & (1 << i)) {
                S.push_back(i);
            }
        }
        ret.push_back(S);
    }
    return ret;
}

int c[10][1005];

int main(){
    int H, W, K;
    int ans = INF;
    cin >> H >> W >> K;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    rep(div, 1<<(H - 1)){ //横の切り方は2^(H-1)通りある
        int g = 0; // group
        vector<int> id(H);
        rep(i, H) {
            id[i] = g;
            if (div>>i&1) ++g;
        }
        g++;
        rep(i, g){
            rep(j, W){
                c[i][j] = 0;
            }
        }
        rep(i, H){
            rep(j, W){
                c[id[i]][j] += (s[i][j] - '0');
            }
        }
        bool ok = true;
        rep(i, g){
            rep(j, W){
                if(c[i][j] > K){
                    ok = false;
                }
            }
        }
        if(!ok) continue;

        int num = g - 1;
        vector<int> now(g);

        // function
        auto add = [&](int j){
            rep(i, g) now[i] += c[i][j];
            rep(i, g) if(now[i] > K) return false;
            return true;
        };
        rep(j, W){
            if(!add(j)) {
                num++;
                now = vector<int>(g);
                add(j);
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include <vector>
using namespace std;
typedef vector<long long int> Row;
typedef vector<Row> Matrix;
//-------------------------------------------------------------
vector<Row> scan_mat(int n, int m); 
vector<Row> keisan(vector<Row> matrixA, vector<Row> matrixB);
void output(vector<Row> matrixC);
long long int get_ans(vector<Row>matrixA, vector<Row>matrixB, int i, int j);
//--------------------------------------------------------------
int main(void)
{
	int n, m, l; //n=???, m=???
	scanf("%d %d %d", &n, &m, &l);
	
	// vector<Row> matrixA(n, Row(m));
	// vector<Row> matrixB(m, Row(n));
	
	vector<Row> matrixA;  //???????????°???????????£?¨?????????????????????????????????????
	vector<Row> matrixB;
	vector<Row> matrixC;
	
	matrixA = scan_mat(n, m);
	matrixB = scan_mat(m, l);
	matrixC = keisan(matrixA,  matrixB);
	output(matrixC);
	
	return 0;
}
//-------------------------------------------------------
vector<Row> scan_mat(int n, int m)
{
	vector<Row> matrix;
	
	for(int i = 0; i < n; i++){     //??????B??????????????????
		Row row;
		for(int j = 0; j < m; j++){  //?????????????????????
			int a;
			scanf("%d", &a);     //???????????????a?????\???
			row.push_back(a);
		}
		matrix.push_back(row);      //	?????????????????????
	}
	return matrix;
}
//-------------------------------------------------------
vector<Row> keisan(vector<Row> matrixA, vector<Row> matrixB)
{
	int n = matrixA.size();  //????????°
	int l = matrixB[0].size();  //????????°
	
	Matrix matrixC(n, Row(l));  //= long long int x[n][l]
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			matrixC[i][j] = get_ans(matrixA, matrixB, i, j);
		}
	}
	return matrixC;
	
}
//-------------------------------------------------------
void output(vector<Row> matrixC)
{
	int n = matrixC.size();
	int l = matrixC[0].size();
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			if(j > 0){
				cout << " ";
			}
			printf("%lld", matrixC[i][j]);
		}
		printf("\n");
	}
}

//--------------------------------------------------------
long long int get_ans(vector<Row>matrixA, vector<Row>matrixB, int i, int j)
{
	int m = matrixA[0].size();
	long long int ans = 0;
	
	for(int k = 0; k < m; k++){
		ans += matrixA[i][k] * matrixB[k][j];
	}
	return ans;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int a, b;

signed main()
{
    cin >> a >> b;
    printf("%lld\n", (a+b) % 24);
    return 0;
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

struct mint {
    // Preparation: MOD is alrejady defined.
    ll value;
    mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint pow(mint m) const {
        return pow(m.value);
    }
    mint inv() const {
        ll a = value, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }
    mint &operator+=(const mint a) {
        if ((value += a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((value += MOD - a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (value *= a.value) %= MOD;
        return *this;
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    vl cum(n + 5, 0);
    repeat(i, 1, n + 5) {
        cum[i] = cum[i - 1] + i;
    }

    mint ans(0);
    repeat(i, k, n + 1) {
        ll m = cum[i - 1];
        ll M = cum[n] - cum[n - i];
        ans += M - m + 1;
    }
    ans += 1;

    out(ans.value);

    return 0;
}


Measured memory_bytes: 4784
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#define ll long long
using namespace std;

string s,ans;

int main() {
	cin >> s;
	if (s[0] == s[s.length() - 1]) {
		if (s.length() % 2 == 0) {
			ans = "First";
		} else {
			ans = "Second";
		}
	} else {
		if (s.length() % 2 == 0) {
			ans = "Second";
		} else {
			ans = "First";
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512