akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

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

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long
#define NAME ""

long long n, m;
long long a[300];
long long dp[300][210000];

const long long MOD = 1e9 + 7;

signed main()
{
    if (NAME != "")
    {
        freopen(NAME ".in", "r", stdin);
        freopen(NAME ".out", "w", stdout);
    }
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    dp[0][m] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            dp[i + 1][j % a[i]] = (dp[i + 1][j % a[i]] + dp[i][j]) % MOD;
            dp[i + 1][j] = (dp[i + 1][j] + (n - i - 1) * dp[i][j]) % MOD;
        }
    }
    long long ans = 0;
    for (int j = 0; j <= m; j++) ans = (ans + j * dp[n][j]) % MOD;
    cout << ans;
}


Measured memory_bytes: 328448
#include<iostream>
#include<queue>

using namespace std;
int money;
priority_queue<int> d;
int n,a,b,c;
int nap[200];

int main()
{
  cin>>n>>a>>b>>c;
  for(int i=0;i<n;i++)
    {
      int t;
      cin >> t;
      d.push(t);
    }
  double ans=c/a;
  int sum_m=a;
  int sum_c=c;
  while(!d.empty())
    {
      int tmp =d.top();d.pop();
      sum_c+=tmp;
      sum_m+=b;
      if(ans<(double)sum_c/sum_m)
	ans=sum_c/sum_m;
      else 
	break;
    }
  //  int ans = nap(a,c,0);
 
  cout<<(int)ans<<endl;
  
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;

int main(){
	int W,a,b;
	cin >> W >> a >> b;

	if(a+W<b)
		cout << b-(a+W) << endl;
	else if(b+W<a)
		cout << a-(b+W) << endl;
	else
		puts("0");
 

	return 0;
}	



Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, A, B = map(int, readline().split())
    ans = 0
    for i in range(1, N + 1):
        ns = str(i)
        s = 0
        for c in ns:
            s += int(c)
        if A <= s <= B:
            ans += i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71556
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
			int n = ni();
			int[] p = na(n);
			int cnt = 0;
			for(int i = 1; i <= n; i++) {
				if(p[i - 1] != i) {
					cnt++;
				}
				if(cnt > 2)break;
			}			
			System.out.println(cnt <= 2 ? "YES" : "NO");
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        } 
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll N;
vector<double> li;
vector<double> dp;

int input(){
  cin >> N;
  REP(i,N) li.push_back( inp<double>() );
}

int main()
{
  input();
  ll dM = 3000;
  REP(i,dM) dp.push_back(0.0);
  dp[0] = 1.0;
  
  REP(i,N){
    REPR(j,dM-2) {
      dp[j+1] += dp[j] * li[i];
      dp[j] = dp[j] * ( 1. - li[i] );
    }
  }
  
  double p=0.;
  REP(i,N+1) if (i>N-i) p += dp[i];
  cout << setprecision(10) << p << endl;
}

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

int main(){
	int A,B,C,X;
	cin>>A>>B>>C>>X;
	int ans=0;
	rep(i,A+1){
		rep(j,B+1){
			rep(k,C+1){
				if(i*500+j*100+k*50==X){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    float a, sum = 0.0;
    char s[10];

    for (int i=0; i < n; i++) {
        cin >> a >> s;
        if(strcmp(s, "JPY") == 0) sum += a;
        else sum += 380000.0 * a;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    int N;cin >> N;
    long long ans = 0;
    long long miniminus = INF;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    for(int i = 0;i<N-1;i++){
        if(retu.at(i) < 0){
            retu.at(i) *= -1;
            retu.at(i+1) *= -1;
        }
        miniminus = min(miniminus,abs(retu.at(i)));
        ans += retu.at(i);
    }
    if(retu.at(N-1) > 0){
        ans += retu.at(N-1);
        cout << ans << endl;
        return 0;
    }
    //終点を引く
    if(miniminus > abs(retu.at(N-1))){
        miniminus = min(miniminus,abs(retu.at(N-1)));
        ans -= miniminus;
    }
    else{
        //途中を引く（事前に足してあるので2回引く）
        ans += abs(retu.at(N-1));
        ans -= miniminus;
        ans -= miniminus;
    }
    cout << ans << endl;

}


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

#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define popcount __builtin_popcountll

const ll INF = 1LL<<60;
const ll MOD = 998244353;

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], signed n) {
    string result = "{";
    for (signed i=0; i<n; ++i) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

ll getSum(int a, int b, vector<int> arr) {
    if (a == 0)
        return arr[b];
    return arr[b] - arr[a-1];
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll N, K;
    cin >> N >> K;
    vector<int> arr(N);
    for (int i = 0; i < N; ++i) cin >> arr[i];
    for (int i = 0; i < N; ++i) arr[i] = (arr[i] - 1 + K) % K;

    vector<int> pref(N);
    ll t = 0;
    for (int i = 0; i < N; ++i) {
        t = (t + arr[i]) % K;
        pref[i] = t;
    }

    map<int, int> count;

    ll total = 0;
    for (int i = N - 1; i >= 0; --i) {
        int req = (i != 0) ? pref[i-1] : 0;
        ++count[pref[i]];
        if (i + K - 1 < N) --count[pref[i + K - 1]];
        total += count[req];
        
    }

    cout << ((K == 1) ? 0 : total) << endl;
}

Measured memory_bytes: 11264
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LLINF 1<<63-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007
void swap(int* x,int* y){
  int tmp=*x;*x=*y;*y=tmp;
}

int main(){
  int i,ans=0;
  char C[16];
  scanf("%s",C);
  for(i=0;i<15;i++)if(C[i]=='o')ans++;
  ans+=15-strlen(C);
  if(ans<8)printf("NO");
  else printf("YES");

  //printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
a = [int(aa) for aa in input().split()]
a.sort(reverse = True)
A = []
B = []
while len(a) > 0:
  A.append(a[0])
  a.pop(0)
  if len(a) == 0:
    break
  B.append(a[0])
  a.pop(0)
ans = sum(A) - sum(B)
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[200010];

int main()
{
	scanf("%s", s);
	
	if (strcmp(s, "Sunny") == 0) {
		printf("Cloudy\n");
	} else if (strcmp(s, "Cloudy") == 0) {
		printf("Rainy\n");
	} else if (strcmp(s, "Rainy") == 0) {
		printf("Sunny\n");
	}
	
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
int a[100010];
int main(){
    int i,n,h,s = 0;
    cin >> h >> n;
    for(i=0;i<n;i++){
        cin >> a[i];s += a[i];
    }
    if(s>=h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int x, t;
	cin >> x >> t;
	if (x - t <= 0)
		cout << 0 << endl;
	else
		cout << x - t << endl;

} 

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

struct city {
    int no, prefecture, year;
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<city> c(m);
    rep(i,m) {
        c.at(i).no = i;
        cin >> c.at(i).prefecture >> c.at(i).year;
    }
    sort(c.begin(), c.end(), [](city x, city y) {
        if (x.prefecture == y.prefecture) return x.year < y.year;
        return x.prefecture < y.prefecture;
    });
    vector<string> ans(m);
    int p = 0, id = 0;
    rep(i,m) {
        if (p == c.at(i).prefecture) id++;
        else id = 1;
        p = c.at(i).prefecture;
        ostringstream pss, idss;
        pss << setfill('0') << setw(6) << p;
        idss << setfill('0') << setw(6) << id;
        ans.at(c.at(i).no) = pss.str() + idss.str();
    }
    rep(i,m) cout << ans.at(i) << endl;
    return 0;
}

Measured memory_bytes: 7464
N = int(input())
A = map(int, input().split())
cnt = {}
for a in A:
  if cnt.get(a):
    cnt[a] = cnt[a] + 1
  else:
    cnt[a] = 1
for v in cnt.values():
  if v != 1:
    print('NO')
    exit()
print('YES')

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

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

ll dp[1010][1010];
char a[1010][1010];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        ll h, w;
        cin>>h>>w;
        rep(i, h)
            rep(j, w)
                cin>>a[i][j];

        for(i=1;i<h;i++)
        {
            if(a[i][0] == '#')
                break;
            else
                dp[i][0] = 1;
        }

        for(i=1;i<w;i++)
        {
            if(a[0][i] == '#')
                break;
            else
                dp[0][i] = 1;
        }

        for(i=1;i<h;i++)
        {
            for(j=1;j<w;j++)
            {
                if(a[i][j] == '.')
                {
                    if(a[i-1][j] == '.')
                        dp[i][j] += dp[i-1][j];
                    if(a[i][j-1] == '.')
                        dp[i][j] += dp[i][j-1];
                    dp[i][j] moduloe mod;
                }
            }
        }

        cout<<dp[h-1][w-1]<<endl;
    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

int main() {
    int N; cin >> N;
    vector<vector<int>> x(N), y(N);
    for(int i=0; i<N; ++i) {
        int a; cin >> a;
        for(int j=0; j<a; ++j) {
            int tx, ty; cin >> tx >> ty;
            x[i].push_back(tx - 1);
            y[i].push_back(ty);
        }
    }

    int res = 0;
    vector<bool> h(N);
    for(int i=0; i<(1<<N); ++i) {
        for(int j=0; j<N; ++j) h[j] = (i >> j) & 1;

        bool ok = true;
        for(int k=0; k<N; ++k) {
            if(!h[k]) continue;
            for(int l=0; l<x[k].size(); ++l) {
                if(y[k][l] == 1 && !h[x[k][l]]) ok = false;
                if(y[k][l] == 0 && h[x[k][l]]) ok = false;
            }
        }

        if(ok) res = max(res, __builtin_popcount(i));
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String str = "";

		for (int i = 0; i < 3; i++) {
			String c = scanner.next();
			str += c.substring(i,i+1);
		}
		System.out.println(str);
	}

}

Measured memory_bytes: 22740
#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);

LL BigMod(LL B,LL P,LL M){LL R=1;while(P>0){if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;}return R;}

#include<bits/stdc++.h>

using namespace std;
string str[15];
int main()
{
    FastRead
    int n,m;
    cin >> n >> m;

    REP(i,n){
        cin >> str[i];
    }
    int found = 0;
    REP(i,n)
    {
        REP(j,m)
        {
            int counter = 0;
            if(str[i][j+1]=='#')counter++;
            if(str[i+1][j]=='#')counter++;

            if(counter==2)found=1;
            if(found)break;
        }
        if(found)break;
    }
    if(found)cout << "Impossible\n";
    else cout << "Possible\n";

}



Measured memory_bytes: 764
#include<cstdio>
#include<algorithm>
int dsum(int n){
    if(n==10000)return 1;
    int a=n/1000,b=(n-a*1000)/100,c=(n-a*1000-b*100)/10,d=n-a*1000-b*100-c*10;
    return a+b+c+d;
}
int main(){
    int n,a,b,d,sum=0;
    scanf("%d%d%d",&n,&a,&b);
    for(int i=1;i<=n;i++){
        d=dsum(i);
        if(a<=d&&d<=b)sum+=i;
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

typedef struct data *node;
struct data{
  int key;
  node p;
  node l;
  node r;
};

node root,NIL;

void insert(int k){
  node y = NIL;
  node x = root;
  node z;

  z = (node)malloc(sizeof(struct data));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;
  if(y == NIL)root = z;
  else{
    if(z->key < y->key)y->l = z;
    else y->r = z;
  }
}

void InOrder(node u){
  if(u == NIL) return;
  InOrder(u->l);
  printf(" %d",u->key);
  InOrder(u->r);
}

void Preorder(node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  Preorder(u->l);
  Preorder(u->r);
}

node find(node x,int k){
  while(x != NIL && k != x->key){
    if(k < x->key) x = x->l;
    else x = x->r;
  }
  return x;
}

int main(){
  int n,i,a;
  char str[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",str);

    if(str[0] == 'f'){
      scanf("%d",&a);
      node t = find(root,a);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }

    if(str[0] == 'i'){
      scanf("%d",&a);
      insert(a);
    }

    else if(str[0] == 'p'){
      InOrder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20452
#include <stdio.h>
int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum = sum + i;
    }
  }
  printf("%lld", sum);
  return 0;
}

Measured memory_bytes: 1732
from heapq import heappush, heappop

N,M = map(int,input().split())
AB = []
for i in range(N):
  AB.append(list(map(int,input().split())))
AB.sort()
#print(AB)

hq = []
idx = 0
ans = 0
for day in range(1,M+1):
  while (idx < N and AB[idx][0] == day):
    heappush(hq, -AB[idx][1])
    idx += 1
  if len(hq) > 0:
    ans -= heappop(hq)
print(ans)


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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DFourColoring {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int h, w, d; cin >> h >> w >> d;
      vector<vector<char>> dp(h+w, vector<char>(h+w));
      rep(i, h+w) {
        rep(j, h+w) {
          if (i%(2*d)<d && j%(2*d)<d) {
            dp[i][j] = 'R';
          } else if (i%(2*d)<d) {
            dp[i][j] = 'Y';
          } else if (j%(2*d)<d) {
            dp[i][j] = 'B';
          } else {
            dp[i][j] = 'G';
          }
        }
      }

      rep(i, h) {
        rep(j, w) {
          cout << dp[i+j][i-j+w-1];
        }
        cout << '\n';
      }
    }
};

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

Measured memory_bytes: 4300
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<ll, pii>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

ll dp[3010][3010];
ll n;
ll val[3010];

ll find(ll l, ll h){

    if(l>h) return 0;
    if(l==h) return val[l];

    if(dp[l][h]!=-1) return dp[l][h];

    ll ans1 = val[l]+min( find(l+2, h), find(l+1, h-1) );
    ll ans2 = val[h]+min(find(l+1, h-1), find(l, h-2));

    dp[l][h] = max(ans1, ans2);
    return dp[l][h];
}

int main()
{  
    FAST;
    memset(dp, -1, sizeof(dp));

    ll sum=0;
    cin>>n;
    fr(i,n) cin>>val[i], sum+= val[i];

    ll ans = find(0, n-1);   
    cout<<ans-(sum-ans)<<endl;
}

Measured memory_bytes: 71168
a,b = input().split()
if a > b:
    print(int(b)*int('1'*int(a)))
elif a < b:
    print(int(a)*int('1'*int(b)))
else:
    left = int(b)*int('1'*int(a))
    right = int(a)*int('1'*int(b))
    print(max(left,right))

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

struct edge{
    int position, number;
    bool if_second;
};

bool compare(edge point1, edge point2){
    return point1.position < point2.position;
}

int main(){
    int R, C, N;
    cin >> R >> C >> N;
    vector<edge> edge_points;
    for(int i = 0; i < N; i++){
        int x[2], y[2];
        cin >> x[0] >> y[0] >> x[1] >> y[1];
        edge this_pair[2] = {{-1, i, false}, {-1, i, false}};
        for(int j = 0; j < 2; j++){
            if(!x[j]) {
                this_pair[j].position = y[j];
            }
            if(x[j] == R) {
                this_pair[j].position = R + C * 2 - y[j];
            }
            if(!y[j]) {
                this_pair[j].position = R * 2 + C * 2 - x[j];
            }
            if(y[j] == C) {
                this_pair[j].position = C + x[j];
            }
        }
        if(this_pair[0].position != -1 && this_pair[1].position != -1){
            sort(this_pair, this_pair + 2, compare);
            this_pair[0].if_second = false;
            this_pair[1].if_second = true;
            edge_points.push_back(this_pair[0]);
            edge_points.push_back(this_pair[1]);
        }
    }
    sort(edge_points.begin(), edge_points.end(), compare);
    vector<int> points_stack;
    for(int i = 0; i < edge_points.size(); i++){
        if(edge_points[i].if_second){
            if(points_stack.back() == edge_points[i].number){
                points_stack.pop_back();
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else{
            points_stack.push_back(edge_points[i].number);
        }
    }
    cout << "YES" << endl;
}


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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

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

    vector<int> csa(n + 1);
    csa[0] = 0;
    for (int i = 0; i < n; i++)
        csa[i + 1] = csa[i] + a[i];

    map<int, int> m;
    for (auto &&x : csa)
    {
        m[x]++;
    }

    int ans = 0;

    for (auto &&x : m)
    {
        if (x.second <= 1)
            continue;
        ans += x.second * (x.second - 1) / 2;
    }

    cout << ans << endl;
}


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b, c, res =0;
    cin >> a >> b >>c;
    res =a + b + 1;
    if(res >= c)
      cout << b + c;
    else
        cout << b + res;

}

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

typedef long long ll;

const int Maxn = 19;
const int Maxm = 1 << 18;
const ll Inf = 9000000000000000000ll;

int n;
int a[Maxn];
vector <ll> seq[2];
int cur;
ll dp[Maxm][Maxn];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    seq[cur].push_back(1);
    seq[cur].push_back(1);
    for (int i = 2; i < n; i++) {
        seq[!cur].clear();
        for (int j = 0; j < seq[cur].size(); j++) {
            seq[!cur].push_back(seq[cur][j]);
            if (j + 1 < seq[cur].size())
                seq[!cur].push_back(seq[cur][j] + seq[cur][j + 1]);
        }
        cur = !cur;
    }
    fill((ll*)dp, (ll*)dp + Maxm * Maxn, Inf);
    dp[0][0] = 0;
    for (int i = 0; i < seq[cur].size(); i++)
        for (int j = 0; j <= n; j++) if (dp[i][j] < Inf) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (j < n) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + ll(seq[cur][i]) * a[j]);
        }
    cout << dp[seq[cur].size()][n] << endl;
    return 0;
}


Measured memory_bytes: 40112
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

void solve()
{
    int n;
    cin >> n;
    int a;
    int c[3] = {};
    REP(i, 0, n)
    {
        cin >> a;
        if (a % 4 == 0)
            c[0]++;
        else if (a % 2 == 0)
            c[1]++;
        else
            c[2]++;
    }
    if (c[1])
    {
        if (c[0] >= c[2])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
    {
        if (c[0] + 1 >= c[2])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]){
  int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d", &k);
  printf("%d", arr[k-1]);
}

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

int main()
{
    int n;
    cin >> n;

    vector<int> weightSumVec;
    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;

        if (weightSumVec.size() == 0)
        {
            weightSumVec.push_back(input);
        }
        else
        {
            weightSumVec.push_back(weightSumVec.at(i - 1) + input);
        }
    }

    int minDiffAbs = 100;
    for (int i = 0; i < n; ++i)
    {
        int singleDiffAbs = abs((weightSumVec.at(n - 1) - weightSumVec.at(i)) - weightSumVec.at(i));
        minDiffAbs = min(minDiffAbs, singleDiffAbs);
    }

    cout << minDiffAbs << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main() {
  int64_t K,A,B;
  cin>>K>>A>>B;
  if(B-A<=2){cout<<1+K<<endl;}
  else{
    if(K<=A-1){cout<<K+1<<endl;}
    else{int64_t ans=((K-(A-1))/2)*(B-A)+A;
         if((K-(A-1))%2!=0){ans+=1;}
         cout<<ans<<endl;
  }
  }
  return 0;}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }
    println!("{}", 3i32.pow(n as u32) - a.iter().map(|i| { 2 - (i % 2)} ).product::<i32>());
}


Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#define ll long long
using namespace std;

int main(void){
    ll n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string a;
    cin >> a;
    vector<ll> sum;
    bool use[k];
    ll ans = 0, count = 0;
    for(ll i = 0; i < a.length(); i++){
        if(a[i]=='r') sum.push_back(p);
        if(a[i]=='s') sum.push_back(r);
        if(a[i]=='p') sum.push_back(s);
        //cout << i << " " << sum[i] << endl;
    }
    for(ll i = 0; i < k; i++){
            ans+=sum[i];
            use[i] = true;
    }
        //cout << i << " " << ans << endl;

    while(count!=k){
        for(ll i = count+k; i < sum.size(); i+=k){
            if(a[i-k]==a[i] && use[i%k] == false){
                ans += sum[i]; use[i%k] = true;
            }
            else if(a[i-k]==a[i] && use[i%k] == true)
                use[i%k] = false;
            else if(a[i-k]!=a[i]){
                ans += sum[i];
                use[i%k] = true;
            }
            //cout << i << " " << ans << endl;
        }
        count++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1528
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let num: u32 = read();
    let goal: i32 = read();

    let vec: Vec<(i32, i32)> = (0..num).map(|_| (read(), read())).collect();

    let mut min: i32 = 100000;

    for i in 0..i32::pow(2, num) {
        let mut sum: i32 = 0;
        let mut count: i32 = 0;

        let mut unused_indexes: Vec<i32> = Vec::new();

        for j in 0..num {
            if (1 & i >> j) == 1 {
                let j_num: i32 = j as i32 + 1;
                let j_index: usize = j as usize;
                sum += j_num * 100 * vec[j_index].0 + vec[j_index].1;

                count += vec[j_index].0;
            } else {
                unused_indexes.push(j as i32);
            }
        }

        if sum >= goal {
            min = cmp::min(min, count);
        } else {
            unused_indexes.reverse();
            let index = unused_indexes[0];
            let n = vec[index as usize].0;
            for l in 0..n-1 {
                sum += (index+1) * 100;
                count+=1;
                if sum >= goal {
                    min = cmp::min(min, count);
                    break;
                }
            }
        }
    }
    println!("{}", min);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 4352
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
        b: [i64; n],
    }
    let mut q = std::collections::BinaryHeap::new();
    let mut ad = 0;
    let mut res = 0;
    for i in 0..n {
        if a[i] < b[i] {
            ad += b[i] - a[i];
            res += 1;
        } else {
            q.push(a[i] - b[i]);
        }
    }

    while let Some(x) = q.pop() {
        if ad <= 0 {
            break;
        }
        res += 1;
        ad -= x;
    }

    if ad <= 0 {
        println!("{}", res);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 5940
#define _USE_MATH_DEFINES

#pragma GCC optimize("Ofast,no-stack-protector") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") 
#pragma GCC optimize("unroll-loops") 
#pragma GCC optimize("fast-math")
  
#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
  
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
  
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
  
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i; 
    }
    return str;
}
  
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
  
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();   
    return 0;
}

const int MAXN = 100;
int a[MAXN][MAXN], b[MAXN][MAXN];

void solve() {
    int n, m;
    cin >> n >> m;
    vec<vec<bitset<7000>>> dp(n + 1, vec<bitset<7000>>(m + 1));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> b[i][j];
        }
    }

    dp[1][1][abs(a[1][1] - b[1][1])] = 1; 
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (i == 1 && j == 1) continue;
            for (int k = 0; k < 7000; ++k) {
                int cur = abs(a[i][j] - b[i][j]);
                    if (dp[i - 1][j][abs(k - cur)])
                        dp[i][j][k] = 1;
                    if (dp[i][j - 1][abs(k - cur)])
                        dp[i][j][k] = 1;
                if (k + cur < 7000) {
                    if (dp[i - 1][j][k + cur])
                        dp[i][j][k] = 1;
                    if (dp[i][j - 1][k + cur])
                        dp[i][j][k] = 1;
                }
            }
        }
    }

    for (int k = 0; k < 7000; ++k) {
        if (dp[n][m][k]) {
            cout << k << endl;
            return;
        }
    }
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int A[3][3];
    bool ok[3][3];
    
    rep(i,3)rep(j,3){
        cin >> A[i][j];
        ok[i][j]=false;
    }
    
    int N; cin >> N;
    rep(k,N){
        int b; cin >> b;
        rep(i,3){
            rep(j,3){
                if(A[i][j]==b){
                    ok[i][j]=true;
                }
            }
        }
    }
    
    bool ans=false;
    rep(i,3){
        if (ok[0][i] && ok[1][i] && ok[2][i]) ans=true;
        if (ok[i][0] && ok[i][1] && ok[i][2]) ans=true;
    }
    if(ok[0][0] && ok[1][1] && ok[2][2]) ans=true;
    if(ok[0][2] && ok[1][1] && ok[2][0]) ans=true;
    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List (sort, group)
import Control.Applicative
import Control.Monad
import qualified Data.Map as M

main :: IO ()
main = do
    [n, m] <- (map read . words) <$> getLine
    xys <- map readLine2 <$> replicateM m getLine
    putStrLn $ if solve n xys then "YES" else "NO"

-- |
--
-- >>> solve 4 [(1,2),(2,4),(1,3),(3,4)]
-- True
--
-- >>> solve 5 [(1,2),(3,5),(5,1),(3,4),(2,3)]
-- False
solve :: Int -> [(Int, Int)] -> Bool
solve n xys = all even ns
  where
    (xs, ys) = unzip xys
    zs = sort $ xs ++ ys
    ns = map length $ group zs

-- Util
readLine2 :: String -> (Int,Int)
readLine2 = tuplify2 . map read . words

tuplify2 :: [a] -> (a, a)
tuplify2 [] = undefined
tuplify2 [x] = undefined
tuplify2 (x:y:_) = (x, y)


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

int main(){
  int w, n, wd[31];
  for(int i = 0; i < 31; i++) wd[i] = i+1;
  cin >> w;
  cin >> n;
  for(int i = 0; i < n; i++){
    int a, b, tmp;
    scanf("%d,%d", &a, &b);
    tmp = wd[a-1];
    wd[a-1] = wd[b-1];
    wd[b-1] = tmp;
  }

  for(int i = 0; i < w; i++){
    cout << wd[i] << endl;
  }
}

Measured memory_bytes: 1240
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
long A[2<<17];
long cnt[4<<17];
main()
{
	cin>>N;
	vector<long>X(2*N);
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		X[i*2]=A[i]+i;
		X[i*2+1]=i-A[i];
	}
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	long ans=0;
	for(int i=0;i<N;i++)
	{
		ans+=cnt[lower_bound(X.begin(),X.end(),i-A[i])-X.begin()];
		cnt[lower_bound(X.begin(),X.end(),A[i]+i)-X.begin()]++;
	}
	cout<<ans<<endl;
}


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

using namespace std;

void solve(void)
{
	int n, k;
	cin >> n >> k;
	double ans = 0;
	for (int d = 1; d <= n; d++)
	{
		double t = 0, dd = d;
		while(dd < k)
		{
			t++;
			dd *= 2;
		}
		ans += pow(2, -t) / n;
	}
	cout << fixed << setprecision(12) << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 384
n,m=map(int,input().split())
if n>=m:
  print(0)
  import sys
  sys.exit()
x=list(map(int,input().split()))
x.sort()
l=[]
for i in range(m-1):
  l.append(x[i+1]-x[i])
l.sort()
sm=0
for j in range(m-n):
  sm+=l[j]
print(sm)

Measured memory_bytes: 20320
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;

    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ans = 1; 
    vector<int> v(3);
    rep(i, n) {
        ll p = 0;
        int flag = 0;
        rep(j, 3) {
            if(v[j] == a[i]) {
                p++;
                if(!flag) {
                    v[j]++;
                    flag = 1;
                }
            }
        }
        ans *= p;
        ans %= mod;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
a_life, a_attk, b_life, b_attk = [int(i) for i in input().split()]

i = 0
while(True):
  if i % 2 == 0:
    b_life -= a_attk
  else:
    a_life -= b_attk
  i += 1
  if b_life <= 0:
    print("Yes")
    break
  elif a_life <= 0:
    print("No")
    break

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

signed main(){
  int n;
  cin>>n;
  if(n<1200) cout<<"ABC"<<en;
  else if(n<2800) cout<<"ARC"<<en;
  else cout<<"AGC"<<en;
}


Measured memory_bytes: 764
use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String; n]
    };
    let mut c_sb = 0_i64;
    let mut c_ea = 0_i64;
    let mut c_sbea = 0_i64;
    let mut c_ab = 0_i64;
    for s_i in s.iter() {
        let sb = s_i.starts_with('B');
        let ea = s_i.ends_with('A');
        if sb && ea {
            c_sbea += 1;
        } else if sb {
            c_sb += 1;
        } else if ea {
            c_ea += 1;
        }
        c_ab += s_i.matches("AB").collect::<Vec<_>>().len() as i64;
    }
    let ans = c_ab
        + std::cmp::max(c_sbea - 1, 0)
        + if c_sbea > 0 {
            let mut c = 0;
            if c_sb > 0 {
                c_sb -= 1;
                c += 1;
            }
            if c_ea > 0 {
                c_ea -= 1;
                c += 1;
            }
            c + std::cmp::min(c_sb, c_ea)
        } else {
            std::cmp::min(c_sb, c_ea)
        };

    println!("{}", ans);
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(void) {
  int N;
  int M;
  int sum = 0;

  scanf("%d", &N);
  scanf("%d", &M);

  int A[M];
  for (int i = 0; i < M; i++) {
    scanf("%d", &A[i]);
    sum += A[i];
  }
  if (N < sum) {
    printf("%d\n", -1);
  } else {
    printf("%d\n", N - sum);
  }
  return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int num(int N){
	int x = 0;
	for (int i = 1;; i++){
		if (N % 2 == 1){
			return x;
		}
		if (N % 2==0){
			N = N / 2;
			x = x + 1;
		}
	}
}
int main(){
	int N, max = 0, ans=1;
	cin >> N;
	for (int i = 1; i <= N; i++){
		if (max < num(i)){
			max = num(i);
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=list(map(int,input().split()))
e=0
f=0
for i in range(b):
  if d[i]>c:
    e=e+1
  if d[i]<c:
    f=f+1
if e>f:
  print(f)
else:
  print(e)

Measured memory_bytes: 9180