akhauriyash/Code-Regression huggingface dataset:
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto A = aryread();
    auto B = aryread();
    auto C = aryread();
    A.sort();
    B.sort();
    C.sort();
    // writeln(A);
    // writeln(B);
    // writeln(C);
    long ans;
    auto Bs = new long[](N);
    foreach (i, a; A)
        Bs[i] = bsearch(B, a);
    auto Cs = new long[](N);
    foreach (i, b; B)
        Cs[i] = bsearch(C, b);
    long[] sum = new long[](N + 1);
    foreach (i; 0 .. N)
        sum[i + 1] = sum[i] + (N - (Cs[i] + 1));

    foreach (i; 0 .. N)
    {
        auto bb = Bs[i];
        ans += sum[$ - 1] - sum[bb + 1];
    }
    writeln(ans);
}

long bsearch(const long[] V, long x)
{
    if (x < V[0])
    {
        return -1;
    }
    long gt = V.length;
    long lt = 0;
    while (1 < gt - lt)
    {
        long m = lt + (gt - lt) / 2;
        if (V[m] <= x)
        {
            lt = m;
        }
        else
        {
            gt = m;
        }
    }
    return lt;
}


Measured memory_bytes: 13000
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int sum;
	int i;
	
	while (scanf("%d %d", &a, &b) != EOF){
		
		sum = a + b;
		i = 1;
		
		while (sum / 10 != 0){
			i++;
			sum /= 10;
		}
		
		printf("%d\n", i);
		
	}
		return (0);
}

Measured memory_bytes: 600
// Kyoto University Programming Contest 2016
// E - 柵 / Fences

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define MAX_H 100
#define MAX_W 100
#define MAX_V (MAX_H * MAX_W * 2 + 2)
#define INF 100000000
using namespace std;


struct edge{
  int to, cap, rev; // 行き先, 容量, 逆辺番号
};

class Graph{
public:
  void add_edge(int from, int to, int cap);
  int max_flow(int s, int t);
private:
  void bfs(int s);
  int dfs(int v, int t, int f);
private:
  vector<edge> g[MAX_V];
  int level[MAX_V];
  int iter[MAX_V];
};

void Graph::add_edge(int from, int to, int cap) {
  g[from].push_back((edge){to, cap, (int)g[to].size()});
  g[to].push_back((edge){from, 0, (int)g[from].size() - 1});
  return;
}

int Graph::max_flow(int s, int t) {
  int f;
  int flow = 0;

  while (true) {
    bfs(s);
    if (level[t] < 0) {
      break;
    }
    memset(iter, 0, sizeof(iter));
    while ((f = dfs(s, t, INF)) > 0) {
      flow += f;
    }
  }
  return flow;
}

void Graph::bfs(int s) {
  queue<int> que;
  int v;
  int i;

  memset(level, -1, sizeof(level));
  level[s] = 0;
  que.push(s);
  while (!que.empty()) {
    v = que.front();
    que.pop();
    for (i = 0; i < (int)g[v].size(); i++) {
      if (g[v][i].cap > 0 && level[g[v][i].to] < 0) {
        level[g[v][i].to] = level[v] + 1;
        que.push(g[v][i].to);
      }
    }
  }
  return;
}

int Graph::dfs(int v, int t, int f) {
  int d;

  if (v == t) {
    return f;
  }
  for ( ; iter[v] < (int)g[v].size(); iter[v]++) {
    edge &e = g[v][iter[v]];
    if (e.cap > 0 && level[v] < level[e.to]) {
      d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}


int H, W;
Graph G;
int dy[4] = { -1, 0, 1, 0 };
int dx[4] = { 0, 1, 0, -1 };
const int S = MAX_H * MAX_W * 2 + 0;
const int T = MAX_H * MAX_W * 2 + 1;
int ans;

int main() {

  int y, x;
  char buff[MAX_W + 2];

  scanf("%d%d", &H, &W);
  for (int i = 0; i < H; i++) {
    scanf("%s", buff);
    for (int j = 0; j < W; j++) {
      if (buff[j] == 'X') {
        G.add_edge(S, (i * W + j) * 2 + 0, INF);
        G.add_edge((i * W + j) * 2 + 0, (i * W + j) * 2 + 1, INF);
      } else {
        G.add_edge((i * W + j) * 2 + 0, (i * W + j) * 2 + 1, 1);
      }
      for (int k = 0; k < 4; k++) {
        y = i + dy[k];
        x = j + dx[k];
        if (y < 0 || H <= y || x < 0 || W <= x) {
          G.add_edge((i * W + j) * 2 + 1, T, INF);
        } else {
          G.add_edge((i * W + j) * 2 + 1, (y * W + x) * 2 + 0, INF);
        }
      }
    }
  }

  ans = G.max_flow(S, T);
  ans = ans >= INF ? -1 : ans;
  printf("%d\n", ans);

  return 0;

}




Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
using namespace std;
string tbl[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(){
  int t;
  cin>>t;
  while(t--){
    string s;
    cin>>s;
    int p=0,c=0;
    for(int i=0;i<s.length();++i){
      if(s[i]=='0'){
	if(p||c) cout<<tbl[p][c%tbl[p].length()];
	p=0;
	c=0;
      }
      else{
	if(!p) p=s[i]-'0';
	else ++c;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
n,m,d = map(int,input().split())
a = [[' ' for _ in range(m)] for _ in range(n)]
b = [[' ' for _ in range(n)] for _ in range(m)]
for i in range(n):
    s = input()
    for j in range(len(s)):
        a[i][j] = s[j]
        b[j][i] = s[j]
cnt = 0
for i in range(n):
    tmp = ''.join(a[i])
    for j in range(m-d+1):
        if '.'*d == tmp[j:j+d]:
            cnt += 1
for i in range(m):
    tmp = ''.join(b[i])
    for j in range(n-d+1):
        if '.'*d == tmp[j:j+d]:
            cnt += 1
print(cnt)



Measured memory_bytes: 5764
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


int main() {

    ll N, D; cin >> N >> D;
    int cnt = 0;
    rep(i,N) {
        ll x, y; cin >> x >> y;
        if (x*x + y*y <= D*D) ++cnt;
    }

    cout << cnt << endl;





    return 0;
}





Measured memory_bytes: 3612
N,M = list(map(int,input().split()))
H = list(map(int,input().split()))
C = [1]*N
check=[1]*N
for i in range(M):
    A,B = list(map(int,input().split()))
    if H[A-1]>H[B-1]:
        check[B-1]=0
    elif H[A-1]<H[B-1]:
        check[A-1]=0
    elif H[A-1]==H[B-1]:
        check[A-1]=0
        check[B-1]=0

print(check.count(1))


Measured memory_bytes: 84768
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,mn=INF;
    
    cin>>N;
    rep(i,N){
        int a; cin>>a;
        int cnt=0;
        while(a>0&&a%2==0){
            cnt++;
            a/=2;
        }
        chmin(mn,cnt);
    }
    cout1(mn)
}

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

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int x[4], y[4];

int main(){
    rep(i, 2) cin >> x[i] >> y[i];

    rep(i, 2){
        int xi = x[i + 1] - x[i];
        int yi = y[i + 1] - y[i];

        x[i + 2] = x[i + 1] - yi;
        y[i + 2] = y[i + 1] + xi;

        cout << x[i + 2] << " " << y[i + 2] << " ";
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// Union-Find; 素集合データ構造
class UnionFind {
public:
    vector<long long> parent;
    long long n;
    UnionFind(long long x) :parent(x, -1), n(x){}
    bool unite(long long x, long long y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        parent[x] += parent[y]; parent[y] = x;
        return true; }
    bool same(long long x, long long y){ return find(x) == find(y); }
    long long find(long long x){ return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    long long size(long long x){ return -parent[find(x)]; }
    long long group(){ set<long long> st; for(long long i=0; i<n; i++) st.insert(find(i)); return st.size(); }
};

int main(){
    Init();
    ll n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        ll x, y, z; cin >> x >> y >> z; x--; y--;
        uf.unite(x, y);
    }
    cout << uf.group() << endl;
}

Measured memory_bytes: 8732
N, Y = map(int, input().split())
Y //= 1000

for i in range(N + 1):
    for j in range(N + 1 - i):
        k = N - i - j
        if 10 * i + 5 * j + k == Y:
            print(i, j, k)
            exit(0)

print(-1, -1, -1)


Measured memory_bytes: 9172
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> A;

  while (A > 0)
    A -= 1000;

  return -A;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  int coins = 0;
  int ans = 0;
  while (true) {
    if (coins >= c) {
      cout << ans << endl;
      return 0;
    }
    coins += a;
    ans++;
    if (ans % 7 == 0) coins += b;
  }
  return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const ll INF = 1LL<<60;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, x;
    cin >> n >> m >> x;
    vvi a(n, vi(m));
    vi c(n);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    ll ans = INF;
    bool ok = false;
    rep(bit, 1<<n) {
        vi rikai(m, 0);
        ll now = 0;
        rep(i, n) {
            if (bit>>i&1) {
                now += c[i];
                rep(j, m) {
                    rikai[j] += a[i][j];
                }
            }
        }
        bool flag = true;
        rep(j, m) if (rikai[j] < x) flag = false;
        if (flag) {
            chmin(ans, now);
            ok = true;
        }
        
    }
    if (ok) cout << ans << endl;
    else cout << -1 << endl;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

int main(){
 ll D,G;
 cin >> D >> G;
 vector<ll> P(D),C(D),ALL;
 for(int i = 0;i < D;i++){
   cin >> P[i] >> C[i];
 }
 ll ans = INF;
 for(ll i = 0;i < (1<<D);i++){
   bitset<10> S(i);
   ll cnt = 0;
   ll Point = 0;
   for(int j = 0;j < 10;j++){
     if(S.test(j)){
       Point += 100 * (j+1) * P[j] + C[j];
       cnt += P[j];
     }
   }
   if(Point >= G){
     ans = min(ans,cnt);
   }else{
     for(int k = D-1;k >= 0;k--){
       if(!S.test(k)){
         for(int l = 0;l < P[k]-1;l++){
           Point += (k+1) * 100;
           cnt++; 
           if(Point >= G){
             break;
           }
         }
         break;
       }
     }
     if(Point >= G){
       ans = min(ans,cnt);
     }
   }
 }
 cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  string S;
  cin >> S;
  int ans = 0;
  for(int i=0; i<S.length(); ++i){
    if(S[i] == '+') ++ans;
    else --ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def Main():
    N, M = list(map(int, input().split(" ")))
    nSums = sum(list(map(int, input().split(" "))))
    
    playDays = N - nSums if nSums <= N else -1
    print(playDays)
    
    
if __name__ == "__main__":
    Main()
    

Measured memory_bytes: 9992
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A[]=new int[N];
		int z=0;
		long x=0,y=0;
		while(z<N){
			A[z]=stdIn.nextInt();
			z++;
		}z=N-1;
		Arrays.sort(A);
		while(z>0){
			if(A[z]==A[z-1]){
				if(y==0)
					y=A[z];
				else
					if(x==0)
						x=A[z];
					else
						break;
				z--;
			}
			z--;
		}
		if(x==0||y==0)
			System.out.println(0);
		else
			System.out.println(y*x);
	}
}


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

int main(){
  string s; cin >> s;
  if(s.size()==1){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0; i<s.size()-1; i++){
    if(s[i]=='B'&&s[i+1]=='C'){
      s[i]='D';
      s.erase(s.begin()+i+1);
    }
  }
  long long d=0,res=0;
  for(int i=s.size()-1; i>=0; i--){
    if(s[i]=='A'){
      res+=d;
    }else if(s[i]=='D'){
      d++;
    }else{
      d=0;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 640
import java.util.*;
// warm-up
// Missed one pattern
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		String[] t = {"000","001","010","011","100","101","110","111"};
		String tok = sc.next();
		int A = Character.getNumericValue(tok.charAt(0)), 
		B = Character.getNumericValue(tok.charAt(1)),
		C = Character.getNumericValue(tok.charAt(2)),
		D = Character.getNumericValue(tok.charAt(3)); 
		for (String e : t) {
			int s = 0;
			StringBuilder sb = new StringBuilder();
			s+=e.charAt(0)=='1' ? A+B : A-B;
			s+=e.charAt(1)=='1' ? C : -C;
			s+=e.charAt(2)=='1' ? D : -D;
			if (s==7) {
				sb.append(A).append(e.charAt(0)=='1' ? "+" : "-").append(B)
				.append(e.charAt(1)=='1' ? "+" : "-").append(C)
				.append(e.charAt(2)=='1' ? "+" : "-").append(D);
				System.out.println(sb+"=7");
				System.exit(0);
			}
		}
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 38452
### dfs ###
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
N = int(input())
G = [[] for _ in range(N)]
dis = [-1]*N
for _ in range(N-1):
    a, b, c = map(int, input( ).split( ))
    a -= 1
    b -= 1
    G[a].append([b,c])
    G[b].append([a,c])
Q, K = map(int, input().split())
K -= 1
dis[K] = 0

def dfs(pos):
    for n_pos, n_cost in G[pos]:
        if dis[n_pos] != -1:
            continue
        dis[n_pos] = dis[pos]+n_cost
        dfs(n_pos)
dfs(K)

for i in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    ans = dis[x]+dis[y]
    print(ans)

    
 

Measured memory_bytes: 137964
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        int n,m,c; cin >> n >> m >> c;
        int cnt = 0;
        vi b(m);
        for(int i = 0; i<m;i++)cin >> b[i];
        for(int i = 0; i<n; i++){
            ll res = 0;
            vi a(m,0);
            for(int j = 0; j<m; j++){
                cin >> a[j];
                res+=(a[j] *b[j]);
            }
            if((res+c)>0)cnt++;
        }
        cout<<cnt<<endl;

return 0;
}




Measured memory_bytes: 256
s = list(input())
for i in range(int(input())):
  cmd, a, b, *c = input().split()
  a = int(a); b = int(b)
  if cmd == "print":
    print(*s[a:b+1], sep='')
  elif cmd == "reverse":
    s[a:b+1] = reversed(s[a:b+1])
  else:
    s[a:b+1] = c[0]



Measured memory_bytes: 5736
import sys
from collections import *
S=sys.stdin.readlines()
N,Q=map(int,S[0].split())
G=[[] for i in range(N)]
a,b=0,0
for i in range(N-1):
  a,b=map(int,S[i+1].split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
X=[0]*N
for i in range(Q):
  a,b=map(int,S[N+i].split())
  X[a-1]+=b
D=deque()
S=set()
def qao(x):
  global D,S
  if x in S:
    return False
  S.add(x)
  D.append(x)
  return True

def bfs():
  global D,X,G
  v=0
  for i in range(len(D)):
    v=D.popleft()
    for j in range(len(G[v])):
      if qao(G[v][j]):
        X[G[v][j]]+=X[v]
  return len(D)

qao(0)
while bfs():
  pass
print(*X)

Measured memory_bytes: 184152
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





string S, P;
//---------------------------------------------------------------------------------------------------
int i, a, b, c, d;
int f() {
    if (S[i] == '[') {
        i++;
        int l, r, res;
        if (S[i] == '+') {
            i++;
            l = f();
            r = f();
            res = l | r;
        }
        else if (S[i] == '*') {
            i++;
            l = f();
            r = f();
            res = l & r;
        }
        else {
            i++;
            l = f();
            r = f();
            res = l ^ r;
        }
        i++;
        return res;
    }

    int res;
    if (S[i] == 'a') res = a;
    else if (S[i] == 'b') res = b;
    else if (S[i] == 'c') res = c;
    else res = d;

    i++;
    return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    while (cin >> S) {
        if (S == ".") return;
        cin >> P;

        i = 0;
        a = P[0] - '0';
        b = P[1] - '0';
        c = P[2] - '0';
        d = P[3] - '0';
        int ha = f();
        int cnt = 0;
        rep(j, 0, 10000) {
            i = 0;
            a = j / 1000;
            b = (j / 100) % 10;
            c = (j / 10) % 10;
            d = j % 10;

            if (ha == f()) cnt++;
        }

        printf("%d %d\n", ha, cnt);
    }
}



Measured memory_bytes: 3364
#include <stdio.h>
int n, A[2000];
int solve(int i, int m){
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}
int main(){
  int i,q,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)){
      printf("yes\n");
    }
    else
      printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
object Main extends App {
  val Array(n, x) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val data = scala.io.StdIn.readLine.split(" ").map(_.toInt).sorted.reverse
  val ldata = data.map(_.toLong).toList

  if (ldata.sum == x) {
    println(n)
  } else {
    if (x > ldata.sum) {
      println(n - 1)
    } else {
      var sumSize = ldata.sum
      var cnt = n
      ldata.foreach { i =>
        if (x < sumSize) {
          sumSize -= i
          cnt -= 1
        }
      }
      println(cnt)
    }
  }
}


Measured memory_bytes: 27320
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int l;
	while (cin >> l && l) {
		VI m(12), n(12); rep(i, 12)cin >> m[i] >> n[i];

		int sum = 0, ans = -1;
		rep(i, 12) {
			sum += m[i] - n[i];
			if (sum >= l && ans == -1)ans = i + 1;
		}
		if (ans == -1)puts("NA");
		else cout << ans << endl;
	}
}


Measured memory_bytes: 3044
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let rat_cmp x y = match x, y with
  ((x1, y1), (x2, y2)) -> x1 * y2 < x2 * y1

let rat_max x y = if rat_cmp x y then y else x

let () =
  let [a; b; c; d; e; f] = read_ints 6 in
  let lim = f+1 in
  let warr = Array.make lim false in
  let sarr = Array.make lim false in
  for_iter_ 0 (f / (100*a) + 1) (fun x ->
    for_iter_ 0 ((f - 100*a*x) / (100*b) + 1) (fun y ->
      warr.(100*(a*x + b*y)) <- true));
  for_iter_ 0 (f / c + 1) (fun x ->
    for_iter_ 0 ((f - c*x) / d + 1) (fun y ->
      sarr.(c*x + d*y) <- true));

  let sentinel = (0, 100*a) in
  let h = List.fold_left rat_max sentinel in
  for_iter 0 lim (fun x -> for_iter 0 lim (fun y ->
    if warr.(x) && sarr.(y) && y <= e * x / 100 && x + y <= f then (y, x+y) else sentinel)
    |> h) |> h
  |> (fun (x, y) -> printf "%d %d\n" y x)


Measured memory_bytes: 5504
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys

# import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().decode('utf8').rstrip()

print(s[::2])


Measured memory_bytes: 21724
#include<bits/stdc++.h>
using namespace std;
string S[3];
int main(){
	cin>>S[0]>>S[1]>>S[2];
	int turn=0;
	while(true){
		int V=S[turn][0]-'a';
		S[turn]=S[turn].substr(1,S[turn].size()-1);
		if(S[turn].size()==0){cout<<(char)('A'+turn)<<endl;break;}
		turn=V;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int n,o=1,s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=2;i<=n;i++)
	{
		if(a[i]!=a[i-1])
		{
			if(o<a[i-1])
			{
				s+=o;
			}
			else
			{
				s+=(o-a[i-1]);
			}
			o=1;
		}
		else
		{
			o++;
		}
	}
	if(o<a[n])
	{
		s+=o;
	}
	else
	{
		s+=(o-a[n]);
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;
ll f(ll x,ll y){
    ll ret=1;
    while (y){
        if (y&1){
            ret=ret*x%mod;
        }
        x=x*x%mod;
        y/=2;
    }
    return ret;
}
int main()
{
    FASTINOUT;
    ll x;
    cin>>x;
    ll a[x];
    for (int i=0;i<x;i++)
        cin>>a[i];
    ll sum=0;
    for (int i=0;i<x;i++)
        sum=(sum%mod+a[i]%mod)%mod;
    ll k=(sum*sum)%mod;
    ll m=0;
    for (int i=0;i<x;i++){
        m=(m+((a[i]*a[i])%mod))%mod;
    }
    cout<<(((k-m+mod)%mod)*(f(2,mod-2)%mod))%mod;
    return 0;
}


Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  double n,k,ans=0,p=1,y=0.5,t=2;
  cin >>n>>k;
  ll ni=n,d=0,fl=0;
  for(ll i=1;i<=ni;i++){
    if(fl==0){
    double f=(log10(k/i)/log10(t))+p;
    d=ceil(f);
  }
    if(d==1) {
      ans+=(p/n);
      fl=1;
    }
    else ans+=((pow(y,d-1))/n);
  }
   printf("%.16f\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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; }

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

  int N;cin>>N;
  vector<int>a(N);
  rep(i,0,N)cin>>a[i];
  map<int,int>m;
  int ans(0);
  rep(i,0,N){
    m[a[i]]++;
  }

  for(auto &a:m){
    if(a.second<a.first)
      ans+=a.second;
    else
      ans+=a.second-a.first;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for(int i = 0; i < k; i++){
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
//============================================================================
// Name        : Osenbei
// Author      : seaupnice
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

const int MAX_R=10;
const int MAX_C=10000;
bitset<MAX_C> maze[MAX_R];
int R,C;
int ans;
/* dfs()全排列*/
void dfs(int k){
	if(k==C){
		int result=0;
		for(int i=0; i<R; i++){
			int upnum=0;
			for(int j=0; j<C; j++){
				if(maze[j][i]){
					upnum++;
				}
			}
			result += max(upnum,C-upnum);
		}
		ans = max(ans, result);
		return;
	}
	dfs(k+1);
	maze[k].flip();
	dfs(k+1);
}

int main(){
	while((cin >> C >> R) && C && R){
		for(int i=0; i<C; i++){
			for(int j=0; j<R; j++){
				int a;
				scanf("%d",&a);
				maze[i][j] = (a==1?true:false);
			}
		}
		ans=0;
		dfs(1);
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3124
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin


def bit_count(x):
    return bin(x).count("1")

def bit_exchange(x):
    return 2 ** (x-1)

all_switch_list=[]
clear_list=[]


N, M = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(M):
    switch_list = [int(x) for x in stdin.readline().rstrip().split()]
    bin_s_list = 0
    for j in range(switch_list[0]):
        # j+1 
        bin_s_list = bin_s_list | bit_exchange(switch_list[j+1])

    
    all_switch_list.append(bin_s_list)
remainder = [int(x) for x in stdin.readline().rstrip().split()]

#for i in range(bit_exchange(N+1)):

clear_list = list(range(bit_exchange(N+1)))
for i in range(M):
    for j in range(bit_exchange(N+1)):
        count = j & all_switch_list[i]
        if bit_count(count) % 2 != remainder[i]:
            try:
                clear_list.remove(j)
            except:
                pass

print(len(clear_list))


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll dp[110][100010];//dp[i][j]=i人終わってj個配る方法
ll cum[100010];//cum[x]=dp[i][j]のjの[0,x)の和

int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	dp[0][0]=1;
	rep(i,0,n){
		cum[0]=0;
		rep(j,0,k+2)cum[j+1]=(cum[j]+dp[i][j])%MOD;
		ll t;
		scanf("%lld",&t);
		rep(j,0,k+1)dp[i+1][j]=cum[j+1]-cum[max(0,j-t)];
	}
	printf("%lld\n",(dp[n][k]+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 82048
///
// File:  1610.cpp
// Author: ymiyamoto
//
// Created on Wed Nov 29 00:50:26 2017
//

#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint64_t m, n;
    cin >> m >> n;
    if (m == 0 && n == 0) break;

    array<bool, 7368792> years;
    for (uint64_t i = 0; i < years.size(); i++) {
      years[i] = true;
    }

    uint64_t year = m;
    for (uint64_t i = 0; i < n; i++) {
      for (uint64_t j = year; j < years.size(); j += year) {
        years[j] = false;
      }

      while (!years[year]) {
        year++;
      }
    }
    cout << year << endl;
  }
  return 0;
}

Measured memory_bytes: 10288
A, B, C = map(int, input().split())
K = int(input())

count = 0
while True:
    if A < B:
        break
    B *= 2
    count += 1
while True:
    if B < C:
        break
    C *= 2
    count += 1

if count <= K:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9164
/*input
1000000000000000000
*/
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mod 998244353
#define int double

long poss(int x) {
	double num = 101.0/100.0;
	long prin = 100;
	if(prin >=x) return 0;
	for(int i=1;i<=100005;i++) {prin*=num;
	if(prin >= x) return i;}
	return -1;
}

signed main() {
	int x;
	cin>>x;
	// int lo = 0, hi = 10005;
	// while(lo<hi) {
	// 	int mid = (lo+hi)/2;
	// 	if() hi = mid;
	// 	else lo = mid+1;
	// }
	long ans = poss(x);
	//if(ans != lo) ans++;
	cout<<ans<<endl;
}

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

int main() {

	int go = 0;
	int an = 0;

	int ch = 0;
	cin >> go;

	if (100 <= go && go <= 100000) {
		if (2000 < go) {
			an = 1;
		}else{
			for (int i = 0; i < 20; i++) {
				ch = go / 100;

				if (ch==(i+1)&&go <= 100 * (i+1) + 5 * (i+1)) {
					an = 1;
				}
			}
		}
	}
	cout << an;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int b[n];
	long long int ans = 0;
	for (int i=1;i<n;i++)
	{
		cin >> b[i];
	}
	ans = b[1]+b[n-1];
	for (int i=2;i<n;i++)
	{
		ans+=min(b[i-1],b[i]);
	}
	cout << ans;
	
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9;
const llong LINF = 2e18;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Improving atcoter rating

// Code below

int n;

vector<llong> arr;

void inp() {
    cin >> n;
    arr.resize(n);
    for (auto &x: arr) {
        cin >> x;
    }
}

void solve() {
    int cntN = 0, cnt4 = 0;
    for (auto &x: arr) {
        if (x % 2 == 1) {
            cntN++;
        }
        if (x % 4 == 0) {
            cnt4++;
        }
    }
    if (cntN + cnt4 == n) {
        cout << (cnt4 >= cntN - 1 ? "Yes" : "No");
    } else {
        cout << (cnt4 >= cntN ? "Yes" : "No");
    }
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


Measured memory_bytes: 1024
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
int fa[100005],sz[100005],n,m,x[100005],y[100005];
ll pre[100005];
inline int gf(int x) {
	return fa[x]==x?x:fa[x]=gf(fa[x]);
}
int main() {
	read(n),read(m);
	for(int i=1;i<=n;++i)
		fa[i]=i,sz[i]=1;
	for(int i=1;i<=m;++i)
		read(x[i]),read(y[i]);
	for(int i=m;i;--i) {
		int u=gf(x[i]),v=gf(y[i]);
		if(u==v)
			continue;
		pre[i]=1ll*sz[u]*sz[v],fa[v]=u,sz[u]+=sz[v];
	}
	for(int i=1;i<=m;++i)
		pre[i]+=pre[i-1],printf("%lld\n",pre[i]);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

struct mi {
  int val; static const int MOD = 1e9+7; static_assert(MOD > 0, "Modulus not set!");
  mi(int v=0) : val(v) { if ((val %= MOD) < 0) val += MOD; }
  mi& operator += (const mi& b) { (val += b.val) %= MOD; return *this; }
  mi& operator -= (const mi& b) { return (*this) += MOD-b.val; }
  mi& operator *= (const mi& b) { val = ((ll)val*(ll)b.val) % MOD; return *this; }
  mi& operator /= (const mi& b) { return (*this) *= b.pow(MOD-2); }
#define _op(op, op2) mi operator op (const mi& b) const { mi ans = *this; return ans op2 b; }
  _op(+, +=); _op(-, -=); _op(*, *=); _op(/, /=);
#undef _op
  mi pow(ll e) const { mi res(1), b(*this); for (; e>0; e/=2, b*=b) { if (e&1) res*=b; } return res; }
  int toInt() const { return val; }
};

template <class T, int N>
struct matrix {
  T b[N][N];
  T& operator()(int i, int j) {
    return b[i][j];
  }
  matrix operator*(matrix& o) const {
    matrix ret;
    forx(i, N) forx(j, N) forx(k, N) ret(i, j) += b[i][k] * o(k, j);
    return ret;
  }
};

using mat = matrix<mi, 50>;

int n;
ll k;

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n >> k;
  mat m, a;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int v; cin >> v;
      m(i, j) = v;
    }
  }
  for (int i = 0; i < n; ++i) a(i, i) = 1;
  while(k) {
    if (k & 1) {
      a = a * m;
    }
    m = m*m;
    k /= 2;
  }
  mi ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      ans += a(i, j);
    }
  }
  cout << ans.toInt() << nl;

  return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	char s[500001];
	scanf("%s", s+200000);
	int l=200000, r=200000+strlen(s+200000);
	int f=1;

	int q, i;
	scanf("%d", &q);
	for(i=0; i<q; i++){
		int Q, F;
		char c;
		scanf("%d", &Q);
		if(Q==1){
			f=(f==1?2:1);
		}else{
			scanf("%d %c", &F, &c);
			if(F==f){
				s[--l]=c;
			}else{
				s[r++]=c;
			}
		}
	}
	if(f==1){
		s[r]=0;
		printf("%s\n", s+l);
	}else{
		for(i=r-1; i>=l; i--){
			putchar(s[i]);
		}
		putchar(10);
	}
}


Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int[] M = new int[2];
		int[] D = new int[2];
		for (int i = 0; i < 2; i++) {
			String[] str = reader.readLine().split(" ");
			M[i] = Integer.parseInt(str[0]);
			D[i] = Integer.parseInt(str[1]);
		}
		if (M[0] == M[1]) {
			System.out.println("0");
		}
		else {
			System.out.println("1");
		}
	}
}


Measured memory_bytes: 22612
#include<stdio.h>
int main(void){
    int i,n, people[4][3][10]={}, b, f, r, v, j, k;
    scanf("%d", &n);
    for(i = 0;i < n;i ++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        people[b-1][f-1][r-1] += v;
    }
    for(i=0 ;i<4 ;i++){
        if(i) printf("####################\n");
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf(" %d", people[i][j][k]);
            }
            printf("\n");
        }
    }
    return 0;
}

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

typedef int data_t;

typedef struct tag_node {
  tag_node *before_;
  data_t    data_;
  tag_node *next_;
} node_t;

class List
{
  node_t *head_;
  node_t *FindNodeFromBefore(data_t) const;
  node_t *FindLastNode(void) const;
public:
  List(void);
  void Insert(data_t);
  int Delete(data_t);
  int DeleteFirst(void);
  int DeleteLast(void);
  int Print(void) const;
};

List::List(void) {
  head_ = new node_t;
  head_->before_ = head_;
  head_->next_   = head_;
}

node_t *List::FindNodeFromBefore(data_t findData) const {
  node_t *tmp;

  for (tmp = head_->next_; tmp != head_; tmp = tmp->next_) {
    if (tmp->data_ == findData) return tmp;
  }

  return tmp;
}

node_t *List::FindLastNode(void) const {
  node_t *tmp;

  for (tmp = head_->next_; tmp->next_ != NULL; tmp = tmp->next_) ;

  return tmp;
}

void List::Insert(data_t data) {
  node_t *node = new node_t;

  node->data_ = data;

  node->next_ = head_->next_;
  head_->next_->before_ = node;
  head_->next_ = node;
  node->before_ = head_;
}

int List::Delete(data_t data) {
  node_t *target = FindNodeFromBefore(data);

  if (target == head_) return 1;

  target->before_->next_ = target->next_;
  target->next_->before_ = target->before_;

  delete target;

  return 0;
}

int List::DeleteFirst(void) {
  node_t *target = head_->next_;
  if (target == head_) return 1;

  target->before_->next_ = target->next_;
  target->next_->before_ = target->before_;

  delete target;
}

int List::DeleteLast(void) {
  node_t *target = head_->before_;

  if (target == head_) return 1;

  target->before_->next_ = target->next_;
  target->next_->before_ = target->before_;

  delete target;
}

int List::Print(void) const {
  if (head_->next_ == head_) return 1;

  node_t *tmp;

  for (tmp = head_->next_; tmp != head_; tmp = tmp->next_) {
    if (tmp != head_->next_) cout << " ";
    cout << tmp->data_;
  }
  cout << endl;

  return 0;
}

int main(void)
{
  int n;
  data_t value;
  char command[12];
  List list;

  scanf("%d%*c", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%*c", command);

    if (command[0] == 'i') {
      scanf("%d%*c", &value);
      list.Insert(value);
      continue;
    }
    switch(command[6]) {
    case 'F':
      list.DeleteFirst();
      continue;
    case 'L':
      list.DeleteLast();
      continue;
    default:
      scanf("%d%*c", &value);
      list.Delete(value);
      continue;
    }
  }
  list.Print();

  return 0;
}

Measured memory_bytes: 32364
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
#include <boost/multiprecision/integer.hpp>


template<typename T>
void invec(vector<T> &A){rep(i, 0, A.size()) cin >> A[i];}

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

int N; cin >> N;
VI A(N); invec(A);

i64 ans = 0;
int maxdigit = (int)log2(*max_element(ALL(A)))+ 1;
rep(digit, 0, maxdigit){
    i64 cnt1 = 0;
    rep(i, 0, N)
        if (A[i] & (1LL<<digit)) ++cnt1;
    (ans += (1LL<<digit) %MOD * cnt1 %MOD * (N - cnt1) %MOD) %= MOD;
}
cout << ans << endl;

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 2560
use proconio::input;

const MOD: usize = 1_000_000_007;

fn main() {
  input! {
    n: usize,
    vals: [usize;n]
  }
  
  let mut memo: Vec<usize> = vec![0;n];
  memo[n-1] = vals[n-1] % MOD;
  let mut index = n-2;
  loop {
    memo[index] = (memo[index+1] + vals[index]) % MOD;
    if index == 0 { break }
    index -= 1;
  }

  let mut result = 0;
  for i in 0..n-1 {
    result = (result + (vals[i] * memo[i+1] % MOD)) % MOD;
  }
  
  println!("{}", result);
}

Measured memory_bytes: 7096
h,w=[int(i) for i in input().split()]
alpha=[chr(i) for i in range(65, 65+26)]
s=[]
for i in range(h):
    s.append(input().split())

for i in range(h):
    for j in range(w):
        if s[i][j]=="snuke":
            print( alpha[j] +str(i+1))

Measured memory_bytes: 3060