akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    /*
    int a, b, c;
    cin >> a >> b >> c;
    */
    
    /*
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    
    int r;
    cin >> r;
    cout << r * r << endl;
    
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector<ll> X(N), Y(N), P(N);
    for(int i=0; i<N; i++) scanf("%lld%lld%lld", &X[i], &Y[i], &P[i]);

    vector<ll> lx, ly;
    lx.emplace_back(0);
    ly.emplace_back(0);
    vector<ll> ans(N+1, LONGINF);
    auto dfs = [&](auto &&self, int k, int cnt) -> void {
        if(k == N) {
            ll res = 0;
            for(int i=0; i<N; i++) {
                ll dist_x = LONGINF, dist_y = LONGINF;
                for(auto &x : lx) chmin(dist_x, abs(x - X[i]));
                for(auto &y : ly) chmin(dist_y, abs(y - Y[i]));
                res += min(dist_x, dist_y) * P[i];
            }
            chmin(ans[cnt], res);
            return;
        }

        {
            self(self, k+1, cnt);
        }
        {
            lx.emplace_back(X[k]);
            self(self, k+1, cnt+1);
            lx.pop_back();
        }
        {
            ly.emplace_back(Y[k]);
            self(self, k+1, cnt+1);
            ly.pop_back();
        }
    };
    dfs(dfs, 0, 0);

    for(int i=0; i<=N; i++) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>

using namespace std;

// ofstream f;
int main() {
    // f.open("log", ios::out);
    int N, A, B, C; cin >> N >> A >> B >> C;
    int l[8] = {};
    for(int i = 0; i < N; i++) {
        cin >> l[i];
    }

    int length = pow(4, 8);
    int* sums = new int[length];
    int num = pow(4, N);

    for(int i = 0; i < num; i++) {
        int num_bk = i;
        int a, b, c;
        a = b = c = 0;

        int sum = 0;

        // 各要素がA, B, Cまたは使わない
        for(int j = 0; j < N; j++) {
            int mod = 0;
            switch(num_bk%4) {
                case 0:
                    break;
                case 1:
                    if(a > 0) sum += 10;
                    a += l[j];
                    break;
                case 2:
                    if(b > 0) sum += 10;
                    b += l[j];
                    break;
                case 3:
                    if(c > 0) sum += 10;
                    c += l[j];
                    break;
            }
            num_bk /= 4;
        }

        if(a == 0 || b == 0 || c == 0) sum = pow(2, 31) - 1;
        else sum += abs(a - A) + abs(b - B) + abs(c - C);
        // f << a << ", " << b << ", " << c << ", then: " << sum << endl;
        sums[i] = sum;
    }

    int *min = std::min_element(sums, sums + num);
    cout << *min << endl;
    delete[] sums;
    // f.close();
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	
	return 0;
}

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

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << max(0LL, b * (n - 1) + a - (a * (n - 1) + b) + 1) << endl;
}


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

int main() {
    int N, C, K; cin >> N >> C >> K;
    vector<int> T(N);
    for (int i = 0; i < N; ++i) cin >> T[i];
    sort(T.begin(), T.end());
    int res = 0;
    for (int i = 0; i < N;) {
        ++res;
        int start = i;
        while (i < N && T[i] - T[start] <= K && i - start < C) ++i;
    }
    cout << res << endl;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

ll const INF = INT_MAX;
vector<vector<P>> edges;

void bellmanford1(int s,int n,vector<ll>& dist) {
    dist[s] = 0;
    for (int x = 0;x < n-1;++x) {
        for (int i = 0;i < n;++i) if (dist[i] < INF) for (P& p : edges[i]) {
            dist[p.first] = min(dist[i]+p.second,dist[p.first]); 
        }
    }
}

void bellmanford2(int s,int n,vector<ll>& dist) {
    for (int x = 0;x < n-1;++x) {
        for (int i = 0;i < n;++i) if (dist[i] < INF) for (P& p : edges[i]) {
            if (dist[i]+p.second < dist[p.first]) dist[p.first] = -INF;
        }
    }
}

int main() {
    int n,m,p;
    cin >> n >> m >> p;
    edges.resize(n);
    vector<ll> dist(n,INF);
    for (int i = 0;i < m;++i) {
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        edges[u].push_back(P(v,p-w));
    }
    bellmanford1(0,n,dist);
    // p_ary(dist,0,n,i);
    bellmanford2(0,n,dist);
    // p_ary(dist,0,n,i);
    if (dist[n-1] > -INF) cout << max(-dist[n-1],0LL) << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <utility>
#include <set>
#include <iomanip>



using namespace std;

typedef long long l;


unsigned long long int sum(vector<unsigned long long int> sum, int l, int r)
{
    return (l == 0) ? sum[r] : (sum[r] - sum[l - 1]);
}

bool compare(const pair<int, int> &i, const pair<int, int> &j)
{
	if(i.first == j.first)
		return i.second < j.second;
	return i.first > j.first;
}

void f(string &s)
{
	string t = "";
	for(int i = 0;i < s.size();i++)
	{
		s[i] = tolower(s[i]);
		if(s[i] >= 'a' && s[i] <= 'z')
			t += s[i];
	}
	s = t;
}



bool isprime(l n)
{
	if(n == 2) return true;
	if(n < 2 || n%2 == 0) return false;
	for(l i = 3;i*i <= n;i+=2)
		if(n%i == 0)
			return false;
	return true;
}


void countPrimesInRange_sieve(l a,l b)	
{
	vector<bool> isPrime(b-a+1, true);	
	isPrime[0] = isPrime[1] = 0;		

    for (l i = 2; i*i <= b; ++i) {
        if (isPrime[i]) {
            for (int j = i * 2; j <= b; j += i)
            	isPrime[j] = 0;
        }
    }

    for (l i = 0; i < isPrime.size(); ++i)
    	if(isPrime[i])
    		cout<<i<<endl;
}

l C(l n, l r) {
	if(n == 0 && r == 0) return 1;
    if(r > n - r) r = n - r;
    l ans = 1;
    l i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

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

int main()
{
	int n,m,ans=0;
	cin>>n>>m;
	vector<pair<int, bool> > v(n+1);
	v[1].second = 1;
	for(int i = 1;i <= n;i++)
		v[i].first = 1;
	
	while(m--)
	{
		int a,b;
		cin>>a>>b;
		if(v[a].second == 1)
		{
			
			v[b].second = 1;
			v[b].first +=1;
			v[a].first -=1;
			if(v[a].first == 0)
				v[a].second = 0;
		}
		else
		{
			v[b].first +=1;
			v[a].first -=1;
		}
	}

	for(int i = 1;i <= n;i++)
		ans += v[i].second;
	cout<<ans<<endl;
} 

Measured memory_bytes: 1024
/**
 * Created by happygirlzt on 2019-08-17 19:51
 */

import java.io.*;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void solve(String s) {
        if (s == null || s.length() == 0) {
            System.out.println(0);
            return;
        }

        int n = s.length();
        int k = 1;
        char prev = s.charAt(0);
        int prevLen = 1;
        for (int i = 1; i < n; i++) {
            if (s.charAt(i) != prev || prevLen > 1) {
                k++;
                prevLen = 1;
                prev = s.charAt(i);
            } else {
                if (i + 1 < n) {
                    i++;
                    prev = s.charAt(i);
                    prevLen = 2;
                    k++;
                }
            }
        }

        System.out.println(k);
    }

    public static void main(String[] args) {
        FastReader fr = new FastReader();
        String s = fr.nextLine();
        solve(s);
    }
}


Measured memory_bytes: 25832
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

const int mod = 1000000007;
struct mint{ //modint
    int x;
    mint(int x = 0): x(x % mod) {}
    friend istream& operator >> (istream &s, mint& m){ return s >> m.x; }
    friend ostream& operator << (ostream &s, mint m){ return s << m.x; }
    inline mint& operator += (mint a){ if((x += a.x) >= mod)x -= mod; return *this; }
    inline mint& operator -= (mint a){ if((x += mod - a.x) >= mod)x -= mod; return *this; }
    inline mint& operator *= (mint a){ (x *= a.x) %= mod; return *this; }
    inline mint& operator /= (mint a){ return(*this) *= a.inv(); }
    inline mint operator + (mint a){ mint res(*this); return res += a; }
    inline mint operator - (mint a){ mint res(*this); return res -= a; }
    inline mint operator * (mint a){ mint res(*this); return res *= a; }
    inline mint operator / (mint a){ mint res(*this); return res /= a; }
    inline bool operator == (mint a){ return x == a.x; }
    mint inv(){ return pow(mod - 2); }
    mint pow(int p){
        mint res(1), tmp(x);
        for(; p; p >>= 1){ if(p & 1)res *= tmp; tmp *= tmp; }
        return res;
    }
};

string s;
mint dp[100005][13]; //iまで決めてj余る

//ABC135
signed main(void){

    cin >> s;
    reverse(all(s));
    int ten = 1;

    dp[0][0] = mint(1);
    rep(i, s.size()){
        if(s[i] == '?'){
            rep(j, 13){
                rep(k, 10){
                    dp[i+1][(j+k*ten%13)%13] += dp[i][j];
                }
            }
        }else{
            int now = s[i] - '0';
            rep(j, 13){
                dp[i+1][(j+now*ten%13)%13] += dp[i][j];
            }
        }
        ten *= 10;
        ten %= 13;
    }
    cout << dp[s.size()][5] << endl;

}

Measured memory_bytes: 10624
/*
// Sample code to perform I/O:

#include <iostream>

using namespace std;

int main() {
	int num;
	cin >> num;										// Reading input from STDIN
	cout << "Input number is " << num << endl;		// Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000009
typedef pair<int,int> pp;
#define ff first 
#define ss second 
#define pb push_back
#define lb lower_bound 
#define ub upper_bound
int N=1e4+7;
vector<int> dp(N,0);
void solve(){
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                ll sum=i*i+j*j+k*k+i*j+j*k+k*i;
                if(sum<=N)
                dp[sum]++;
            }
        }
    }
}
int main(){ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,ans=0;
	solve();
	cin>>n;
	for(int i=1;i<=n;i++){
	    cout<<dp[i]<<"\n";
	} 
    
}

Measured memory_bytes: 3692
import numpy as np
#li=np.array([int(i) for i in list('{:06b}'.format(i)])
#exit()
H,W,K=map(int, input().split()) 
B=[]
for i in range(H):
  B.append(list(input()))
for i in range(H):
  for j in range(W):
    if(B[i][j]=='.'):
      B[i][j]=1
    else:
      B[i][j]=0
B=np.array(B)      

HC=np.zeros(H)
WC=np.zeros(W)
#i行目を取り出し
for i in range(H):
  HC[i]=np.count_nonzero(B[i]==1)
#j列目を取り出し  
for j in range(W):
  WC[j]=np.count_nonzero(B[:,j]==1)
WC=np.argsort(WC)
HC=np.argsort(HC)
count=0
for i in range(2 ** H):
  BB=B.copy()
  for iii in range(H):
    if [int(ii) for ii in list('{:06b}'.format(i))][6-H:][iii]==1:
      BB[iii]=1
  for j in range(2 ** W):
    BBB=BB.copy()
    for jjj in range(W):
      if [int(jj) for jj in list('{:06b}'.format(j))][6-W:][jjj]==1:
        BBB[:,jjj]=1
    if np.count_nonzero(BBB==0)==K:
      count+=1
print(count)  

Measured memory_bytes: 27008
#include <algorithm>
#include <cassert>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

#define all(x) begin(x), end(x)

using namespace std;

template <typename T> T gcd(T a, T b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}

template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }

int dp[45] = {0};
int fib(int n) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (dp[n-1] != 0) {
        if (dp[n-2] != 0) {
            return dp[n-1] + dp[n-2];
        }
    }
    dp[n-1] = fib(n-1);
    dp[n-2] = fib(n-2);
    return dp[n-1] + dp[n-2];
}

int main() {
  int n;
  cin >> n;
  cout << fib(n) << endl;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
// rep(i,1,10) is from 1 to 9 and rep(I,10,1) is from 9 to 1
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    n=n%(mod-1);
    a=a%mod;
    int res=1;
    while(n>0)
    {
        if(n&1) res=(res*a)%mod;
        a=(a*a)%mod;
        n>>=1;
    }
    return res;
}


vi adj[100005],color(100005);
vector<bool> vis(100005,false);
int cnt=0;

void dfs(int s)
{
    vis[s]=true;
    cnt++;
    // color[s]=clr;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            vis[u]=true;
            dfs(u);
        }
    }
    // order.pb(s);
}


void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,flag=0,count=0;
    string S,T,U;
    // int a,b,c,d;
    cin>>S;
    n=sz(S);
    if(S[n-1]=='1'||S[n-1]=='6'||S[n-1]=='8'||S[n-1]=='0')
    {
        cout<<"pon";
    }
    else if(S[n-1]=='3')
    {
        cout<<"bon";
    }
    else cout<<"hon";

}




signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 6212
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair 
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9;
const ll MAX = 1e5+10;
const ll inf = 1e18+7;

int main(){
	fastio;
	ll n,a,b,cont=0;
	cin>>n;
	bool go = false;
	f(i,0,n){
		cin>>a>>b;
		if(a==b) cont++;
		else cont=0;
		if(cont==3) go = true;
	}
	if(go) cout<<"Yes\n";
	else cout<<"No\n";
    return 0; 
}

Measured memory_bytes: 3680
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
vector<int> edge[200000];
int onite[100003];
int nigete[100003];
int main(){
    int N,u,v;
    cin>>N>>u>>v;
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }


    for(int i=0;i<100003;i++){
        onite[i]=1000000;
        nigete[i]=1000000;
    }
    queue<int>pos;
    queue<int>te;
    pos.push(v);
    te.push(0);
    onite[v]=0;
    //cout<<edge[1][1];
    while(!pos.empty()){

        int karipos=pos.front();pos.pop();
        int karite=te.front();te.pop();
        for(int i=0;i<edge[karipos].size();i++){
            //puts("hoge");
            if(onite[edge[karipos][i]]>karite+1){
                pos.push(edge[karipos][i]);
                te.push(karite+1);
                onite[edge[karipos][i]]=karite+1;
            }

        }
    }
    pos.push(u);
    te.push(0);
    nigete[u]=0;
    //cout<<edge[1][1];
    while(!pos.empty()){

        int karipos=pos.front();pos.pop();
        int karite=te.front();te.pop();
        for(int i=0;i<edge[karipos].size();i++){
            //puts("hoge");
            if(nigete[edge[karipos][i]]>karite+1){
                if(onite[edge[karipos][i]]>karite+1){
                    pos.push(edge[karipos][i]);
                    te.push(karite+1);
                    nigete[edge[karipos][i]]=karite+1;
                }
            }
        }
    }
    long long int ans=0;
    for(int i=1;i<=N;i++){
        if(nigete[i]!=1000000){
            ans=max(ans,(long long int)onite[i]-1);
        }
    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 12340
#include <stdio.h>

int main(void)
{
        int n,i,s=0;
        scanf("%d",&n);
        int a[n],b[n],c[n-1];
        for(i=0;i<n;i++)
                scanf("%d",&a[i]);
        for(i=0;i<n;i++)
                scanf("%d",&b[i]);
        for(i=0;i<n-1;i++)
                scanf("%d",&c[i]);

        for(i=0;i<n;i++){
                s+=b[a[i]-1];
                if(i>0 && a[i]==a[i-1]+1) s+=c[a[i-1]-1];
        }
        printf("%d\n",s);
        return 0;
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a;
	vector<int> b,ans;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		b.emplace_back(a);
	}
	int f;
	for (int i = n; i > 0; --i)
	{
		f=0;
		for (int j = b.size()-1; j >= 0; --j)
		{
			if (j+1==b.at(j))
			{
				ans.emplace_back(j+1);
				b.erase(b.begin()+j);
				f=1;
				break;
			}
		}
		if (f==0)
		{
			cout<<"-1\n";
			return 0;
		}
	}
	reverse(ans.begin(), ans.end());
	for (int i = 0; i < n; ++i)
	{
		cout<<ans.at(i)<<endl;
	}
	return 0;
}


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

int main() {
  long long N, M;
  cin >> N >> M;

  if (N > M) swap(N, M);

  if (N == 1) {
    if (M == 1) {
      cout << 1 << endl;
    } else {
      cout << M - 2 << endl;
    }
    return 0;
  }

  cout << (N - 2) * (M - 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  
  int ans = 1;
  rep(i,8) {
     if (N < ans) {
       cout << ans/2 << endl;
       break;
     }
    ans *= 2;
  }
}

Measured memory_bytes: 256
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

x = ni()

num = 1

for i in range(100):
  for j in range(2,10):
    if i**j <= x:
      num = max(num,i**j)

print(num)

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "", t = "";
    cin >> s >> t;
    int len = (int)s.size();
    vector<vector<int>> alph(26);
    for (int i=0; i<len; i++) {
        alph.at(s.at(i) - 'a').push_back(i+1);
    }
    int now = 0;
    ll ans = 0;
    for (char c : t) {
        if (alph.at(c-'a').size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto next = upper_bound(alph.at(c-'a').begin(), alph.at(c-'a').end(), now);
        int next_i = 0;
        if (next == alph.at(c-'a').end()) {
            next_i = alph.at(c-'a').front();
        }
        else {
            next_i = *next;
        }
        ans += (next_i > now) ? next_i-now : len - now + next_i;
        now = next_i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

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

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

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

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

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

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

int main(int argc, char const *argv[]) {
    int n,m,k; cin>>n>>m>>k;
    union_find uf(n);
    vector<set<int>> fri(n);
    vector<set<int>> br(n);
    rep(i,m) {
        int a,b; cin>>a>>b;
        --a,--b;
        fri[a].insert(b);
        fri[b].insert(a);
        uf.unite(a,b);
    }
    rep(i,k) {
        int c,d; cin>>c>>d;
        --c,--d;
        br[c].insert(d);
        br[d].insert(c);
    }

    rep(i,n) {
        int fz = fri[i].size();
        int con = uf.size(i)-1;
        int ans = con-fz;
        for (auto &&e: br[i]) {
            if (uf.same(i,e)) ans--;
        }
        cout << ans;
        if (i!=n-1) cout << ' ';
        else cout << '\n';
    }
    return 0;
}

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

int main() {
 double W,H,x,y;
  cin >> W >> H >> x >> y;
  cout << W*H/2 << endl;
  if(2*x==W && 2*y==H) cout << 1 << endl;
  else cout << 0 << endl;
}


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

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

int facc(int n) {
  int sum = 1;
  rep(i, n) { sum *= i; }
  return sum;
}

int main() {
  int p, q, r;
  cin >> p >> q >> r;

  int a = p + q;
  int b = q + r;
  int c = r + p;

  cout << min(a, min(b, c)) << endl;
  return 0;
}


Measured memory_bytes: 256
building = [[[0*r for r in range(1, 11)] for f in range(1, 4)] for b in range(1, 5)]
num = int(input())
for i in range(num):
    b, f, r, v = map(int, input().split())
    building[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print('', *building[b][f])
    if b < 3:
        print('#'*20)



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s,t;cin>>s>>t;
    int n=SIZE(s);
    LL result=0;

    REP(i,n){
        if(s[i]!=t[i]){
            result++;
        }
    }
    cout<<result<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main() {
  long A,B,K;
  cin >> A >> B >> K;
  if(A>=K){
    cout << A-K << " " << B << endl;
  }else{
    if(A+B>=K) cout << 0 << " " << A+B-K << endl;
    else cout << 0 << " " << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
array=[]

for j in range(3):
    array.append([int(i) for i in input().split(" ")])

n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))

flag=[0 for j in range(9)]

for i in range(3):
    for j in range(3):
        if array[i][j] in b:
            flag[i*3+j]=1

check=[
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6],
]

for i in check:
    sum=0
    for j in i:
        sum+=flag[j]
    if sum==3:
        print("Yes")
        exit(0)

print("No")


Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        s:String,
    }
    let s = s;
    let mut ans = 0;
    let mut mi_ans = 0;
    for c in s.chars(){
        match c {
            'A' | 'C' | 'G' |  'T'  =>   mi_ans += 1,
            _ => {
                ans = std::cmp::max(ans,mi_ans);
                mi_ans = 0;
            },
        }

    }
    println!("{}",std::cmp::max(ans,mi_ans));

}  


Measured memory_bytes: 4352
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){ 
    ll N,X,T; 
    cin >> N >> X >> T;
    print(T * ((N + X-1) / X));
    

}

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

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
 * 境界部分には気をつける(そこだけ別で処理するというのもあり)
 * 逆再生することで簡単になることもある
 */
public class Main {
    public Main() {
    }

    public static void main(String[] args ) {
            Main main = new Main();
            main.exec();
    }

    public void exec() {
        BufferedReader bf = null;
        try{
            bf = new BufferedReader(new InputStreamReader(System.in));
            exec_body(bf);
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally{
            if( bf != null ) {
                try {
                    bf.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public void exec_body( BufferedReader bf ) throws IOException {
            bf.readLine();
            int[] sAry = toList(bf.readLine(),false);
            bf.readLine();
            int[] tAry = toList(bf.readLine(),false);

            int cnt = 0;
            for( int tVal : tAry ) {
            		int left = 0;
            		int right = sAry.length - 1;
            		while( left <= right ) {
            			int middle = ( left + right ) / 2;
            			int middleVal = sAry[middle];
            			if( middleVal == tVal ) {
            				cnt++;
            				break;
            			} else if ( middleVal > tVal ) {
            				right = middle - 1;
            			} else if( middleVal < tVal ) {
            				left = middle +1;
            			}
            		}
            }

            System.out.println(cnt);
    }

    public int[] toList( String str, boolean isBanhei ) {
            String[] elements = str.split(" ");
            int arysize = elements.length + ( (isBanhei) ? 1 : 0 );
            int[] ret = new int [arysize];
            for( int i = 0; i < elements.length; i++ ) {
                ret[i] = Integer.valueOf(elements[i]);
            }

            return ret;
    }
}


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

using namespace std;

int main() {
    int N;
    vector<int> P;

    cin >> N;
    for (int i = 0 ; i < N ; i++) {
        int p;
        cin >> p;
        P.push_back(p);
    }

    int cnt = 0;
    int min = numeric_limits<int>::max();
    for (int i = 0 ; i < N ; i++) {
        if (P[i] < min) {
            cnt++;
            min = P[i];
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1400
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;
fn main() {
    input!{
        a: i64,
        b: i64,
        x: i64,
    }
    println!("{}", if 0 <= x - a && x - a < b { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,op=0;
    long long x=0LL,ai,t1;
    cin>>n;
    deque<long long> s;
    for(int i=0;i<n;i++){
        cin>>ai;
        s.push_back(ai);
        while(s.size()>2&&(s[s.size()-2]>=s[s.size()-1])&&(s[s.size()-2]>=s[s.size()-3])){
                t1 = s[s.size()-1]+s[s.size()-3]-s[s.size()-2];
                s.pop_back();
                s.pop_back();
                s.pop_back();
                s.push_back(t1);
        }
    }
    int sign = 1;
    while(s.size()){
        if(s.back()>s.front()){
            x = x + sign*s.back();
            s.pop_back();
        }else{
            x = x + sign*s.front();
            s.pop_front();
        }
        sign = -sign;
    }
    cout<<x<<"\n";
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  int x[2*n],y[2*n];
  int max = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if( abs(a[max]) < abs(a[i]) ){
      max = i;
    }
    x[i*2] = -1;
    x[i*2 + 1] = -1;
    y[i*2] = -1;
    y[i*2 + 1] = -1;
  }

  int m = 0;
  if(a[max] >= 0){
    //step1
    for(int i = 0; i < n; i++){
      if(a[i] < 0){
	a[i] += a[max];
	x[m] = max;
	y[m] = i;
	m++;
      }
    }
    //step2
    for(int i = 0; i < n-1; i++){
      if(a[i] > a[i+1]){
	a[i+1] += a[i];
	x[m] = i;
	y[m] = i+1;
	m++;
      }
    }
  }else{
    //step1
    for(int i = 0; i < n; i++){
      if(a[i] > 0){
	a[i] += a[max];
	x[m] = max;
	y[m] = i;
	m++;
      }
    }
    //step2
    for(int i = n-1; i > 0; i--){
      if(a[i] < a[i-1]){
	a[i-1] += a[i];
	x[m] = i;
	y[m] = i-1;
	m++;
      }
    }
  }

  cout << m << endl;
  for(int i = 0; i < m; i++){
    cout << x[i]+1 << " " << y[i]+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
slist=list(input())
x,y=map(int,input().split())

direction_x=True
xlist,ylist=[],[]
cnt=0
for s in slist:
  if s=="F":
    cnt+=1
  else:
    if direction_x:
      xlist.append(cnt)
    else:
      ylist.append(cnt)
    cnt=0     
    direction_x=not direction_x
else:
  if direction_x:
    xlist.append(cnt)
  else:
    ylist.append(cnt)

x-=xlist.pop(0)
#print(x,y,xlist,ylist)

# check each x,y
set_x={0}
for i in range(len(xlist)):
  new_set_x=set()
  for xx in set_x:
    new_set_x.add(xx+xlist[i])
    new_set_x.add(xx-xlist[i])
  set_x=new_set_x
    
set_y={0}
for i in range(len(ylist)):
  new_set_y=set()
  for yy in set_y:
    new_set_y.add(yy+ylist[i])
    new_set_y.add(yy-ylist[i])
  set_y=new_set_y

#print(set_x,set_y)
if x in set_x and y in set_y:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3816
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32,
        b: i32
    }
    println!("{}", 6 - a - b);
}


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

// long long ll_min(long long n, long long m){
//     if(n < m) return n;
//     else return m;
// }

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int V, E;
    cin >> V >> E;
    int INF = 1<<28;
    vector<vector<int>> edges(V, vector<int>(V, INF));
    for(int i=0; i<E; i++){
        int s, t, d;
        cin >> s >> t >> d;
        edges[s][t] = d;
    }


    // Warshall-Floyd
    // dp[i][j] はそこまで見た中での i->j の最短距離
    vector<vector<int>> dp = edges;
    for(int i=0; i<V; i++){
        dp[i][i] = 0;
    }
    for(int k=0; k<V; k++){
        for(int i=0; i<V; i++){
            for(int j=0; j<V; j++){
                // dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                // 負の辺があると INF が減算されてしまって非常に怪しい
                if(dp[i][k] == INF || dp[k][j] == INF){
                    // 更新なし
                    continue;
                }
                else if(dp[i][j] == INF){
                    dp[i][j] = dp[i][k] + dp[k][j];
                }
                else{
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }
    }

    // NEGATIVE CYCLE の判定
    for(int i=0; i<V; i++){
        for(int j=0; j<V; j++){
            if(dp[i][i] < 0){
                cout << "NEGATIVE CYCLE" << endl;
                return 0;
            }
        }
    }

    for(int i=0; i<V; i++){
        for(int j=0; j<V-1; j++){
            if(dp[i][j] == INF) cout << "INF ";
            else cout << dp[i][j] << " "; 
        }
        if(dp[i][V-1] == INF) cout << "INF" << endl;
        else cout << dp[i][V-1] << endl; 
    }


    return 0;
}


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

int main(void) {
	i64 a, b, k;
	vector<i64> d;
	cin >> a >> b >> k;
	for (i64 i = 1; i <= 100; i++) {
		if (a % i == 0 && b % i == 0) d.push_back(i);
	}
	cout << d[d.size() - k] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int H,W;
	cin>>H>>W;
	
	vector<string> grid(H);
	for(int i=0;i<H;i++)cin>>grid[i];
	
	vector<string> R(H,string(W,'.')),B(H,string(W,'.'));
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(j==0||j==W-1){
				if(j==0)R[i][j]='#';
				if(j==W-1)B[i][j]='#';
			}
			else{
				if(i%2==0||grid[i][j]=='#')R[i][j]='#';
				if(i%2==1||grid[i][j]=='#') B[i][j]='#';
			}
		}
	}
	
	for(int i=0;i<H;i++){
		cout<<R[i]<<endl;
	}
	cout<<endl;
	for(int i=0;i<H;i++){
		cout<<B[i]<<endl;
	}
	
	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    char c;
    cin >> c;
    cout << char(c+1) << endl;

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  ll R=0,G=0,B=0;
  rep(i,N){
    if(S[i]=='R') R++;
    else if(S[i]=='G') G++;
    else B++;
  }
  ll ans=R*G*B;
  rep(i,(N-1)/2){
    rep(j,N-2*(i+1)){
      if(S[j]!=S[j+i+1] and S[j+i+1]!=S[j+i*2+2] and S[j]!=S[j+i*2+2]) ans--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628