akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : ITP_1_6_C.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int a[4][3][10],n,b,f,r,v;
	cin >> n;
	for(int i=0;i<4;++i) {
		for(int j=0;j<3;++j) {
			for(int k=0;k<10;++k) {
				a[i][j][k]=0;
			}
		}
	}
	for(int i=0; i<n; ++i) {
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1]+=v;
	}
	for(int i=0;i<4;++i) {
		for(int j=0;j<3;++j) {
			printf(" %d %d %d %d %d %d %d %d %d %d\n"
					,a[i][j][0]
					,a[i][j][1]
					,a[i][j][2]
					,a[i][j][3]
					,a[i][j][4]
					,a[i][j][5]
					,a[i][j][6]
					,a[i][j][7]
					,a[i][j][8]
					,a[i][j][9]);

		}
		if(i==3) break;
		printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::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 trace(...)
#endif


#define M 100010


int main(){
    IOS;
 	
 	
	ll n;cin>>n;
	ll a[n],x=0;
	rep(i,0,n)cin>>a[i],x^=a[i];
	rep(i,0,n)cout<<(a[i]^x)<<" ";
    return 0;
}


Measured memory_bytes: 5172
import java.util.ArrayList;
import java.util.Collections;
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());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		Collections.sort(list, Collections.reverseOrder());
		int count = 0;
		int alice = 0;
		int bob = 0;
		for(int i = 0; i < list.size(); i++) {
			if(count % 2 == 0) {
				alice += list.get(i);
			}else {
				bob += list.get(i);
			}
			count++;
		}
		int ans = alice - bob;
		System.out.println(ans);
	}
}

Measured memory_bytes: 22100
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>

using namespace std;

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

int gcdarray(vector<int> &arr, int n)
{
	int g;
	if (n == 0)
	{
		g = arr.back();
	}
	else
	{
		g = arr[0];
	}
	for (int i = 1; i < arr.size(); i++)
	{
		if (i != n)
		{
			g = gcd(g, arr[i]);
		}
	}
	return g;
}

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

	vector<int> all;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		all.push_back(x);
	}

	vector<int> gcds;
	gcds.push_back(all[0]);
	for (int i = 1; i < n; i++)
	{
		gcds.push_back(gcd(gcds.back(), all[i]));
	}

	int ans = gcdarray(all, 0);

	for (int i = 1; i < n; i++)
	{
		if (gcds[i] < gcds[i - 1])
		{
			ans = max(ans, gcdarray(all, i));
		}
	}
	cout << ans << "\n";

}

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int H,W; cin >> H>>W;
    int h,w; cin >> h>>w;
    cout<<((H-h)*(W-w))<<endl;

}


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

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

using namespace std;
using namespace atcoder;

int main(){
	int n,q; scanf("%d%d",&n,&q);

	dsu U(n);
	rep(_,q){
		int t,u,v; scanf("%d%d%d",&t,&u,&v);
		if(t==0) U.merge(u,v);
		else     printf("%d\n",U.same(u,v));
	}

	return 0;
}


Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  vector<int> a(n-1);
  for(int i=0;i<n-1;i++){
    cin>>a[i];
  }
  vector<int> x(n+1);
  for(int i=0;i<n;i++){
    x[a[i]]++;
  }
  for(int i=1;i<=n;i++){
    cout<<x[i]<<endl;
  }
}

Measured memory_bytes: 4780
import math
def S(N) :
    for i in range(2, int(math.sqrt(N))+1) :
        if N % i == 0 :
            return 'F'
    return 'T'
    

n = int(input())
ans = 0
for j in range(n) :
    a = int(input())
    if S(a) == 'T' :
        ans += 1

print(ans)


Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
  string S;
  cin >> S;
 
  int a=0,b=0,c=0;
  for (int i=0; i<S.length(); ++i)
  {
    if (S[i]=='a') a++;
    if (S[i]=='b') b++;
    if (S[i]=='c') c++;
  }
 
  //cout << S.length() << a << b << c << endl;
  string ans = "YES";
  if ((abs(a-b)<=1)&&(abs(b-c)<=1)&&(abs(c-a)<=1))
  {
    ans = "YES";
  }
  else
  {
    ans = "NO";
  }
 
  cout << ans << endl;
 
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,K;string S;cin>>N>>K>>S;
	map<char,char> s;s['A']='a';s['B']='b';s['C']='c';
	S.at(K-1)=s[S.at(K-1)];
	cout<<S<<endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,m,x=get_i
fine=array(n+1,1,0)
a=get_i
m.times do|i|
  fine[a[i]]=1
end
min=105
temp=0
x.upto(n) do|i|
  temp+=fine[i]  
end
min=temp if min>temp
temp=0
x.downto(0) do|i|
  temp+=fine[i]
end
min=temp if min>temp
puts min

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

#define MAX_A 200001

int main(){

    int n,m;
    cin >> n >> m;
    vector<bool> a(MAX_A,false);//1とi
    vector<bool> b(MAX_A,false);//iとN
    int l,k;
    for(int i = 0;i < m;i++){
        cin >> l >> k;
        if(l == 1){
            a[k] = true;
        }
        if(k == n){
            b[l] = true;
        }
    }

    for(int i = 0;i < n;i++){
        if(a[i] == true && b[i] == true){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <algorithm>
#include <vector>
#define NMAX 105
#define WMAX 10005
//#define SELECTED 1
//#define UNSELECTED 0

using namespace std;

struct Item {
    int value,weight;
};

int N,W;
Item items[NMAX+1]; // ??°????¬¬i???????????????????????????
int C[NMAX+1][WMAX+1]; // C[i][w]??¨??????i??????????£???\?????????W???????????¶?????????????????§???
//int G[NMAX+1][WMAX+1]; // G[i][w]??°?????¨?????????w????????????????????????????¢??????????

void compute(int &maxValue
//            , vector<int> &selection
            ) {
    //????????§?°?w???0?????????????????°i???0??¶?????????????????????0?????????C???w=0???i=0????????????????´??????¨??¨????§???????0.
    for(int w=0;w<=W;w++)
        C[0][w]=0;
    for(int i=1;i<=N;i++)
        C[i][0]=0;

    for(int i=1;i<=N;i++) {
        for(int w=1;w<=W;w++) {
            C[i][w]=C[i-1][w];// C[i][w]????°??????\??§???C[i-1][w]?????§?°?
//            G[i][w]=UNSELECTED;
            if(items[i].weight>w) // ???????¬¬i???????????????????¶???????w?????£??????????????????????????????????????????????????????
                continue;// ?????¢C[i-1][w-items[i].weight]????¶????
            if(items[i].value+C[i-1][w-items[i].weight]>C[i-1][w]){// ?????????????????¶??????
                C[i][w]=items[i].value+C[i-1][w-items[i].weight];// ??´?????¨???????????????w????????????????¬¬i??¶???????????\???
//                G[i][w]=SELECTED;
            }

        }
    }
    maxValue=C[N][W];
//    selection.clear();
//    for(int i=N,w=W;i>=1;i--) {
//        if(G[i][w]==SELECTED) {
//            selection.push_back(items[i].value);
//            w-=items[i].weight;
//        }
//    }
//    reverse(selection.begin(), selection.end());
}

void input() {
    cin>>N>>W;
    for(int i=1;i<=N;i++)
        cin>>items[i].value>>items[i].weight;
}

int main() {
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue
//            ,selection
    );

    cout<<maxValue<<endl;

    /*cout<<endl;
    for(int n=0;n<=N;n++)
    {
        for(int m=0;m<=W;m++)
        cout<<G[n][m]<<" ";
        cout<<endl;
    }*/
    /*cout<<"??????????????????????????????";
    for(int i=0;i<selection.size();i++)cout<<selection[i]<<" ";*/

}

Measured memory_bytes: 7048
//
//  main.cpp
//  
//
//  Created by yataka on 2018/10/11.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    int ans[50] = {};
    int a, b;
    for(int i =0; i < M; i++){
        cin >> a >> b;
        ans[a]++, ans[b]++;
    }
    for(int i = 1; i <= N; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n, m, x; cin >> n >> m >> x;
    vint a(m); vin(a);
    int d = a.end() - lower_bound(all(a), x);
    int e = upper_bound(all(a), x) - a.begin();

    print(min(d, e));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
ll LCM(ll x, ll y) { 
  return x * y / GCD(x, y);
}

int main(){
  double a, b; cin >> a >> b;
  cout << ceil((b-1) / (a-1)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void){
    int seat,n,i,a=0,b=0,c=0,d=0;
    for(i=1;i<=4;i++){
        scanf("%d %d",&seat ,&n);
        
        if(seat==1){
            a=6000*n;
            printf("%d\n",a);
            
        }
        
        if(seat==2){
            b=4000*n;
            printf("%d\n",b);            
        }
        
        if(seat==3){
            c=3000*n;
            printf("%d\n",c);            
        }
        
        if(seat==4){
            d=2000*n;
            printf("%d\n",d);            
        }
        
    }
    
    
}


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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  while(cin >> n) {
    if(!n) return 0;
    int p, a, b;
    int maxs = 0, ans;
    rep(i, 0, n) {
      cin >> p >> a >> b;
      if(maxs < a + b) maxs = a + b, ans = p;
    }
    cout << ans << " " << maxs << endl;
  }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> d(n, vector<int>(2));
  rep(i, n) rep(j, 2) cin >> d[i][j];
  for (int i = 0; i + 2 < n; i++) {
    if (d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1] &&
        d[i+2][0] == d[i+2][1]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
n=int(input())
m=100000000000
for i in range(1,int((n)**(1/2))+1):
  if n%i==0:
    num1=i
    num2=n//i
    l1=len(str(num1))
    l2=len(str(num2))
    m1=max(l1,l2)
    if m>m1:
      m=m1
print(m)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,k;
int d[100100];
vector<pair<int,int> > qujian;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		scanf("%1d",&d[i]);
	for(int i=1;i<=n;i++){
		if(d[i]==0){
			int j=i;
			while(!d[j]&&j<=n)
				j++;
			qujian.push_back(make_pair(i,j-1));
			i=j;
		}
	}
	int m=qujian.size();
	if(m<=k){
		cout<<n<<endl;
		return 0;
	}
	int res=0;
	for(int i=qujian.size()-1;i>=0;i--){
		int j=min(i+k-1,m-1);
		int L=(i==0)  ?(0)  :(qujian[i-1].second);
		int R=(j==m-1)?(n+1):(qujian[j+1].first);
		res=max(res,R-L-1);
	}
	cout<<res<<endl;
	return 0;
}


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



int main(){
    ll N  , K = 1000000000000001;
    cin >> N;
    N;
    ll num = 1;
    ll cnt = 0;
    ll tmp_N = N;
    while(tmp_N > 0){
        num *= 26;
        tmp_N -= num;
        cnt++;
    }

    
    tmp_N = N;
    ll tmp = 1;
    for(int i = 0; i < cnt - 1; i++){
        tmp *= 26;
        tmp_N -= tmp;
    }
    
    num /= 26;

    string str ="";

    for(int i = 0; i < cnt; i++) str.push_back('a');

    ll div = 1;
    for(int i = 0; i < cnt - 1; i++){
        div *= 26;
    }

    tmp_N--;
    for(int i = 0; i < cnt; i++){
        str[i] += tmp_N / div;
        tmp_N = tmp_N % div;
        div /= 26;
    }

    cout << str << endl;
}


/**
 * やりたいことは26の累乗を引いていって、引けた回数で桁数が確定。
 * 桁数-1の26の累乗で割れる回数で文字を勧めていく
 **/


Measured memory_bytes: 3620
#include <iostream>
#include <map>
#include <vector>
using namespace std; using P=pair<int,int>; using ll=long long;
struct tp {int x,y,i; bool operator<(const tp tt) const {if (x==tt.x) return y<tt.y; else return x<tt.x;}};

int main() {
  int n,t; cin>>n>>t;
  int an=1e9;
  for(int i=0;i<n;i++) {
    int c,u; cin>>c>>u;
    if (u<=t) an=min(an,c);
  }
  if (an==1e9) cout<<"TLE"<<endl;
  else cout<<an<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static long f(long a) {
		if (a < 0) a = 0;
		if(a % 2 == 0) {
			if(a % 4 == 0) return a;
			else return a+1;
		}
		else {
			if((a+1) % 4 == 0) return 0;
			else return 1;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		System.out.println(f(A-1) ^ f(B));
	}

}

Measured memory_bytes: 23124
function main(input) {
  let [n,m] = input[0].trim().split(" ").map(i => parseInt(i));

  let [a,b] = [[],[]];
  let adjacentList = [];
  for(let i=1;i<m+1;i++){
    [a[i],b[i]] = input[i].trim().split(" ").map(i => parseInt(i-1));
    if(adjacentList[a[i]]===undefined){
      adjacentList[a[i]]=[];
    }
    adjacentList[a[i]].push(b[i]);
    if(adjacentList[b[i]]===undefined){
      adjacentList[b[i]]=[];
    }
    adjacentList[b[i]].push(a[i]);
  }

  let visited = new Array(n).fill(-1);

  let queue = [0];

  while(queue.length != 0) {
    let currentNode = queue.pop()

    for(let nextNode of adjacentList[currentNode]) {
      if(visited[nextNode] != -1) continue
      visited[nextNode] = currentNode+1;
      queue.unshift(nextNode);
    }
  }
  console.log("Yes")
  visited.shift()
  console.log(visited.map((i)=>(i+"\n")).join(""))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 113264
def main():
    n, m = map(int, input().split())
    a = [int(input()) for _ in range(m)]
    s = [True for _ in range(n + 1)]

    for ai in a:
        s[ai] = False

    print(solve(n, s))

def solve(n, s):
    M = 10 ** 9 + 7

    dp = [0 for _ in range(n + 1)]
    dp[0] = 1

    if s[1]:
        dp[1] = 1
    
    for i in range(2, n + 1):
        if s[i]:
            dp[i] = (dp[i-2] + dp[i-1]) % M
        else:
            dp[i] = 0
    
    return dp[n]


main()


Measured memory_bytes: 8624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int a, p;
    cin >> a >> p;

    cout << (a * 3 + p) / 2 << endl;

    return 0;
}

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

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


int main(){
    ll n; cin >> n;
    ll ans = 1e18;
    for (ll i=1;i*i<=n;i++){
        if(n%i != 0) continue;

        ll j = n/i;
        ans = min(ans, i+j-2);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll A, B;

int main() {
	cin >> A >> B;
	ll ans = A - 1;
	if (B >= A)cout << ans + 1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = str(input())

cnt_A=0
cnt_Z=0
max=0
N=len(s)
for i in s:
	if i!='A':
		cnt_A+=1
	else:
		break

for i in range(-1,-200000,-1):
	if s[i]!='Z':
		pass
	else:
		break
#print(cnt_A)
#print(i)

print(N+(i+1)-cnt_A)


Measured memory_bytes: 3512
import java.util.*
import java.io.*

val MOD = 924844033

fun main(args: Array<String>)
{
	Thread(null, Main(), "whatever", 1 shl 28).start()
}

class Main : Runnable {

	override fun run()
	{
		val inputStream = System.`in`
		val outputStream = System.out
		val `in` = InputReader(inputStream)
		val out = PrintWriter(outputStream)
		val solver = TaskD()
		var test = 1
		test = `in`.nextInt()
		for (t in 1..test)
		{
			solver.solve(t, `in`, out)
		}
		out.close()
	}

	internal class TaskD
	{
		fun solve(testNumber: Int, `in`: InputReader, out: PrintWriter) {
			val INF = 4000000000000000000L
			val dx = intArrayOf(-1, 1, 0, 0)
			val dy = intArrayOf(0, 0, -1, 1)

			var n = `in`.nextLong()
			var a = LongArray(3, {`in`.nextLong()})
			var b = longArrayOf(2, 3, 5)
			var d = `in`.nextLong()

			var f = TreeMap<Long, Long>()
			f[0] = 0
			fun solve(n: Long): Long
			{
				if (f.contains(n)) return f[n]!!
				var ret = INF
				for (i in 0..2)
				{
					for (x in arrayOf(n/b[i], n/b[i]+1))
						if (x < n)
						{
							ret = Math.min(ret, solve(x)+a[i]+Math.abs(n-x*b[i])*d)
							if (x*(b[i]-1) <= a[i]/d) ret = Math.min(ret, solve(x)+x*(b[i]-1)*d+Math.abs(n-x*b[i])*d)
						}
				}
				f[n] = ret
				return ret
			}

			var res = solve(n)
			out.println(res)
		}
 
	}

	internal class InputReader(stream: InputStream) {
		var reader: BufferedReader
		var tokenizer: StringTokenizer? = null

		init {
			reader = BufferedReader(InputStreamReader(stream), 32768)
			tokenizer = null
		}

		operator fun next(): String {
			while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
				try {
					tokenizer = StringTokenizer(reader.readLine())
				} catch (e: IOException) {
					throw RuntimeException(e)
				}

			}
			return tokenizer!!.nextToken()
		}

		fun nextInt(): Int {
			return Integer.parseInt(next())
		}

		fun nextLong(): Long {
		    return next().toLong()
		}

	}
}

fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a%b)

fun power(a: Long, b: Long, p: Long): Long
{
	if (b == 0L) return 1L
	var t = power(a, b/2, p)
	t = t*t%p
	if (b%2 == 1L) t = t*a%p
	return t
}


Measured memory_bytes: 57640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vll>;
df data(n, vll(m));
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
*/


/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/range/algorithm.hpp> // boost::sort(arr)
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
using boost::algorithm::join; // string s = join(arr, "");
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int div_count(int a) {
  int div = 0;
  while (a % 2 == 0) {
    ++div;
    a /= 2;
  }
  return div;
}

int main() {
  int n;
  cin >> n;
  int max_div = 0;
  int ans = 1;
  for (int i = 1; i <= n; ++i) {
    int div = div_count(i);
    if (div > max_div) {
      max_div = div;
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String s[] = sc.next().split("");

        int count = 1;

        for (int i = 0; i < n-1; i++) {
            if (!(s[i].equals(s[i+1]))) {
                count++;
            }
        }

        System.out.println(count);
	}
}


Measured memory_bytes: 34148
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    if 500*i > x:
        break
    for j in range(b+1):
        y = 500*i+100*j
        if y > x:
            break
        z = x - y
        if z // 50 <= c:
            cnt += 1
print(cnt)

Measured memory_bytes: 3316
/**
 *    created by : PawPaw       
**/

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

#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)

void nope(){
  cout << "No\n";
  exit(0);
}

void yes(){
  cout << "Yes\n";
  exit(0);
}

int solve(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  if(n % 2) nope();
  F(i, 0, n/2 - 1){
    if(s[i] != s[n/2 + i]) nope();
  }
  yes();
  return 0;
}

void fun(){
  int t = 1;
  // cin >> t;
  while(t--) solve();
} 

int main(){
  ios::sync_with_stdio(false); 
  cin.tie(0);
  // #ifndef ONLINE_JUDGE
  //   freopen("fi", "r", stdin);
  //   freopen("fo", "w", stdout);
  //   clock_t startClock, endClock;
  //   startClock = clock();
  // #endif

  fun();

  // #ifndef ONLINE_JUDGE
  //   endClock = clock(); 
  //   cout << "Time taken by program is : " << fixed <<  double(endClock - startClock) / double(CLOCKS_PER_SEC) << setprecision(5) << " sec " << endl; 
  // #endif
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int l=0;
long long  x,a[100],b[100];
long long tot=0;
void work(){

	long long ans=0,cur=b[l];
	for (int i=l-1;i>=1;i--){
		if (a[i]==1) cur =cur*10+b[i];
		if (a[i]==0)  {
			ans+=cur;
			cur=b[i];
		}
	}
	ans +=cur;
//	cout << ans << endl;
	tot+=ans;
//	cout << "shuai";

}
void f(int cur){
	if (cur==l) {
	//	for (int i=l-1;i>=1;i--) cout << a[i];
		//cout << endl;
		work();
		return ;
	}
	a[cur]=0;f(cur+1);
	a[cur]=1;f(cur+1);
}

int main(){
	cin >> x;
	long long xx=x;;
	while(xx>0){
		b[++l]=xx%10;
		xx/=10;
	}
	//for (int i=1;i<=l;i++)cout << b[i];
	f(1);
	cout << tot;	
}

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

using namespace std;

class Sum {
public:
    explicit Sum(const vector<long long>& v) : sum(v.size()+1, 0), stepSum(v.size()+1, 0) {
        for(int i=0;i<v.size();i++) sum[i+1] = v[i];
        for(int i=0;i<v.size();i++) stepSum[i+1] = sum[i+1] + sum[i] + stepSum[i];
    }
    long long getStepSum(int s, int e) const {
        return stepSum[e] - stepSum[s] - sum[s];
    }
    long long getSum(int e) const {
        return sum[e];
    }
private:
    vector<long long> sum;
    vector<long long> stepSum;
};

int main(){
    int L, N;
    while(cin >> L >> N){
        vector<long long> X(N), Y(N);
        for(int i=0;i<N;i++){
            cin >> X[i];
            Y[N-i-1] = L - X[i];
        }
        long long res = max(X.back(), Y.back());
        Sum sx(X), sy(Y);
        for(int i=1;i<N;i++){
            int nx = i;
            int ny = N-i;
            int m = min(nx, ny);
            res = max(res, sx.getStepSum(nx-m, nx) + sy.getStepSum(ny-m, ny) + max(sx.getSum(nx), sy.getSum(ny)));
            {
                int mx = min(m+1, nx);
                int my = mx - 1;
                if(my > 0){
                    res = max(res, sx.getStepSum(nx-mx, nx) + sy.getStepSum(ny-my, ny) + sy.getSum(ny));
                }
            }
            {
                int my = min(m+1, ny);
                int mx = my - 1;
                if(mx > 0){
                    res = max(res, sx.getStepSum(nx-mx, nx) + sy.getStepSum(ny-my, ny) + sx.getSum(nx));
                }
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 9600
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	int a, b;

	cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int a[102];
void solve()
{
  int t, x, n, ans, dif=1e9;
  cin >> x >> n;
  for(int i=0; i<n; i++)
    cin >> t, a[t] = 1;
  
  for(int i=0; i<=101; i++)
    if(!a[i] && dif>abs(i-x))
      ans = i, dif = abs(i-x);
  cout << ans << "\n";
}
int main()
{
  fastio
  solve();
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int A, B;
    cin >> A >> B;

    if (A >= 9 || B >= 9)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    while(1) {

            int i, j, h, w;

            scanf("%d %d", &h, &w);

            if(h == 0 && w == 0) {

                break;
            }

            for(i = 1; i <= h; i++) {

                for(j = 1; j <= w; j++) {

                    if(i != 1 && i != h && j != 1 && j != w) {
                        printf(".");
                    }

                    else {

                        printf("#");
                    }
                }

                printf("\n");
            }

            printf("\n");
    }

    return 0;
}


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

using namespace std;

using ll = long long;

int main(void) {
    int n;
    scanf("%d", &n);
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);
    int swaps = 0;
    for (int i = 0; i < n; i++) {
        int mini = i;
        for (int j = i + 1; j < n; j++) {
            if (arr[j] < arr[mini]) 
                mini = j;
        }
        if (mini != i) {
            swap(arr[i], arr[mini]);
            ++swaps;
        }
    }
    for (int i = 0; i < n - 1; i++)
        printf("%d ", arr[i]);
    printf("%d\n%d\n", arr[n - 1], swaps);
    return 0;
}


Measured memory_bytes: 3208
object Main {
    def check(n: Int, arr: List[String]) = {
        val vowels = List('a', 'i', 'u', 'e', 'o')
        val x = arr.map(s => (s.head + s.zip(s.tail).collect{case cc if vowels.contains(cc._1) => cc._2}.mkString).take(n))
        x.size == x.distinct.size
    }
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines
        for (n <- in if n != "0") {
            val x = in.take(n.toInt).toList
            (1 to 50).find(d => check(d, x)) match {
                case Some(x) => println(x)
                case None => println(-1)
            }
        }
    }
}

Measured memory_bytes: 242392
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
main(){
  int n;
  while(1){
    scanf("%d",&n);
    if(n==-1) break;
    double an=2*M_PI;
    double x=0,y=0;
    double k=1;
    for(int i=2;i<n+2;i++){
      an+=asin(1/k);
      x=cos(an)*k;
      y=sin(an)*k;
      k=sqrt(i);
    }
    printf("%.2lf\n%.2lf\n",y,-x);
  }
}

Measured memory_bytes: 0
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


A, B, M = invr()

a = inlist()  # all fridger cost list
b = inlist()  # all oven cost list

C = []
for i in range(M):
    C.append(inlist())

costs_of_using_tickets = [0] * M

for i in range(M):
    ci = C[i]
    costs_of_using_tickets[i] = a[ci[0]-1] + b[ci[1]-1] - ci[2]

cost_of_not_using_tickets = min(a) + min(b)

print(min(cost_of_not_using_tickets, min(costs_of_using_tickets)))


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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
// http://arcslab.hatenablog.jp/entry/ARC091
int main() {
  ll N, K;
  cin >> N >> K;
  ll cnt = 0;
  if (K == 0) {
    cnt = N * N;
  } else {
    for (int b = K + 1; b <= N; b++) {
      int seq = (N + 1) / b;
      cnt += seq * (b - K);
      int r = (N + 1) % b - K;
      if (r >= 1)
      cnt += r;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int freq[26];

int main() {
    fast();
    ll n;cin>>n;
    int arr[n];
    int freq[n]={0};
    for (int i = 0; i <n ; ++i) {
        cin>>arr[i];
        if(((n%2==0)&&(arr[i]%2==0))||((n%2!=0)&&(arr[i]%2!=0)))return cout<<0,0;
        freq[arr[i]]++;
    }
    for (int j = n-1; j >=0 ; j-=2) {
        if(j>=1&&freq[j]!=2)return cout<<0,0;;
        if(j==0&&freq[j]!=1)return cout<<0,0;
    }
    ll mod=1e9+7;
    cout<<binpow(2,n/2,mod);
}

Measured memory_bytes: 1024
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------

s = input()		# 文字列の入力  abcdefg...
n = len(s)

def isKB(s):
	
	b = False
	for i in range((len(s)+1)//2):
		
		#p(i, s[i], " _ ",-i-1, s[-i-1])
		
		if s[i]!=s[-i-1]: break
		
	else:
		b = True

	return b


#p(s, s[:((n-1)//2)], "((n+3)//2)-1=",((n+3)//2)-1, s[((n+3)//2)-1:n])

ans="No"

if isKB(s):
	if isKB(s[:((n-1)//2)]):
		if isKB(s[((n+3)//2)-1:n]):
			ans="Yes"

print(ans)



Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else if (b % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else if ((a + b) % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while 1:
  m,n=map(int,input().split())
  if m+n==0: break
  
  if m**n<10000:
    print(m**n)
    continue
  
  s=str(m**n)
  while len(s)%4>0: s="0"+s
  
  us=["","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"]
  for i in range(0,len(s),4):
    x=int(s[i:i+4])
    if x==0: continue
    print(str(x)+us[(len(s)-i)//4-1],sep="",end="")
  print()

Measured memory_bytes: 6728
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=2100;
const ll mod=924844033;

inline ll zarb(ll a,ll b){
	ll e=(a*b)%mod;
	if(e<0)return e+mod;
	return e;
}
inline void jam(ll &a,ll b){
	a+=b;
	if(a>=mod)a-=mod;
}

ll fac[maxn];
ll f[maxn];
ll dp[maxn][maxn][2];
bool dif[maxn];

void add(ll tol,ll tedad){
	ll v=1;
	while(v<maxn){
		dif[v]=1;
		if(tedad){
			v+=tol;
			tedad--;
		}else{
			v+=(tol+1);
		}
	}
}
int main(){
	ll n,k,tol,tedad;
	cin>>n>>k;
	tol=n/k;
	tedad=k-n%k;

	add(tol,tedad);

	fac[0]=1;
	for(ll i=1;i<maxn;i++){
		fac[i]=zarb(fac[i-1],i);
	}
	
	dp[0][0][0]=1;
	dp[0][0][1]=1;
	for(ll i=1;i<=n;i++){
		bool b=!dif[i];
		for(ll j=0;j<=i;j++){
			dp[i][j][1]=dp[i-1][j][1];
			dp[i][j][0]=dp[i-1][j][1];
			if(b){
				if(i>=2 && j>=2){
					jam(dp[i][j][1],dp[i-2][j-2][1]);
				}if(i && j){
					jam(dp[i][j][1],dp[i-1][j-1][0]);
					jam(dp[i][j][1],dp[i-1][j-1][0]);

					jam(dp[i][j][0],dp[i-1][j-1][0]);
				}
			}
		}
	}
	for(ll i=0;i<=n;i++){
		f[i]=dp[n][i][1];
	}
	ll ans=0;
	ll t=1;
	for(ll i=0;i<=n;i++){
		ans+=zarb(zarb(f[i],fac[n-i]),t);
		t*=-1;
	}
	ans%=mod;
	cout<<ans;
}




















Measured memory_bytes: 66048
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7
dp = [-1]*(n+1)
for i in para:
    dp[i] = 0
for i in range(n+1):
    if  dp[i] != 0 :
        if i == 1 or i==0:
            dp[i] = 1
        else:
            dp[i] = (dp[i-1] + dp[i-2])%mod



print("{}".format(dp[-1]))

Measured memory_bytes: 7848
import numpy as np

a = input()
a, b = a.split()
a = int(a)
if int(b) == 0:
  print(a)
  exit()
n = input()
n = [int(i) for i in n.split()]
li = list(range(-250, 250))
for i in n:
  li.remove(i)
mini = [np.inf, 0]
for i in li:
  if abs(i - a) == mini[0]:
    if i < mini[1]:
      mini = [abs(i - a), i]
  elif abs(i - a) < mini[0]:
    mini = [abs(i - a), i]
print(mini[1])

Measured memory_bytes: 27164
X = int(input())

def sqrt(x):
    last_guess=x/2
    while True:
        guess=(last_guess+x/last_guess)/2
        if abs(guess-last_guess)<.000001:
            break
        last_guess=guess
    return guess

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def next_prime(N): 
    if (N <= 1): 
        return 2
  
    prime = N 
    found = False
    while(not found): 
        prime = prime + 1
  
        if(is_prime(prime) == True): 
            found = True
  
    return prime 

if 1==X:
    print(2)
    exit(0)
print(next_prime(X-1)) 

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int n;
  int a[3][3];

  map<int, pair<int,int>> m;
  REP(i,3)REP(j,3){
    int t;
    cin >> t;
    a[i][j] = t;
    m[t] = make_pair(i,j);

  }
  cin >> n;

  REP(i,n){
    int t;
    cin >> t;
    if(m.find(t) != m.end()){
      int p = m.find(t)->second.first;
      int q = m.find(t)->second.second;
      a[p][q]=0;
    }
  }
  REP(i,3){
    bool f=true;
    REP(j,3){
      if(a[i][j]!=0)f=false;
    }
    if(f){
      cout << "Yes" << endl;
      exit(0);
    }
  }
  REP(i,3){
    bool f=true;
    REP(j,3){
      if(a[j][i]!=0)f=false;
    }
    if(f){
      cout << "Yes" << endl;
      exit(0);
    }
  }
  if((a[0][0]==0 && a[1][1]==0 && a[2][2]==0) ||
      (a[0][2]==0 && a[1][1]==0 && a[2][0]==0)){
      cout << "Yes" << endl;
      exit(0);
    }
  cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  // 入力
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  unordered_map<int,int> map;
  // bit 全探索
  bool exist = false;
  for (int bit = 0; bit < (1 << N); ++bit) {
    int sum = 0;
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) sum += a[i];
    }
    map[sum]++;
  }
  int q;
  cin >> q;
  rep(i,q){
    int w; cin >> w;
    if(map[w]!=0) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}



Measured memory_bytes: 3184
import java.util.*;

public class Main {
    public static void insertionSort(int[] A, int N){
        for(int i=1; i<N; i++){
            int v = A[i];
            int j = i-1;
            while(j>=0 && A[j]>v ){
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = v;
            
            for(j=0; j<N; j++){
                System.out.print(A[j]);
                if(j!=N-1) System.out.print(" ");
            }
            System.out.println("");
        }
    }
    
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[100];
        
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            System.out.print(A[i]);
            if(i != N-1) System.out.print(" ");
        }
        System.out.println("");
        
        insertionSort(A,N);
        
        
        
    }
}

Measured memory_bytes: 33852
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      int N = sc.nextInt();
	  String S = sc.next();
      String[] al = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
           "S","T","U","V","W","X","Y","Z"};
      String kitta = "";
      int Sl=S.length();
      for(int i=0;i<Sl;i++){
        kitta=S.substring(i,i+1);
        for(int j=0;j<26;j++){
          if(kitta.equals(al[j])){
            System.out.print(al[(j+N)%26]);
          }
        }
      }

        
      

 
      
    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}

Measured memory_bytes: 27676
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(5);
    for(int i = 0; i < 5; i++) cin >> A[i];
    sort(all(A));
    cout << 4 + (N + A[0] - 1) / A[0] << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll maze[1005][1005];

void show_table(ll I, ll J) {
  for (ll i = 0; i <= I; i++) {
    for (ll j = 0; j <= J; j++) {
      ll o = maze[i][j];
      if ((o == INF)) {
        cout << '@';
      } else {
        cout << (o);
      }
      cout << " ";
    }
    cout << "" << endl;
  }
  cout << "" << endl;
}

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll ans = -INF;

  ll H, W;
  scanf("%lld %lld", &H, &W);

  ll Ch, Cw;
  scanf("%lld %lld", &Ch, &Cw);

  ll Dh, Dw;
  scanf("%lld %lld", &Dh, &Dw);

  for (ll y = 0; y < H; y++) {
    string s;
    cin >> s;

    for (ll x = 0; x < s.size(); x++) {
      if (s[x] == '#') {
        maze[y][x] = -1;
      } else {
        maze[y][x] = INF;
      }
    }
  }

  maze[Ch - 1][Cw - 1] = 0;

  // show_table(H, W);

  queue<pll> q;
  q.push(make_pair(Ch - 1, Cw - 1));

  for (;;) {
    if (q.empty()) {
      break;
    }
    auto pos = q.front();
    ll y = pos.first;
    ll x = pos.second;

    ll c = maze[y][x];

    if (y >= 1 && maze[y - 1][x] > c) {
      maze[y - 1][x] = c;
      q.push(make_pair(y - 1, x));
    }
    if (y < H - 1 && maze[y + 1][x] > c) {
      maze[y + 1][x] = c;
      q.push(make_pair(y + 1, x));
    }
    if (x >= 1 && maze[y][x - 1] > c) {
      maze[y][x - 1] = c;
      q.push(make_pair(y, x - 1));
    }
    if (x < W - 1 && maze[y][x + 1] > c) {
      maze[y][x + 1] = c;
      q.push(make_pair(y, x + 1));
    }

    for (ll ox = -2; ox <= 2; ox++) {
      for (ll oy = -2; oy <= 2; oy++) {
        if (abs(ox) + abs(oy) <= 1) {
          continue;
        }
        ll ty = y + oy;
        ll tx = x + ox;
        if (ty < 0 || ty >= H) {
          continue;
        }
        if (tx < 0 || tx >= W) {
          continue;
        }

        if (maze[ty][tx] > c + 1) {
          maze[ty][tx] = c + 1;
          q.push(make_pair(ty, tx));
        }
      }
    }

    q.pop();
  }

  // show_table(H, W);

  ll a = maze[Dh - 1][Dw - 1];

  if (a == INF) {
    cout << (-1) << endl;
    return 0;
  }

  cout << a << endl;
}


Measured memory_bytes: 11844
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

long GetLCM(const long &a, const long &b){
    long x = max(a,b);
    long y = min(a,b);
    while(x % y != 0){
        long t = x % y;
        x = y;
        y = t;
    }
    return a * b / y;  
}

int main(){
    long n,m;
    scanf("%ld %ld", &n, &m);
    vector<long> a(n);
    vector<long> ord(n, 0);
    for(long i = 0; i < n; i++){
        scanf("%ld", &a[i]);
        long k = a[i];
        while(k % 2 == 0){
            k /= 2;
            ord[i]++;
        }
        if(ord[i] != ord[0]){
            printf("%d", 0);
            return 0;
        }
    }
    
    long nLCM = 1;
    for(long i = 0; i < n; i++){
        nLCM = GetLCM(nLCM, a[i]);
        if(nLCM > 2 * m){
            printf("%d", 0);
            return 0;
        }
    }
    long HalfLCM = nLCM / 2;
    long nAns = (m / HalfLCM) - (m / nLCM);
    printf("%ld", nAns);
  
    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

    cout << (n - 1) * (m - 1) << endl;

    return 0;
}

Measured memory_bytes: 256