akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  math2do
 *    created: 12.05.2020 00:18:44 IST
**/

#include <bits/stdc++.h>

using namespace std;

//..iterative
template <typename T>
vector <vector <T>> subset(vector <T>& arr) {
  int n = arr.size();
  int total = ((1 << n) - 1);
  vector <vector <T>> ss(total);

  for (int mask = 1; mask <= total; mask++) {
    for (int sh = 0; sh < n; sh++) {
      if ((mask & (1 << sh)) != 0) {
        ss[mask - 1].push_back(arr[sh]);
      } 
    }
  }
  return ss;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x;
  cin >> n >> m >> x;
  vector <int> c(n);
  vector <vector <int>> mat(n, vector <int>(m));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
    } 
  }
  constexpr int pinf = std::numeric_limits<int>::max();
  int ans = pinf;
  bool found = false;
  vector <int> which(n);
  iota(which.begin(), which.end(), 0);
  auto good = [&] (vector <int> &skill) -> bool {
    for (int j = 0; j < m; j++) {
      if (skill[j] < x) {
        return false;
      } 
    } 
    return true;
  };
  vector <vector <int>> ss = subset(which);
  for (auto &vec : ss) {
    vector <int> skill(m, 0);
    int cost = 0;
    for (int i : vec) {
      for (int j = 0; j < m; j++) {
        skill[j] += mat[i][j];
      }
      cost += c[i]; 
    }
    if (good(skill)) {
      found = true;
      ans = min(ans, cost);
    }  
  } 
  cout << (found ? ans : -1) << endl;
  return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

const string chk="keyence";

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	string s;
	int i=0, j=chk.size()-1;
	cin>>s;
	for(int k=0;k<s.size() && i<chk.size();k++,i++) if(s[k]!=chk[i]) break;
	for(int k=s.size()-1;k>=0 && j>=0;k--,j--) if(s[k]!=chk[j]) break;
	cout<<(i>=++j ? "YES\n":"NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//16:35~
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	priority_queue<llint>que;
	int i,n,m;cin>>n>>m;
	for(i=0;i<n;i++){llint a;cin>>a;que.push(a);}
	while(m--){que.push(que.top()/2);que.pop();}
	llint ans=0;
	while(que.size()){ans+=que.top();que.pop();}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
            int n = input.nextInt();
            int []a = new int[n];
            int count = 0;
            for(int i = 1; i <= n; i++){
                a[i -1] = input.nextInt();
                if((i%2 != 0 && a[i-1] % 2 !=0))
                    count++;
            }
        System.out.println(count);

    }
}


Measured memory_bytes: 35628
L, R = [int(x) for x in input().split()]

if R - L >= 672:
    ans = 0
else:
    ans = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, i * j % 2019)
            if ans == 0: break
        else:
            continue
        break

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll a[200010],b[200010];
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=n;i>=1;i--){
		ll sum=0;
		ll now=a[i];
		ll k=i;
		for(ll j=k;j<=n;j+=k){
			sum+=b[j];
		}
		if(sum%2!=now){
			b[i]=1;
		}
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans+=b[i];
	}	cout <<ans<<endl;
	for(ll i=1;i<=n;i++){
		if(b[i]==1){
			cout << i << " ";
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3968
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,i,j,k,a,b,c,dp[500000],cc[500000];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&cc[i]);
	for (int i=2;i<=n;i++) dp[i]=9999999999;	
	for (int i=1;i<n;i++){
		for (int j=i+1;j<=i+k;j++) dp[j]=min(dp[j],dp[i]+abs(cc[i]-cc[j]));		
	}
	printf("%d\n",dp[n]);
	return 0;
}

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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

void solve(void) {

	string s, t;
	cin >> s >> t;

	int n = s.length(), m = t.length();

	vector<vi> dp(n+1, vi(m+1));

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(s[i-1] == t[j-1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}

	string ans;
	int i = n, j = m;

	while(i > 0 && j > 0) {
		if(dp[i][j] == dp[i-1][j]) {
			i--;
		} else if(dp[i][j] == dp[i][j-1]) {
			j--;
		} else {
			ans.push_back(s[i-1]);
			i--;
			j--;
		}
	}


	reverse(ALL(ans));
	cout << ans << '\n';

}

int main(void) {

	solve();
	return 0;
}


Measured memory_bytes: 35968
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	string s; cin >> s;
	cout << s;
	if(s.back() == 's') cout << "es";
	else cout << "s";
	
	return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;


int n, c;
VI2 D, C, CC;

int main() {
    std::cin >> n >> c;
    D.resize(c, VI(c));
    C.resize(n, VI(n));
    CC.resize(3, VI(c, 0));
    REP(i, c) {
        REP(j, c) {
            std::cin >> D[i][j];
        }
    }
    REP(i, n) {
        REP(j, n) {
            int X;
            std::cin >> X;
            ++CC[(i+j)%3][--X];
        }
    }

    LL ans = std::numeric_limits<LL>::max();
    REP(i, c) REP(j, c) if(i != j) REP(k, c) {
        if(i == j || j == k || k == i) continue;

        LL cost = 0;
        REP(l, c) cost += D[l][i] * CC[0][l];
        REP(l, c) cost += D[l][j] * CC[1][l];
        REP(l, c) cost += D[l][k] * CC[2][l];

        ans = std::min(ans, cost);
    }
    std::cout << ans << std::endl;
}

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

int main(){

    while(1){
        string s; cin >> s;
        if(s[0] == '#') break;

        if(s.size() == 4){
            cout << 90 << endl;
            continue;
        }else if(s.size() == 5){
            cout << 0 << endl;
            continue;
        }else if(s.size() == 9){
            cout << 45 << endl;
            continue;
        }

        int dir = 45;
        int n = 0;
        for(int i = s.size() - 10; i >= 0; i--){

            if(s[i] == 'w'){
                dir = dir * 2 + 45;
                n++;
            }else if(s[i] == 'n'){
                dir = dir * 2 - 45;
                n++;
            }
        }

        cout << dir << "/" << pow(2, n) << endl;
    }

    return 0;
}


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

using namespace std;
using Graph = vector<vector<int>>;

int main() {
  
long long n,k;
cin >> n >> k;
long long a,b,ans;
a = n%k;
b=k-n%k;

if (a<b)
{
   ans = a;
}
else ans = b;

cout << ans;

  return 0;
}




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


int main(){
    double N;
    int w;
    cin>>N;
    for(double h=1;h<=3500;h++){
        for(double n=1;n<=3500;n++){
            w=(N*h*n)/(4*h*n-N*n-N*h);
            if((double)w==(N*h*n)/(4*h*n-N*n-N*h) && w>0){
                cout<<h<<" "<<n<<" "<<w<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);


void solve(int T){
    int  n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=0;i<=n;i++){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x>=a[i]){
            ans+=a[i];
            x-=a[i];
            if(x>=a[i+1]){
                ans+=a[i+1];
                a[i+1]=0;
            }
            else {
                ans+=x;
                a[i+1]-=x;
            }
        }
        else {
            ans+=x;
            a[i]-=x;
        }
    }
    cout<<ans<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 3732
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    sc.nextLine();
    String A = sc.nextLine();
    String B = sc.nextLine();
    String C = sc.nextLine();
    char[] cha = A.toCharArray();
    char[] chb = B.toCharArray();
    char[] chc = C.toCharArray();
    int sum = 0;
    for (int i = 0; i < N; i++) {
      int[] mat = new int[26];
      mat[cha[i] - 'a']++;
      mat[chb[i] - 'a']++;
      mat[chc[i] - 'a']++;

      int max = 0;
      for (int j = 0; j < mat.length; j++) {
        max = Math.max(max, mat[j]);
      }
      sum += (3 - max);
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100005;
ll b[3 * N];
ll c[3 * N];
int a[3 * N];
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; i++) {
    cin >> a[i];
  }
  ll sum = 0;
  priority_queue<int, vector<int>, greater<int> > p;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    p.push(a[i]);
    b[i] = sum;
  }
  for (int i = n; i < 2 * n; i++) {
    p.push(a[i]);
    int temp = p.top();
    sum += a[i] - temp;
    b[i] = sum;
    p.pop();
  }
  priority_queue<int> p2;
  ll sum2 = 0;
  for (int i = 3 * n - 1; i >= 2 * n; i--) {
    sum2 += a[i];
    p2.push(a[i]);
    c[i] = sum2;
  }
  for (int i = 2 * n - 1; i >= n; i--) {
    p2.push(a[i]);
    int temp = p2.top();
    sum2 += a[i] - temp;
    c[i] = sum2;
    p2.pop();
  }
  /*for (int i = n - 1; i < 2 * n; i++) {
    cout << b[i] << " " << c[i + 1] << endl;
  }*/
  ll ans = b[n - 1] - c[n];
  for (int i = n; i < 2 * n; i++) {
    ans = max(ans, b[i] - c[i + 1]);
  }
  cout << ans << endl;
  return 0;
}
/*int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int h , w;
  cin >> h >> w;
  int temp = max(h, w);
  int temp2 = min(h, w);
  if (temp % 3 == 0 || temp2 % 3 == 0) {
    cout << 0 << "\n";
  } else if (temp % 3 == 2) {
  } else {

      cout << (temp - temp / 3) * temp2 / 3 -  temp / 3 * temp2 << "\n";
  }
  return 0;
}*/


Measured memory_bytes: 5624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author GYSHGX868
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskC solver = new TaskC();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.nextInt();
      int answer = (int) (Math.sqrt(2.0 * n) + 0.5);
      out.printLine(answer);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      boolean isSpaceChar(int ch);

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(int i) {
      writer.println(i);
    }

  }
}



Measured memory_bytes: 21460
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <queue>

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

using namespace std;

typedef long long ll;

int input[5];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    REP(i, 5) {
        cin >> input[i];
    }
    
    int min = INF;
    int minIndex = 0;
    REP(i, 5) {
        if (((input[i] % 10) < min) && (input[i] % 10) != 0) {
            min = input[i] % 10;
            minIndex = i;
        }
    }
    
    int result = 0;
    REP(i, 5) {
        if (minIndex == i) {
            result += input[i];
        } else if ((input[i] % 10) == 0) {
            result += (input[i] / 10) * 10;
        } else {
            result += (input[i] / 10) * 10 + 10;
        }
    }
    
    cout << result << endl;
}



Measured memory_bytes: 256
/*
welcome to my code           hi from    s_agnik1511 
Don't just copy it.
Analyze it.
coz that's what heroes do.....
*/
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<numeric>
#include<vector>
#include<math.h>
using namespace std;
#define dude             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mesc(number,character)   char f[number];memset(f,character,number);
#define mesi(number,value)   int f[number];memset(f,value,number);
#define fr(i,start,end)  for(i=start;i<=end;i++)
#define rf(i,start,end)  for(i=start;i>=end;i--)
#define tst              int t;cin>>t;while(t--)
#define ppc(num)         __builtin_popcount(num)
#define ai               ll n,i;cin>>n;ll a[n];
#define pi               3.14159265358979323846
#define ctz(num)         __builtin_ctz(num)
#define clz(num)         __builtin_clz(num)
#define ll               long long int
#define ld               long double
#define pb               push_back
#define r0               return 0;
#define pp               pop_back
#define vec              vector
#define S                string
#define D                double
#define len              length
#define br               break;
#define wh               while
#define F                float
#define gcd              __gcd
#define sz               size
#define end              "\n"
#define sp              " "
const ll ifn=-1000000007;
ll power(ll x, ll y, ll p) { 
    ll res = 1;
    x = x % p;  
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p; 
    } 
    return res; 
} 
int bs(int arr[],int l,int r,int x) { 
    while (l <= r) { 
        int m=l+(r-l)/2; 
        if (arr[m]==x) 
            return m;
        if (arr[m]<x) 
            l=m+1;
        else
            r=m-1; 
    }
    return -1; 
}
void swap(int x,int y) {
    int t=x;
    x=y;
    y=t;
}
bool vow(char c) {
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') {
        return true;
    }
    else {
        return false;
    }
}
/*int mmsed() {
    ll f[n];
    memset(f,1,n) {
        
    }
}*/
int fact(ll x) {
    ll i=1,cnt=1;
    fr(i,1,x) {
        cnt*=i;
    }
    return cnt;
}
bool isPrime(ll n) { 
    if (n<=1)  return false; 
    if (n<=3)  return true;
    if (n%2==0||n%3==0) return false; 
  
    for (ll i=5;i*i<=n;i=i+6) 
        if (n%i==0||n%(i+2)==0) 
           return false; 
  
    return true; 
} 
int chek(S s,int i,int j) {
    ll cnt=0,k,a;
    fr(k,i,j) {
        //cnt=(cnt*10)+(int(s[k])-48);
        a=int(s[k])-48;
        cnt=(cnt*10)+(a);
    }
    return cnt;
}
void solve() {
ll x;
ll i;
S s;
cin>>x>>s;
if(s.len()<=x) {
    cout<<s;
}
else {
    fr(i,0,x-1) {
        cout<<s[i];
    }
    cout<<"...";
}
}
int main() {
    dude
    solve();
    
   r0
}


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

int main() {
  string A;
  cin >> A;
  int answer = 0;
  
  for ( int i =0; i < A.size(); i++){
    if (A.at(i) == '1'){
      answer ++;
    }
  }
  
  cout << answer << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int min = 101;
		int max = -101;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if (a[i] < min) {
				min = a[i];
			}
			if (a[i] > max) {
				max = a[i];
			}
		}
		int cost = 1000000000;
		for (int i = min; i <= max; i++) {
			int sum = 0;
			for (int j = 0; j < n; j++) {
				sum += Math.pow(i - a[j], 2);
			}
			cost = Math.min(cost, sum);
		}
		System.out.println(cost);
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;

const int maxn = 111;

int n,k;
int ans;
int x[maxn];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> x[i];
	
	ans = INT_MAX;
	for(int i = 1; i <= 100; i++){
		int cur = 0;
		for(int j = 0; j < n; j++)
			cur += (x[j]-i)*(x[j]-i);
		ans = min(ans, cur);
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m,t=0;
    cin>>n;
    ll a[n+10];
    map<int,int>c;
    for(int i = 0;i < n-1;i++)
    {
        cin>>a[i];
        c[a[i]]++;

    }
    for(int i = 1;i <= n;i++)
    {
        cout<<c[i]<<endl;
    }


}


Measured memory_bytes: 14568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, d, a; cin >> n >> d >> a;

  vector<pair<int, ll>> mons(n);
  for (int i = 0; i < n; i++) {
    cin >> mons[i].first >> mons[i].second;
  }
  sort(mons.begin(), mons.end());
  queue<pair<int, ll>> bomb;
  ll total = 0;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    while (!bomb.empty() && bomb.front().first < mons[i].first) {
      total -= bomb.front().second;
      bomb.pop();
    }
    if (mons[i].second > total) {
      mons[i].second -= total;
      ll b = (mons[i].second + a - 1) / a;
      ans += b;
      b *= a;

      total += b;
      bomb.emplace(mons[i].first + 2 * d, b);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

long mountain_table[1000002] = {0};
long reflesh_table[1000002] = {0};
const long mod_num = 1000000000 + 7;


int main(){
	int N;
	vector<long> T_array;
	vector<long> A_array;


	cin>>N;

	T_array.resize(N);
	A_array.resize(N);

	REP(i,N){
		cin>>T_array[i];
	}

	REP(i,N){
		cin>>A_array[i];
	}

	long t_max = 0;
	long a_max = 0;
	bool false_flag = false;


	for(int i = 0; i < N; i++){

		if(T_array[i] > t_max){
			mountain_table[i] = 1;
			t_max = T_array[i];
			reflesh_table[i] = 1;
		}
		else{
			mountain_table[i] = t_max;
		}
	}
	
	int flag_count = 0;

	for(int i = N - 1; i >= 0; i--){
	
		if(A_array[i] > a_max){

			if((reflesh_table[i] == 1)&& A_array[i] != T_array[i] ){
				false_flag = true;
				cout<<0<<endl;
				return 0;
			}
			if(A_array[i] > T_array[i] ){
				false_flag = true;
				cout<<0<<endl;
				return 0;
			}
			

			mountain_table[i] = 1;
			a_max = A_array[i];

		}
		else{

			if(mountain_table[i] > a_max){
				mountain_table[i] = a_max;
			}
		}
	}

	long answer = 1;

	REP(i,N){

		answer *= static_cast<long>(mountain_table[i]);
		answer %= mod_num;
	}

	cout<<answer<<endl;

	return 0;
}


Measured memory_bytes: 3072
import sys
N, M = map(int, input().split())

sc = []

for i in range(M):
    sc.append(list(map(int, input().split())))

for i in range(10**N):
    ans = str(i)
    if len(ans) == N and all(ans[s-1] == str(c) for s, c in sc):
        print(ans)
        sys.exit()
print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 
int main(){
    int A,B,K; cin >> A >> B >> K;
    if(B-A+1>=2*K){
        rep(i,K) cout << A+i << endl;
        for (int i=K-1; i>=0; i--){
            cout << B-i << endl;
        }
    }else{
        for(int i=A; i<=B; i++){
            cout << i << endl;
        }
    }
}

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

int main() {
  int a, i = 1;
  cin >> a;

  while (a != 4 && a != 2 && a != 1) {
    if (a & 1)
      a = 3 * a + 1;
    else
      a /= 2;
    i++;
  }
  cout << i + 3 << endl;
}

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

int n,a[2010],s;
bitset <4000010> f;

void work()
{
	scanf("%d",&n),f[0]=1;
	for (int i=1; i<=n; i++)
		scanf("%d",&a[i]),s+=a[i],f|=f<<a[i];
	for (int i=(s+1)/2; i<=s; i++)
		if (f[i])  printf("%d",i),exit(0);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 1792
import numpy as np
A = [int(x) for x in input().split()]
src = np.array(A)
K = int(input())
flag = 0

for i in range(K):
  if(src[0] < src[1]):
    if(src[1] < src[2]):
      flag = 1
      break
    else:
      src[2] *= 2
  else:
    src[1] *= 2
   
if(src[0] < src[1]):
	if(src[1] < src[2]):
		print("Yes")
	else:
		print("No")
else:
  print("No")
    

Measured memory_bytes: 27116
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var L = ReadLongs().OrderByDescending(x => x).ToArray();

            var count = 0L;
            for (int i = 0; i < N - 2; i++)
            {
                for (int j = i + 1; j < N - 1; j++)
                {
                    var k = L[i] - L[j];
                    var l = j + 1;
                    var r = N - 1;
                    while (true)
                    {
                        if (L[l] <= k)
                        {
                            break;
                        }
                        if (L[r] > k)
                        {
                            count += r - j;
                            break;
                        }
                        var mid = (l + r) / 2D;
                        var up = (int)Math.Ceiling(mid);
                        if (k >= L[up])
                        {
                            r = (int)Math.Floor(mid);
                        }
                        else
                        {
                            l = up;
                        }

                        if (r == l)
                        {
                            count += r - j;
                            break;
                        }
                    }
                }
            }

            return count;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 13536
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int dp[110][4][4][4];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n == 3){
        cout << 61 << endl;
        return 0;
    }
    rep(i, 0, 4){
        rep(j, 0, 4){
            rep(k, 0, 4){
                string s = "";
                s += 'A' + i;
                s += 'A' + j;
                s += 'A' + k;
                if(s == "ABC") continue;
                string t = s;
                swap(t[0], t[1]);
                if(t == "ABC") continue;
                t = s;
                swap(t[1], t[2]);
                if(t == "ABC") continue;
                dp[3][i][j][k] = 1;
            }
        }
    }
    for(int i = 3; i < n; i++){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                for(int l = 0; l < 4; l++){
                    for(int m = 0; m < 4; m++){
                        if(dp[i][j][k][l] == 0) continue;
                        string s = "";
                        s += 'A' + j;
                        s += 'A' + k;
                        s += 'A' + l;
                        s += 'A' + m;
                        if(s.find("ABC") != string::npos) continue;
                        string t = s;
                        swap(t[0], t[1]);
                        if(t.find("ABC") != string::npos) continue;
                        t = s;
                        swap(t[1], t[2]);
                        if(t.find("ABC") != string::npos) continue;
                        t = s;
                        swap(t[2], t[3]);
                        if(t.find("ABC") != string::npos) continue;
                        (dp[i + 1][k][l][m] += dp[i][j][k][l]) %= mod;
                    }
                }
            }
        }
    }
    int ans = 0;
    rep(i, 0, 4){
        rep(j, 0, 4){
            rep(k, 0, 4){
                (ans += dp[n][i][j][k]) %= mod;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
public class Eratosthenes
{
	public static void Main(string[] args)
	{
		int count = int.Parse(Console.ReadLine());
		int sum = 0;//?´???°???????¨?
		
		for (int i = 0; i < count; i++)
		{
			//?????????????±????????????????
			int target = int.Parse(Console.ReadLine());
			//????????????
			//2???????°??????£???????????§??????????????????if?????????????????\????????????
			if(target==2)
			{
				sum++;
			}
			if ((target >= 2) && ((target % 2) != 0)) 
			{
				
				int j = 3;
				do{
					
					
					if ( target == 3||target==5||target==7)
					{//?´???°??§??????
						sum ++;
						break;
					}
					
					if (target % j == 0)
					{//?´???°??§?????????
						break;
					}
					if ((j + 2) >( target / (j+2)))
					{
						//????????????????????§????????????break?????????????????´????????????????????\???
						sum ++;
						break;
					}
					
					j+=2;
				}while(j<=target/j);
			}
			
		}
		
		Console.WriteLine(sum);
	}
}

Measured memory_bytes: 9196
import heapq as pq
inf = float("inf")
n,e = map(int, input().split())
M = [[] for i in range(n)]

for i in range(e):
    s,t = map(int, input().split())
    M[s].append(t)

def dfs(s):
    if not visit[s]:
        visit[s] = True
        stack[s] = True
        for t in M[s]:
            if stack[t]:
                print(1)
                exit()
            else: dfs(t)
    stack[s] = False

visit = [False for _ in range(n)]
stack = [False for _ in range(n)]
for i in range(n):
    dfs(i)
print("0")

Measured memory_bytes: 7832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		int kiji=sc.nextInt();
		int[] topping=new int[N];
		for(int i=0; i<N; i++) {
			topping[i]=sc.nextInt();
		}
		Arrays.sort(topping);
		int max=kiji/A;
		for(int i=1; i<=N-1; i++) {
			topping[N-1-i]=topping[N-1-i]+topping[N-i];
		}
		for(int i=0; i<=N-1; i++) {
			max=Math.max(max, (topping[N-1-i]+kiji)/(A+(i+1)*B));
		}
		pl(max);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static void quick_sort(int[][] d, int left, int right) {
		if (left>=right) {
			return;
		}
		int p = d[(left+right)/2][0];
		int l = left, r = right;
		int tmp,tmp1,tmp2;
		while(l<=r) {
			while(d[l][0] < p) { l++; }
			while(d[r][0] > p) { r--; }
			if (l<=r) {
				tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
				tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
				l++; r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 24496
#include <bits/stdc++.h>
using namespace std;
const int maxn=200000+5;
string a;
int len;
int cnt[27];
typedef long long ll;
ll pr[maxn];
void pre()
{
    pr[0]=pr[1]=0;
    pr[2]=1;
    for(int i=3;i<maxn;i++) pr[i]=pr[i-1]+i-1;
    //for(int i=1;i<maxn;i++) printf("pr[%d]=%lld\n",i,pr[i]);
}
int main()
{
    pre();
    cin>>a;
    len=a.length();
    for(int i=0;i<len;i++) cnt[a[i]-'a']++;
    ll Ans=pr[len]+1;
    //printf("Ans=%lld\n",Ans);
    for(int i=0;i<27;i++) if(cnt[i]>=2) Ans-=pr[cnt[i]];
    printf("%lld\n",Ans);
    return 0;
}


Measured memory_bytes: 2180
import sys
import itertools
from collections import deque
from operator import itemgetter

input = sys.stdin.readline
A, B, K = map(int, input().split())
ans = deque()

for i in range(min(A,B),0,-1):
    if A%i == 0 and B%i ==0:
        ans.append(i)
print(ans[K-1])

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

long func(long n)
{
  long nquo = (n+1) / 2;
  long nmod = (n+1) % 2;
  long ret = ( nquo ) % 2 == 0 ? 0 : 1;
  if( nmod == 0 )
    return ret;
  else
    return ret ^ n;
}

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

  cout << (long)(func(A-1) ^ func(B)) << endl;

  return 0;
}



Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int lo;
typedef pair< int,int > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
lo n,m,b[li],a[li],k,flag,t;
lo cev;
string s;
vector<int> v;

int main(void){
	scanf("%lld",&n);
	printf("%lld\n",n*n*3);
	return 0;
}



Measured memory_bytes: 256
import java.util.Arrays; 
import java.util.Scanner; 
public class Main { public static void main(String[] args) { 
Scanner keyboard = new Scanner(System.in); 

int N = keyboard.nextInt(); 

int sumW = 0;
int[] s1 = new int[N];

for(int i =0; i<N; i++){
sumW += keyboard.nextInt(); 
s1[i] = sumW;
}

int[] z = new int[N-1];

int ans  = 1000000000;
for(int j =0; j<N-1; j++){
ans = Math.min(Math.abs((sumW - s1[j]) - s1[j]), ans);
}

		System.out.println(ans);
		keyboard.close();
	 	}
 } 


Measured memory_bytes: 23636
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def GCM(a,b):
    while(a%b!=0):
        a,b = b,a%b
    return b

def main():
    N,M = LI()
    A = LI()

    count_two = 0
    while(A[0]%2==0):
        A[0] //= 2
        count_two += 1
    pow_two = pow(2,count_two)

    for i in range(1,N):
        if A[i]%pow_two != 0:
            print(0)
            return
        A[i] //= pow_two
        if A[i]%2 == 0:
            print(0)
            return

    tmp = A[0]

    for i in range(1,N):
        tmp = tmp * A[i] // GCM(tmp,A[i])
        if tmp > M:
            print(0)
            return

    ans = M//(tmp*pow_two//2)
    if ans%2==0:
        ans -= 1
    ans -= ans//2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 59632
#include<stdio.h>            /*さて、いっくよ〜♪*/
#include<string.h>           /*まずは文字列用の配列を用意します♪*/
int main(){                  /*そして成功のおまじない♪*/
  char str[21];              /*ここで文字列を用意しました♪*/
  int i,j;                   /*文字列の長さを取得するi,for文用のjを用意します♪*/
  scanf("%s",str);           /*文字列を入力してもらいます♪*/
  i=strlen(str);             /*文字列の長さを取得します♪*/
  for(j=i;j>0;j--){          /*for文を使い、後ろから出力します♪*/
    printf("%c",str[j-1]);   /*出力時は 'c' なので要注意です!!*/
  }                          /*(((^ω^==^ωギャアアアアアアアアアア*/
  printf("\n");              /*最後に改行を忘れない♪*/
  return(0);                 /*最後はreturn(0)でお片づけ♪*/
}                            /*お疲れ様♪*/

                             /*参考になってくれれば、嬉しいな♪*/

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

int main(){
	int a,b; cin>>a>>b;
	if(a+b==15) cout<<"+"<<endl;
	else if(a*b==15) cout<<"*"<<endl;
	else cout<<"x"<<endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

int main(){
	int n;cin >> n;
	vector<int> v(n);
	REP(i,n)cin >> v[i];
	
	int r = 0;
	int now_sum = 0;
	int now_xor = 0;
	ll ans = 0;
	for(int l = 0;l < n;l++){
		while(r < n && (now_sum+v[r]) == (now_xor^v[r])){
			now_sum += v[r];
			now_xor ^= v[r];
			r++;
		}
		ans += r - l;
		now_sum -= v[l];
		now_xor ^= v[l];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
//Align

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,nc;cin>>n;
    deque<int>a(n),ac;
    rep(i,0,n)cin>>a[i];
    ac=a;
    sort(range(a));
    int la=0,l=a[0],r=a[0],w=a[0],q=a[0];
    a.pop_front();
    for(int i=0;a.size()>1;i++){
        if(i%2==0){
            w=a.back();a.pop_back();
            q=a.back();a.pop_back();
        }else{
            w=a.front();a.pop_front();
            q=a.front();a.pop_front();
        }
        la+=max(abs(w-l)+abs(q-r),abs(w-r)+abs(q-l));
        l=w;r=q;n-=2;
    }
    if(a.size()==1)la+=max(abs(w-a[0]),abs(q-a[0]));

    a=ac;
    sort(range(a),greater<int>());
    int ans=la;
    la=0;l=a[0];r=a[0];w=a[0];q=a[0];
    a.pop_front();
    for(int i=0;a.size()>1;i++){
        if(i%2==0){
            w=a.back();a.pop_back();
            q=a.back();a.pop_back();
        }else{
            w=a.front();a.pop_front();
            q=a.front();a.pop_front();
        }
        la+=max(abs(w-l)+abs(q-r),abs(w-r)+abs(q-l));
        l=w;r=q;
    }
    if(a.size()==1)la+=max(abs(w-a[0]),abs(q-a[0]));

    cout<<max(ans,la)<<nnn;
    return 0;
}

Measured memory_bytes: 5296
#include <iostream>
using namespace std;
int main() {
	int n, a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	int b[n];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == b[k])
					a[i][j] = 1;
			}
		}
	}
	int ans = 0;
	if (a[0][0] == 1 && a[0][1] == 1 && a[0][2] == 1)
		ans++;
	if (a[1][0] == 1 && a[1][1] == 1 && a[1][2] == 1)
		ans++;
	if (a[2][0] == 1 && a[2][1] == 1 && a[2][2] == 1)
		ans++;
	if (a[0][0] == 1 && a[1][1] == 1 && a[2][2] == 1)
		ans++;
	if (a[0][0] == 1 && a[1][0] == 1 && a[2][0] == 1)
		ans++;
	if (a[0][1] == 1 && a[1][1] == 1 && a[2][1] == 1)
		ans++;
	if (a[0][2] == 1 && a[1][2] == 1 && a[2][2] == 1)
		ans++;
	if (a[0][2] == 1 && a[1][1] == 1 && a[2][0] == 1)
		ans++;
	if (ans >= 1)
		cout << "Yes" << "\n";
	else 
		cout << "No" << "\n";
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N;cin >> N; 
    LL P;cin >> P;
    vector<LL> A(N);rep(i,N)cin >> A[i];

    bool ev = true;
    rep(i,N)if(A[i] % 2 == 1)ev = false;
    LL ans = 0;

    if(ev){
        if(P == 0)ans = pow(2,N);
        else ans = 0;
    }
    else{
        ans = pow(2,N-1);
    }
    cout << ans << endl;

}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
int a[110];
long long dp[100010], s[100010], t[100010];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		for (int j = 0; j <= k; j++) {
			s[j+1] = s[j] + dp[j];
			dp[j] = s[j+1] - s[max(j-a[i],0)];
		}
		for (int j = 0; j <= k; j++) {
			dp[j] = (dp[j] % mod + mod) % mod;
		}
	}
	printf("%lld\n", dp[k]);
	return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

const int maxn = 4e5 + 10;
bool vis[maxn];
int n, m, h[maxn], val[maxn];

struct edges {
  int nxt, to, w;
} e[maxn];

void addline(int u, int v, int w) {
  static int cnt = 1;
  e[++cnt] = edges{h[u], v, w}, h[u] = cnt;
}

bool flgans = 1;

void dfs(int u) {
  for (int i = h[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (vis[v]) {
      flgans &= val[v] - val[u] == e[i].w;
    } else {
      vis[v] = 1, val[v] = val[u] + e[i].w, dfs(v);
    }
  }
}

int main() {
  scanf("%d %d", &n, &m);
  rep(i, 1, m) {
    int x = read(), y = read(), w = read();
    addline(x, y, w), addline(y, x, -w);
  }
  rep(i, 1, n) {
    if (!vis[i]) vis[i] = 1, dfs(i);
    if (!flgans) return puts("No"), 0;
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 11392
//JAI SRI KRISHNA.//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
   ll a[n],i,c=0,j,k;
   for(i=0;i<n;i++)
    cin>>a[i];
   sort(a,a+n);
   for(i=0;i<n-2;i++)
   {
       for(j=i+1;j<n-1;j++)
       {
           for(k=j+1;k<n;k++)
           {
               if(a[k]!=a[i]&&a[k]!=a[j])
               {
               if(a[i]+a[j]>a[k]&&a[i]!=a[j])
                c++;
               else
                break;
               }
           }
       }
   }
   cout<<c<<endl;
}


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

int main(){
  int height;
  int width;
  while(true){
    cin >> height >> width;
    if(height == 0 && width == 0)
      break;
    for (int i = 0; i < height; i++){
      for (int j = 0; j < width; j++){
        if (i == 0 || i == height - 1){
          cout << "#";
        }
        else if (j == 0 || j == width - 1){
          cout << "#";
        }
        else {
          cout << ".";
        }
      }
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}




Measured memory_bytes: 3040
#include<stdio.h>
#include<string.h>

int main(){
char a[1001];
char b[1001];
int alen;
int blen;
int maxmatch=0,match;
  scanf("%s",&a[0]);
  scanf("%s",&b[0]);
  alen=strlen(a);
  blen=strlen(b);
  for(int i=0;i<=alen-blen;i++){
    match=0;
	for(int j=0;j<blen;j++){
    	if(b[j]==a[i+j])match++;
    }
    if(maxmatch<match)maxmatch=match;
  }
  printf("%d\n",blen-maxmatch);
  return 0;
}


Measured memory_bytes: 1736
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
void push(int a);
int pop();
int top;
int S[1000];
int main()
{
	top = 0;
char s[100];
	int a;
	int b;
	while(scanf("%s",s) != EOF)
	{
		switch(s[0])
		{
			case '+':	a=pop();b=pop();push(a+b);break;
			case '-':	a=pop();b=pop();push(b-a);break;
			case '*':	a=pop();b=pop();push(a*b);break;
			default :	push(atoi(s));
		}
	}
	printf("%d\n",pop());
}
void push(int a)
{
	top++;
	S[top] = a;
	
}
int pop()
{
	top -= 1;
	return S[top+1];
}


Measured memory_bytes: 2120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int N,X,mins,sum=0,m,ans,flag=0;
    scanf("%d %d",&N,&X);
    mins=1000000;
    for(int i=1;i<=N;i++){
        scanf("%d",&m);
        sum=sum+m;
        mins=min(mins,m);
        if(sum>=X){
            flag=1;
                ans=i;
            break;
        }
    }
    int t;
    if(X-sum>=0&&flag==0){
        t=(X-sum)/mins;
        ans=N+t;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256