akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve_ref(long long S){
    ll n = 3;
    for (ll bit = 0; bit < (1<<n); bit++) {
        V v;
        for (ll i = 0; i < n; i++) {
            if(bit & (1<<i)) {
                v.push_back(i);
            }
        }
        cout << bit << ": ";
        for (ll i = 0; i < v.size(); i++) {
            cout << v[i] << " ";
        }
        cout << endl;
    }
}

void solve_old(long long S){
    ll n = log10(S)+1;
    string str = to_string(S);
    V v;
    ll tmp = S;
    ll sum =0;
    for (ll i = 0; i < n; i++) {
        v.push_back(tmp%10);
        tmp/=10;
    }
    n--;
    // if(S<1000) vout(v);
    for (ll bit = 0; bit < (1<<n); bit++) {
        V va;
        tmp = S;
        for (ll i = 0; i <= n; i++) {
            if(bit & (1<<i)) {
                // va.push_back(v[i]);
                // va.insert(va.begin()+i, 10);
                ll p = pow(10,n-i);
                va.push_back(tmp/p);
                tmp = tmp % p;
            }
        }
        va.push_back(tmp);
        // if (S<1000){
        // cout << bit << ": ";
        // for (ll i = 0; i < va.size(); i++) {
        //     cout << va[i] << " ";
        // }
        // cout << endl;}
        sum+=accumulate(all(va), 0LL);
    }
    cout << sum << "\n";
}

void solve(long long S){
    ll n = log10(S)+1;
    n--;
    ll sum =0;
    for (ll bit = 0; bit < (1<<n); bit++) {
        V v;
        ll tmp = S;
        for (ll i = 0; i <= n; i++) {
            if(bit & (1<<i)) {
                ll p = pow(10,n-i);
                v.push_back(tmp/p);
                tmp = tmp % p;
            }
        }
        v.push_back(tmp);
        sum += vsum(v);
    }
    cout << sum << "\n";
}

int main(){
    long long S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>



int n,A[50];


int solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=n)return 0;
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}


int main(){
  int q,mi,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  for(j=0;j<q;j++){

    scanf("%d",&mi);

    if(solve(0,mi))
      printf("yes\n");

    else printf("no\n");

  }

  return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  long long int N;
  cin >> N;
  for(long long int i=1;i<=N*2;i++){
    if(i*i > N){
      i--;
      cout << i*i << endl;
      return 0;
    }
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

using namespace std;

const int N = 2e5 + 5;
const int maxn = 3005;
const int mod = 1e9 + 7;

int h, w, n, fact[N], ifact[N], dp[maxn];
pair <int, int> a[N];

int binPow (int x, int y) {
    int ans = 1;
    while (y > 0) {
        if (y & 1) ans = 1LL * ans * x % mod;
        x = 1LL * x * x % mod;
        y >>= 1;
    }

    return ans;
}

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

void sub (int &x, int y) {
    x -= y;
    if (x < 0) x += mod;
}

int C (int k, int n) {
    if (k > n || k < 0) return 0;
    return 1LL * fact[n] * ifact[k] % mod * ifact[n - k] % mod;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> h >> w >> n; a[n + 1] = {h, w};
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
        ifact[i] = binPow(fact[i], mod - 2);
    }

    for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
    sort(a + 1, a + n + 2);
    for (int i = 1; i <= n + 1; i++) {
        dp[i] = C(a[i].first - 1, a[i].first + a[i].second - 2);
        for (int j = 1; j < i; j++) {
            sub(dp[i], 1LL * dp[j] * C(a[i].first - a[j].first, a[i].first + a[i].second - a[j].first - a[j].second) % mod);
        }
    }

    cout << dp[n + 1];
    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  cin >> n  ;

  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if((i*j)==n){
        cout << "Yes" << endl ;
        return 0 ;
      }
    }
  }  

  cout << "No" << endl ;
  return 0 ;
}

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

  long long calc(int N) {
    int res = 0;
    while(N > 0) {
        res += N % 10;
        N /= 10;
    }
    return res;
  }
 
    
int main() {
    while (cin >> N) {
        long long res = 1LL<<60;
        for (long long i = 1; i < N; ++i) {
            long long j = N - i;
            long long tmp = calc(i) + calc(j);
            res = min(res, tmp);
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 256
xs=[0]*120
for _ in [0]*int(input()):
    b,f,r,v=map(int,input().split())
    xs[(b-1)*30+(f-1)*10+(r-1)]+=v
for j in range(0,4):
    for i in range(0,3):
        print('',*xs[j*30+i*10:j*30+i*10+10])
    if j<3: print('#'*20)


Measured memory_bytes: 5612
#include<stdio.h>

int main(void){
  int n;
  int i, j;
  
  if(scanf("%d", &n) == 1)
    for(i=0; i<=(100/4); i++)
      for(j=0; j<=(100/7); j++)
        if( n < (i*4+j*7) ){
          break;
        } else if( n == (i*4+j*7) ){
          printf("Yes\n");
          return 0;
        }
  printf("No\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <climits>

using namespace std;
int N, W;
int w[105];
int v[105];
int dp[105][10100];

int main(){
    cin >> N >> W;
    for(int i=0;i<N;i++){
        cin >> v[i] >> w[i];
    }
    for(int i=0;i<=W;i++) dp[0][i]=0; 
    for(int i=0;i<N;i++){
       for(int j=0;j<=W;j++){
           if(j >= w[i])dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
           else dp[i+1][j]=dp[i][j];
       } 
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7108
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
	int N, A;
	queue<int> Q;

	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A;
		Q.push(A);
	}

	long long product_count = 0;
	int min_price = 1;
	while (Q.size() > 0)
	{
		A = Q.front();
		if (A > min_price)
		{
			int product = (A - 1) / min_price;
			A = 1;
			if (min_price < A)
				min_price = A;
			else if (min_price == A)
				min_price = A + 1;
			product_count += product;
		}
		else if (A == min_price)
			++min_price;
		Q.pop();
	}

	cout << product_count << endl;

	return 0;
}

Measured memory_bytes: 640
height,width=map(int,input().split())
A=[]
for i in range(height):
	A.append([int(j) for j in input().split()])


for i in range(height):
	print(' '.join(map(str,A[i])),str(sum(A[i])))

B=[]
C=[0 for _ in range(width)]
for i in range(width):
	for j in range(height):
		s=0
		s+=A[j][i]
		B.append(s)
	C[i]=sum(B)
	B=[]
print(' '.join(map(str,C)),str(sum(C)))

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

vector < pair< long long , long long > > v ;

int main()
{
	
	long long n ; 
	cin>>n;
	
    for(long long i=1;i<=sqrt(n);i++)
	{
	  if(n%i == 0 )
	  {
	     v.push_back({i,n/i}) ;	
	  }	
	}	
	
	long long total=0,ans=100000000000 ;
	
	for(long long i=0;i<v.size();i++)
	{
	    long long c=0,c2=0,n1 = v[i].first , n2 = v[i].second; 
		
		while(n1>0)
		{
		  c++;
		  n1/=10 ;	
		}	
		
		while(n2>0)
		{
			c2++ ;
			n2/=10; 
		}
		long long temp1 = max(c,c2) ;
		ans = min(ans,temp1) ;
	}
	
	cout<<ans<<"\n" ;
 	return 0;
}

Measured memory_bytes: 384
S = input()
T = input()
 
for i in range(len(S) - len(T), -1, -1):
    for j in range(len(T)):
        if S[i + j] != '?' and S[i + j] != T[j]:
            break
    else:
        print((S[:i] + T + S[i + len(T):]).replace('?', 'a'))
        break
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

ll cnt(vector<int>& a, vector<int>& b, vector<int>& c) {
    // a < b < c
    ll res = 0;
    for(int mid: b) {
        ll pre_a = distance(a.begin(), lower_bound(a.begin(), a.end(), mid));
        ll pre_c = distance(c.begin(), lower_bound(c.begin(), c.end(), mid));
        res += pre_a * (c.size()-pre_c) + (a.size()-pre_a) * pre_c;
        for(int pre: a) {
            int tar = mid*2 - pre;
            auto it = lower_bound(c.begin(), c.end(), tar);
            if (it != c.end() && *it == tar)
                res -= 1;
        }
    }
    return res;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> pos(3, vector<int>());
    for(int i = 0; i < n; i++) {
        if (s[i] == 'R')
            pos[0].push_back(i);
        else if (s[i] == 'G')
            pos[1].push_back(i);
        else
            pos[2].push_back(i);
    }
    ll ans = 0;
    ans += cnt(pos[1], pos[0], pos[2]);
    ans += cnt(pos[0], pos[1], pos[2]);
    ans += cnt(pos[0], pos[2], pos[1]);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3700
import bisect

_ = int(input())
A = list(map(int, input().split()))
_ = int(input())
B = list(map(int, input().split()))

ans = 0

if len(A) > len(B):
    B, A = A, B

for a in A:
    i = bisect.bisect_left(B, a)
    if i >= 0 and i < len(B) and B[i] == a:
        ans += 1
print(ans)


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <memory>

using namespace std;

class ALphabet {
public:
	void solve(std::istream& in, std::ostream& out) {
	    char a;
	    in >> a;
	    if ('A' <= a && a <= 'Z') {
	        out << "A" << endl;
	    } else {
            out << "a" << endl;
        }
	}
};


int main() {
	ALphabet solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll,pair<int,int>> P;//ポイント左右
const ll MOD = 1e9+7;
ll a[100000];
ll rui[100001];
priority_queue<P> q;
int main()
{
	ll n,m;
	ll ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	rui[0]=0;
	for(int i=1;i<n+1;i++)
		rui[i]=rui[i-1]+a[i-1];
	int ok=0;
	int ng=200001;
	while(ng-ok>1)
	{
		int mid=(ng+ok)/2;
		ll cnt=0;
		for(int i=0;i<n;i++)
		{
			int itr=(int)(lower_bound(a,a+n,mid-a[i])-a);
			cnt+=n-itr;
		}
		if(cnt<m)
			ng=mid;
		else
			ok=mid;
	}
	//cerr<<ok<<endl;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		int itr=(int)(lower_bound(a,a+n,ok-a[i])-a);
		ans+=a[i]*(n-itr)+(rui[n]-rui[itr]);
		sum+=(n-itr);
	}
	if(sum>m)
		ans-=(sum-m)*ok;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
const double EPS=1e-8;
bool EQ(double a,double b){
  return abs(a-b)<EPS;
}

typedef vector<ll> vec;
typedef vector<vec> mat;

void fastStream(){
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
int T;
int p,q;
bool check(){
  int cnt=0;
  int div=max(abs(p),abs(q));
  for(int m=-div;m<=div;m++){
    for(int n=-div;n<=div;n++){
      if(m==1&&n==0)continue;
      if(m==0&&n==1)continue;
      if(m==-1&&n==0)continue;
      if(m==0&&n==-1)continue;
      if(m==p&&n==q)continue;
      if(m==-q&&n==p)continue;
      if(m==-p&&n==-q)continue;
      if(m==q&&n==-p)continue;
      if(m*m+n*n>0){
        int a=m*m+n*n;
        int b=p*m+n*q;
        int c=q*m-n*p;
        if(b%a==0&&c%a==0)
          cnt++;
      }
    }
  }
  return cnt==0;
}


int main(){
  cin>>T;
  while(T--){
    cin>>p>>q;
    if(check())cout<<'P'<<endl;
    else cout<<'C'<<endl;
  }

  return 0;
}

Measured memory_bytes: 1152
import java.math.BigInteger;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int n = sc1.nextInt();
		int X = sc1.nextInt();
		int[] x = new int[n];

		for ( int i = 0 ; i < n ; i++ ) {
			x[i] = sc1.nextInt() - X;
		}

		int ans = Math.abs(gcd(x));

		System.out.println(ans);

		sc1.close();

	}

	    public static int gcd(int[] x) {
	        int gcd = IntStream.of(x)
	            .mapToObj(BigInteger::valueOf)
	            .reduce(BigInteger::gcd)
	            .orElse(BigInteger.ZERO)
	            .intValue();

	        //System.out.println(gcd);

	        return gcd;
	    }

}

Measured memory_bytes: 64432
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N, X = map(int, input().split())
    m = [int(input()) for _ in range(N)]

    m.sort()
    X -= sum(m)
    ans = N
    i = 0
    while X>0 and i<N:
        ans += X//m[i]
        X %= m[i]
        i += 1

    print(ans)

if __name__ == '__main__':
    resolve()


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

long long int N, K;

int main(void) {
  cin >> N >> K;
  string D[K];
  for (int i=0; i<K; i++) cin >> D[i];
  int a = 0;
  int ans;
  while (a == 0) {
    string check = to_string(N);
    int b = 0;
    for (int i=0; i<K; i++) {
      int n = check.find(D[i]);
      if (n != string::npos) {
        N++;
        break;
      } else {
        b++;
      }
      if (b == K) {
        ans = N;
        a = 1;
      }
    }
  }
  cout << N << endl;
  return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int all=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        all+=a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    if(4*m*a[m-1]<all) cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

const int m = 1e9 + 7;

ll int count(int n) {
	int dp[n + 1];
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 3; j <= n; j++) {
			if(i - j >= 0)
				dp[i] = (dp[i] + dp[i - j]) % m;
				dp[i] %= m;
		}
	}
	return dp[n];
}

int main() {
	int n;
	cin >> n;
	ll int ans = count(n) % m;
	cout << ans;
}

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

#define ll long long
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define all(a) (a).begin(),(a).end()


signed main(){
    int n;
    cin>>n;
    set<int> se;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        if(se.find(t)==se.end()){
            se.insert(t);
        }else{
            se.erase(t);
        }
    }
    cout<<se.size()<<endl;
    return 0;
}

Measured memory_bytes: 4864
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
#define sqr(x) ((x) * (x))
#ifdef LOCAL
#define dbg(as...) {\
    vector<string> _v; \
    std::stringstream _ss(#as);\
    string _cur, _loc;\
    while (getline(_ss, _cur, ',')) {\
        while (count(_cur.begin(), _cur.end(), '(') != count(_cur.begin(), _cur.end(), ')')) {\
            getline(_ss, _loc, ',');\
            _cur += "," + _loc;\
        }\
    _v.pb(_cur);\
    }\
    err(_v.begin(), as);\
}
#else
#define dbg(as...)
#endif

template<typename T>
void err(vector<string>::iterator it, T a) {
    cerr << it->substr((*it)[0] == ' ') << " = " << a << '\n';
}
template<typename T, typename...Ts>
void err(vector<string>::iterator it, T a, Ts...as) {
    cerr << it->substr((*it)[0] == ' ') << " = " << a << ", ";
    err(++it, as...);
}

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(10);
        #ifdef LOCAL
        srand(300); 
        #else
        srand(time(0));
        #endif
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;

const int MAXN = 1e5;

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

int main() {
    int n, a = 0, b = 0, c = 0;
    cin >> n;

    while (n--) {
        int x;
        cin >> x;
        if (x & 1) ++a;
        else if (x & 2) ++b;
        else ++c;
    }

    if (a > c + 1) no();

    if (a == c + 1) {
        if (b) no();
        yes();
    }

    yes();

    return 0;
}


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

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()

const long long MXN = 1e5 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;

using namespace std;

int n, m, l, r, d, v[MXN];
vector<pair<int, int> > q[MXN];
bool used[MXN];

void dfs(int x){
    //cout << x << ' ';
    used[x] = 1;
    for(int i = 0; i < q[x].size(); i++){
        int to = q[x][i].F, d = q[x][i].S;
        if(used[to] == 1 && v[x] + d != v[to]){
            cout << "No";
            EX;
        }
    }for(int i = 0; i < q[x].size(); i++){
        int to = q[x][i].F, d = q[x][i].S;
        if( used[to] == 0){
            v[to] = v[x] + d;
            dfs(to);
        }
    }
}

int main(){
    ios;
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        q[l].pb(mp(r, d));
        q[r].pb(mp(l, -d));
    }for(int i = 1; i <= n; i++){
        if(used[i] == 0){
            dfs(i);
        }
    }cout << "Yes";
    return 0;
}


Measured memory_bytes: 12160
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <iostream>
using namespace std;


int main()
{
  int N;
  cin >> N;
  int A[10000];
  
  for (int i = 0; i<N; i++) cin >> A[i];
  for (int i = 0; i<N; i++)
  {
      if (A[i]%2 == 0) 
      {
          if ((A[i]%3 != 0) && (A[i]%5 != 0)){
              cout <<"DENIED"<<endl;
              return 0;

          }
      }
  }
  
  cout << "APPROVED" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;


template <class T>
class SegmentTree{
  ll N;                         //葉の数
  vector<T> data;               //データを格納(要素数2*N-1)
  T def;                        //初期値かつoperationの単位元
  function<T(T,T)> operation;   //区間クエリで使う関数ラムダ式で入れる
  function<T(T,T)> update;      //一点更新で使う関数

  T _query(ll a,ll b,ll k,ll l,ll r){   //区間(a,b)を考え半開区間[l,r)が管轄
      if(b <= l || r <= a) return def;  
      if(a <= l && r <= b){
          return data[k];
      }else{
          T c1 = _query(a,b,k*2+1,l,(l+r)/2);   //左の子
          T c2 = _query(a,b,k*2+2,(l+r)/2,r);   //右の子
          return operation(c1,c2);
      }
  }
  public:
  SegmentTree(size_t _N,T _def,function<T(T,T)> _operaition,function<T(T,T)> _update):def(_def),operation(_operaition),update(_update){
          N = 1;                //N必要サイズにNを調整
          while(N < _N){
              N *= 2;
          }
          data = vector<T>(2*N-1,def);
  }

  void change(ll i,T x){
      i += N-1;
      data[i] = update(data[i],x);
      while(i > 0){
          i = (i-1)/2;
          data[i] = operation(data[i*2+1],data[i*2+2]);
      }
  }

  T query(ll a,ll b){
      return _query(a,b,0,0,N);
  }

  T operator[](ll i){
      return data[i+N-1];
  }
};

ll N,K;

int main(){
    cin >> N >> K;
    vector<ll> A(N+1),B(N+1);
    ll sum = 0;
    A[0] = 0;
    rep(i,N){
        cin >> A[i+1];
        sum += A[i+1];
        A[i+1] = sum - (i+1) * K;
    }
    map<ll,ll> mp;
    rep(i,N+1) mp[A[i]] = 0;
    ll cnt = 0;
    for(auto itr = mp.begin();itr != mp.end();itr++){
        itr -> second = cnt;
        cnt++;
    }
    rep(i,N+1){
        B[i] = mp[A[i]];
    }
    auto f = [](ll a,ll b){return a+b;};
    auto g = [](ll a,ll b){return b;};
    SegmentTree<ll> ST(200010,0,f,g);
    ll ans = 0;
    rep(i,N+1){
        ans += ST.query(0,B[i]+1);
        ST.change(B[i],ST[B[i]]+1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 19968
N, T = [int(x) for x in input().split()]
t_list = [int(x) for x in input().split()]
t_s = t_e = ans = 0
for t in t_list:
    if t > t_e:
        ans += t_e - t_s
        t_s = t
    t_e = t + T
ans += t_e - t_s
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];

  int minimum = INF; 
  int ans = 0;
  rep(i,n){
  	if(minimum >= p[i]) ++ans;
  	minimum = min(minimum, p[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

const int INF = 1e+9;
typedef pair<int, int> P;

int memo[152][11][80];
int N, M;
vector<P> G[151];

int rec(int n, int p, int m){
	if(memo[n][p][m] != -1)
		return memo[n][p][m];
		
	int res = INF;
	if(n > N){
		return 0;
	}
	if(n == N){
		return 0;
	}
	if(n == N - 1 && m >= 1){
		res = min(res, rec(n + 2, p, m - 1));
	}
	else{
		for(int i = 0; i < G[n].size(); ++i){
			res = min(res, rec(n + 1, i, m) + (G[n - 1][p].second + G[n][i].second) * abs(G[n][i].first - G[n - 1][p].first));
		}
		if(n != N - 1 && m >= 1){
			for(int i = 0; i < G[n + 1].size(); ++i){
				res = min(res, rec(n + 2, i, m - 1) + (G[n - 1][p].second + G[n + 1][i].second) * abs(G[n + 1][i].first - G[n - 1][p].first));
			}
		}
	}
	return memo[n][p][m] = res;
}

int main() {
	while(cin >> N >> M && (N || M)){
		memset(memo, -1, sizeof(memo));
		for(int i = 0; i <= 150; ++i)
			G[i].clear();
		int k, d, x;
		for(int i = 0; i < N; ++i){
			scanf("%d", &k);
			for(int j = 0; j < k; ++j){
				scanf("%d%d", &d, &x);
				G[i].push_back(P(d, x));
			}
		}
		int ans = INF;
		for(int i = 0; i < G[0].size(); ++i){
			ans = min(ans, rec(1, i, M));
			
		}
		if(M >= 1){
			for(int i = 0; i < G[1].size(); ++i){
				ans = min(ans, rec(2, i, M - 1));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1808
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;

string s,t;

int main(){
	cin >> s >> t;
	bool b = 1;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == t[0]){
			for(int j = 0; j < s.size(); j++){
				if(s[(i+j)%s.size()] != t[j]){
					b = 0;
					break;
				}
			}
			if(b){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int x = 0;
  vector<int64_t> A(n);
  
  for (int i = 0; i < n; i++) {
    
    if(s.at(i) == 'I'){
      x++;
    }
    else if(s.at(i) == 'D'){
      x--;
    }
    
    A.at(i) = x;
    
  }
  
  A.push_back(0);
  int64_t max = *max_element(A.begin(), A.end());
  cout << max << endl;

  
}
   

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a;a%=b;return gcd(b,a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
void sol()
{
cin>>n>>k;
vll v=read(n);
vector<string> ans;
for(int i=k;i<n;i++)
{
if(v[i]>v[i-k])
ans.pb("Yes");
else
ans.pb("No");
}

for(auto x:ans)
{
    cout<<x<<'\n';
}
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


Measured memory_bytes: 13144
#include <stdio.h>
int main(){
int x,y;
int i,temp;

for(i=0;i<3000;i++){
	scanf("%d%d",&x,&y);

	if(x==0 && y==0) break;

	if(x>y){
	temp=x;
	x=y;
	y=temp;
	}

	printf("%d %d\n",x,y);
	x=y=0;
	}
return 0;
}

Measured memory_bytes: 596
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long X, N;
    scan(X, N);
    auto P = aryread();
    auto S = P.sort();
    foreach (i; 0 .. 1000)
    {
        foreach (s; [-1, 1])
        {
            long x = X + (i * s);
            if (!S.contains(x))
            {
                writeln(x);
                return;
            }
        }
    }
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


void Warshall_Floyd(ll N, vector<vector<ll>> &g) {
	repn(k, N) {
		repn(i, N) {
			repn(j, N) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
}


int main() {

	ll N;
	cin >> N;

	vector<vector<ll>> g(N + 1, vector<ll>(N + 1, INF));

	repn(i, N){
		g[i][i] = 0;
		string s;
		cin >> s;
		repn(j, N) {
			if (s[j - 1] == '1') { g[i][j] = 1; }
		}
	}

	Warshall_Floyd(N, g);

	ll ans = 0;

	repn(i, N)repn(j,N) {
		ans = max(ans, g[i][j] + 1);
	}

	repn(i, N)repn(j, N) {
		if ((g[1][i] - g[1][j] - g[i][j]) % 2 != 0) { ans = -1; }
	}

	cout << ans;

	system("PAUSE");

}


Measured memory_bytes: 1276
def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(solve(n,a))

def solve(n,a):
    counter = 0
    temp = a[0]
    for i in range(1,n):
        if a[i] < temp:
            counter += temp - a[i]
        temp = max(temp,a[i])
    return counter


if __name__ == '__main__':
    main()


Measured memory_bytes: 32268
n, a, b, c, d = map(int, input().split())
s = input()

def check():
    if '##' in s[a - 1:c] or '##' in s[b - 1:d]:
        return False
    if d < c and '...' not in s[b - 2:d + 1]:
        return False
    return True

if check():
    print('Yes')
else:
    print('No')


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

public class Main {

	static int N, M, Q;
	static List<Integer> A = new ArrayList<>();
	static int[] a, b, c, d;
	static int ans = 0;

	static void dfs(List<Integer> A){
		if(A.size() == N){
			int tmp = 0;
			for(int i = 0; i < Q; i++){
				if(A.get(b[i]) - A.get(a[i]) == c[i]){
					tmp += d[i];
				}
			}
			ans = Math.max(ans, tmp);
			return;
		}
		int x = A.size() == 0 ? 1 : A.get(A.size()-1);
		for(int i = x; i < M+1; i++){
			A.add(i);
			dfs(A);
			A.remove(A.size()-1);
		}
	}

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        Q = sc.nextInt();
        a = new int[Q];
        b = new int[Q];
        c = new int[Q];
        d = new int[Q];
        for(int i = 0; i < Q; i++){
        	a[i] = sc.nextInt()-1;
        	b[i] = sc.nextInt()-1;
        	c[i] = sc.nextInt();
        	d[i] = sc.nextInt();
        }
        sc.close();
        dfs(A);
        System.out.println(ans);
    }
}

Measured memory_bytes: 39088
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;


int mod_pow(int x,int n){
  int res=1;
  while(n){
    if(n%2) res=res*x%mod;
    x=x*x%mod;
    n/=2;
  }
  return res;
}

int divi(int a,int b){
  return a * mod_pow(b,mod-2) % mod;
}

int factorial(int i){
  static vector<int> k(1e6);
  if(!k[0]){k[0]=1;for(int i=1;i<(int)k.size();i++)k[i]=i*k[i-1]%mod;}
  return k[i];
}

int nCr(int n,int r){
  int a = mod_pow( factorial(r) * factorial(n-r) % mod ,mod-2);
  return factorial(n) * a % mod;
}


int cal(int a,int b){
  
  int res=mod_pow(mod_pow(2,b)-1,a),cnt=0,f=1;

  for(int i=b-1;i>=0;i--){
    int x=mod_pow(mod_pow(2,i)-1,a)*nCr(b,i)%mod;
    if(f)cnt=(cnt+x)%mod;
    else cnt=(cnt-x+mod)%mod;
    f=!f;
  }
  
  res=(res-cnt+mod)%mod;
  
  res=res*mod_pow(2,a*(a-1)/2)%mod*mod_pow(2,b*(b-1)/2)%mod;

  return res;
}

signed main(){
  int n,m;
  cin>>n>>m;
  mod=m;
  int ans=0;
  for(int i=1;i<n;i++){
    ans=(ans+nCr(n,i)*cal(i,n-i))%mod;
  }

  cout<<ans<<endl;

  return 0;
}



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

using namespace std;

int main(void) {
	int N;
	vector<int> a;
	cin >> N;
	for(int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	a.push_back(0);//番兵
	a.push_back(1000000001);//番兵
	sort(a.begin(), a.end());
	int prev = a[0];
	int count = 0;
	int result = 0;
	for(int i = 1; i < a.size(); ++i) {
		if(a[i] != prev) {
			if(count < prev) {
				result += count;
			} else {
				result += count - prev;
			}
			prev = a[i];
			count = 0;
		}
		++count;
	}
	cout << result << '\n';
	return 0;
}



Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    int x = Integer.parseInt(scanner.next());
    scanner.close();

    if (x == 0){
        System.out.println(1);
    } else {
        System.out.println(0);
    }
  }
}

Measured memory_bytes: 26932
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;int sum[102]={0};
int sum2[102];
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int a[101];
	rb(i,1,n) cin>>a[i];
//	sort(a+1,a+1+n);
	rb(i,1,n) sum[i]=sum[i-1]+a[i];
	int minimum=INF;
	rl(i,n,1) sum2[i]=sum2[i+1]+a[i];
	rb(i,1,n){
//		cout<<sum[i-1]<<" "<<sum2[i]<<endl;
		minimum=min(minimum,abs(sum[i-1]-sum2[i]));
	}
	cout<<minimum;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		vector<int> a(n);
		rep(i, n) cin >> a[i];
		ll best = INT_MIN;
		rep(i, n) {
			ll j_best = 0;
			REP(j, i, n) {
				j_best += a[j];
				if (j_best > best) best = j_best;
			}
		}
		cout << best << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main()
{
    int n,k,a[55],sum=0;
    cin>>n>>k;for(int i=0;i<n;i++) cin>>a[i]; 
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            if(a[i]<a[j]) swap(a[i],a[j]); 
    for(int i=0;i<k;i++) sum+=a[i]; 
    cout<<sum<<endl; 
    return 0; 
}

Measured memory_bytes: 256
n, m = map(int, input().split())
k = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
b = []
for _k in k:
    bit = 0
    for i in _k[1:]:
        bit += 2 ** (i-1)
    b.append(bit)

res = 0
for i in range(2**n):
    for j, k in enumerate(b):
        if bin(i & k).count('1') % 2 != p[j]:
            break
    else:
        res += 1
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

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

const int INF = INT_MAX;

PII S;
PII T;
int W, H;
int ans;

void move(VVI ts, PII p, int n) {
	if (++n > 10) {
		return;
	}

	for (int i = 0; i < 4; i++) {
		int x = p.X;
		int y = p.Y;
		bool first = true;

		while (true) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx < 0 || ny < 0 || nx >= W || ny >= H) {
				break;
			}
			if (first && ts[ny][nx] == 1) {
				break;
			}
			first = false;

			if (ts[ny][nx] == 3) {
				ans = min(ans, n);
				break;
			}

			if (ts[ny][nx] == 1) {
				VVI nts(ts);
				nts[ny][nx] = 0;
				move(nts, make_pair(x, y), n);
				break;
			}

			x = nx;
			y = ny;
		}
	}
}

int main(void) {
	while (cin >> W >> H, W) {
		VVI ts(H, VI(W));
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> ts[i][j];
				if (ts[i][j] == 2) {
					S = make_pair(j, i);
				}
				if (ts[i][j] == 3) {
					T = make_pair(j, i);
				}
			}
		}

		VI pattern(10, 0);
		ans = INF;

		move(ts, S, 0);

		cout << (ans == INF ? -1 : ans) << endl;
	}

	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t x1,y1,x2,y2,x3,y3,x4,y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = x2 - (y2 - y1);
    y3 = y2 - (x1 - x2);
    x4 = x3 + (y2 - y3);
    y4 = y3 - (x2 - x3);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a = x2-x1;
	int b = y2-y1;
	int x3, y3, x4, y4;
	x3 = x2-b;
	y3 = y2+a;
	x4 = x3 - a;
	y4 = y3 - b;
	cout << x3 << " " << y3 << " " << x4 << " " << y4;

return 0;
}

Measured memory_bytes: 256
n, a, b, k = map(int, input().split())
MOD = 998244353

a_max =  min(k // a, n) + 1
pair = []
for i in range(a_max):
    if (k - a * i) % b == 0:
        j = (k - a * i) // b
        if j <= n:
            pair.append([i % MOD,j % MOD])

inv = [0] * (n + 1)
inv[1] = 1
for i in range(2, n + 1):
    inv[i] = (-(MOD // i) * inv[MOD % i]) % MOD

nCr = [0] * (n + 1)
nCr[0] = 1
for r in range(1, n + 1):
    nCr[r] = (nCr[r - 1] * (n - r + 1) * inv[r]) % MOD

result = 0
for p in pair:
    result += (nCr[p[0]] % MOD) * (nCr[p[1]] % MOD)

if result == 0:
    print(1)
else:
    print(result % MOD)

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

const long long MOD = 1000000007;

struct mint {
  long long x;
  mint(long long x = 0) :x((x%MOD + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  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 pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

const int MAX = 1e6 + 10;

long long f[MAX], finv[MAX], inv[MAX];

void CombInit() {
  f[0] = f[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    f[i] = f[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long Perm(int n, int k) {
  if (n < k || k < 0) return 0;
  return f[n] * finv[n - k] % MOD;
}

long long Comb(int n, int k) {
  if (n < k || k < 0) return 0;
  return f[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int N, k; cin >> N >> k;
  k = min(k, N - 1);

  mint ans = 0;
  CombInit();

  rep(i, k + 1) ans += Comb(N, i) * Comb(N - 1, i);

  cout << ans.x << endl;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a,b;
char s[20],t[20],u[20];
int main()
{
    scanf("%s%s",s,t);
    scanf("%d%d",&a,&b);
    scanf("%s",u);
    if(!strcmp(s,u))
    {
        a--;
    }
    else
    {
        b--;
    }
    printf("%d %d",a,b);
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
#define append push_back
#define mp make_pair
#define endl "\n"
#define MOD 1e9+7 

template <typename T>
void print(T AA[], int nn){for(int ii=0; ii<nn; ii+=1){cout<<AA[ii]<<" ";}cout<<endl;}
template <typename T> inline void print(T nn){ cout << nn << endl;}
/* ----------------------------------------------------------------------------------- */

const int NN = 105;
const int WW = 1e5+5;
int A[NN][2], cache[NN][WW], N, W;  // [w][v]

int fn(int i, int w){
    if(w>W) return -1e15;
    if(i==N) return 0;
    if(cache[i][w] != -1) return cache[i][w];
    int ans = 0;
    ans = max(fn(i+1, w), A[i][1]+fn(i+1, w+A[i][0]));
    cache[i][w] = ans;
    return ans;
}

int32_t main(){

    IOS
    
    memset(cache, -1, sizeof(cache));
    cin >> N >> W;
    for(int i=0; i<N; i+=1) cin >> A[i][0] >> A[i][1]; 
    print(fn(0, 0));

    return 0;
}

Measured memory_bytes: 82304
import math
a, b, x = map(int,input().split())
s = x / a
rad = 0
if s >= a*b/2:
  h = (a*b-s)*2/a
  rad = math.atan2(h,a)
else:
  w = s*2/b
  rad = math.atan2(b,w)
PI = math.acos(-1)
deg = rad/(2*PI)*360
print(deg)

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

const int MAX = 8;
vector<int> G[MAX];
int ans = 0;

void dfs(int now, int n, vector<int> order) {
  if (order.size() == n) {
    ans++;
    return;
  }
  for (int i = 0; i < G[now].size(); i++) {
    bool flag = true;
    for (int j = 0; j < order.size(); j++) {
      if (G[now][i] == order.at(j)) flag = false;
    }
    if (flag) {
      order.emplace_back(G[now][i]);
      dfs(G[now][i], n, order);
      order.pop_back();
    }
  }
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接リスト
  int n, m; // n:頂点数 m:辺数
  cin >> n >> m;
  
  // vector<int> G[n]; // G:頂点数がnのグラフを表す隣接リスト
  
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  vector<int> x = {0};
  dfs(0, n, x);
  
  cout << ans << '\n';
}

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

typedef long long ll;

int main() {
	int n,k;
	cin >> n >> k;
	vector< int > a(n);
	for (auto& e:a)cin >> e;
	// bool y = 1;
	for (int i=0;i+k<n;i++) {
		cout << (a[i+k] > a[i] ? "Yes" : "No") << '\n';
	}
	return 0;
}


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

int main(){
  int a,i,j,d,b,c,k,e=0;
  cin>>a>>b;
  c=b;
  while(c){
    c/=10;
    e++;
  }
  d=a*pow(10,e)+b;
  for(i=1;i*i<=d;i++){
    if(i*i==d){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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


Measured memory_bytes: 128
getter = -> {
   require 'stringio'
  _in = StringIO.new
  while l = gets
    _in << l
  end
  _in.string
}
s = getter.call.split(/\R/)

class Jdg
    def initialize(str)
        dfn(str)
    end
    def dfn(s)
        @a,@v = s[0].split(' ').map(&:to_i)
        @b,@w = s[1].split(' ').map(&:to_i)
        @t = s[2].to_i
    end
    def diff
        (@b-@a).abs
    end
    def rel_spd
        (@v-@w)
    end
    def judge
        return false if @w >= @v
        return true if (rel_spd*@t >= diff)
        false
    end
end

if Jdg.new(s).judge
    puts 'YES'
else
    puts 'NO'
end

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

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	for (int& i:v) cin >> i;
	vector<int> v2=v;
	sort(v2.begin(),v2.end());
	bool ok=true;
	for (int i=0; i<n; ++i){
		if (abs(v[i]-v2[i]) > 1) ok = false;
	}
	if (ok) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B;
  C = A * B % 2;
  if (C == 0){
  cout << "Even" << endl;
  }
  else{
  cout << "Odd" <<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int max;
  static int N;
  static int count;
  static String str;
  static char st;
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    str = sc.next();
    N = str.length();
    max = 0;
    for(int i=0;i<N;i++){
      st = str.charAt(i);
      if(st=='A' || st=='G' || st=='C' || st=='T'){
		count++;
      }
      else if(count>=max){
		max = count;
        count = 0;
      }
      else {
        count = 0;
      }
    }
    if(count>=max){
      max = count;
    }
    System.out.println(max);
  }
  
}
          
    


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long 
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (n >= a + b)cout << min(a, b) << " " << 0 << endl;
	else cout << min(a, b) << " " << a + b - n << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256