akhauriyash/Code-Regression huggingface dataset:
/**
*	created: 30.09.2020 18:13:38
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define len(x) ll(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
using ll = long long;
using P = pair<int,int>;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
inline void print(P a) {cout << a.first << " " << a.second << endl;}
template<typename T> T bpow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

// ModInt
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {if ((x = x_ % mod + mod) >= mod) x -= mod;}
    ModInt inv() const {return bpow(*this, mod - 2);}
    ModInt& operator+=(ModInt rhs) {if ((x += rhs.x) >= mod) x -= mod; return *this;}
    ModInt& operator-=(ModInt rhs) {if ((x -= rhs.x) < 0) x += mod; return *this;}
    ModInt& operator*=(ModInt rhs) {x = (unsigned long long)x * rhs.x % mod; return *this;}
    ModInt& operator/=(ModInt rhs) {x = (unsigned long long)x * rhs.inv().x % mod; return *this;}
    ModInt operator-() const {return -x < 0 ? mod - x : -x;}
    ModInt operator+(ModInt rhs) const {return ModInt(*this) += rhs;}
    ModInt operator-(ModInt rhs) const {return ModInt(*this) -= rhs;}
    ModInt operator*(ModInt rhs) const {return ModInt(*this) *= rhs;}
    ModInt operator/(ModInt rhs) const {return ModInt(*this) /= rhs;}
    bool operator==(ModInt rhs) const {return x == rhs.x;}
    bool operator!=(ModInt rhs) const {return x != rhs.x;}
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {s << a.x; return s;}
    friend istream& operator>>(istream& s, ModInt<mod>& a) {s >> a.x; return s;}
};

using mint = ModInt<MOD>;

signed main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;
    mint ans = 0;
    int st = 0;
    if (s[0] == t[0]) {
        ans += 3;
        st += 1;
    }
    else {
        ans += 6;
        st += 2;
    }
    rep2(i,st,n) {
        if (s[i] == t[i]) {
            if (s[i-1] != t[i-1]) {
                continue;
            }
            else {
                ans *= 2;
            }
        }
        else {
            if (s[i-1] != t[i-1]) {
                ans *= 3;
            }
            else {
                ans *= 2;
            }
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    int ans = n%1000;
    if (ans>0) {
        ans = 1000-ans;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
s=[0]*N
jog=float('inf')
cnt=0
for i in range(N):
    s[i] = int(input())
for i in range(N):
    if s[i]%10!=0:
        jog=min(jog,s[i])
    else:
        cnt+=1
ans=sum(s)
if ans%10 != 0:
    print(ans)
elif ans%10 == 0 and cnt==N:
    print(0)
else:
    print(ans-jog)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000],b[1000],c[1000];
int main(){
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++) cin>>a[i];
    for(int i=0;i<y;i++) cin>>b[i];
    for(int i=0;i<z;i++) cin>>c[i];
    sort(a,a+x);
    sort(b,b+y);
    sort(c,c+z);
    reverse(a,a+x);
    reverse(b,b+x);
    reverse(c,c+x);
    
    vector<ll> ab;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            ab.push_back(a[i]+b[j]);
        }
    }
    sort(ab.begin(),ab.end());
    reverse(ab.begin(),ab.end());
    
    vector<ll> abc;
    for(int i=0;i<min(k,(int)ab.size());i++){
        for(int j=0;j<z;j++){
            abc.push_back(ab[i]+c[j]);
        }
    }
    sort(abc.begin(),abc.end());
    reverse(abc.begin(),abc.end());
    
    for(int i=0;i<k;i++) cout<<abc[i]<<endl;
    return 0;
}


Measured memory_bytes: 43364
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  a, b = get_ints
  puts a.lcm(b)
end

if __FILE__ == $0
  main
end



Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

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

//ツヒツッツトツ青板づーツ陛板つキ
int hit(string a,string b){
	int res = 0;
	rep(i,4) if(a[i] == b[i]) res++;
	return res;
}

//ツブツδ債ーツ青板づーツ陛板つキ
int blow(string a,string b){
	int res = 0;
	rep(i,4) rep(j,4){
		if(i == j) continue;
		if(a[i] == b[j]){
			res++;
			break;
		}
	}

	return res;
}

int main(void){
	vector<string> s,init;

	//4ツケツタツづ個各ツ個つェツ暗卍づ按づゥツ青板づーツ療アツ仰督つキツづゥ
	rep(i,10) rep(j,10) rep(k,10) rep(l,10) {
		if(i != j && i != k && i != l && j != k && j != l && k != l){
			string str = "";
			str += '0' + i;
			str += '0' + j;
			str += '0' + k;
			str += '0' + l;
			init.push_back(str);
		}
	}

	int n;
	while(cin>>n,n){
		s = init;
		while(n--){
			string str;
			int h,b;
			cin>>str>>h>>b;

			vector<string> next;
			rep(i,s.size()){
				if(hit(str,s[i]) == h && blow(str,s[i]) == b){
					next.push_back(s[i]);
				}
			}
			s = next;
		}

		if(s.empty()){
			cout<<"????\n";
		}
		else if(s.size() == 1){
			cout<<s[0]<<endl;
		}
		else{
			bool ansFlg;
			rep(i,init.size()){
				bool used[5][5];
				memset(used,0,sizeof(used));
				ansFlg = true;

				rep(j,s.size()){
					int h = hit(init[i],s[j]);
					int b = blow(init[i],s[j]);
					if(used[h][b]){
						ansFlg = false;
						break;
					}
					used[h][b] = true;
				}

				if(ansFlg){
					cout<<init[i]<<endl;
					break;
				}
			}
			if(!ansFlg) cout<<"????\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1096
H,W,l1,l2=list(map(int,input().split()))
import numpy as np
l=np.zeros((H,W))
if l2>0:
   l[0:l2,l1:]=1
if l1>0:
   l[l2:,0:l1]=1
for i in l:
   print(*list(map(int,i)),sep="")

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


int main(void){
  int a,b;
  int i,k;

  cin >> a >> b;

  k=0;

  i=1;

  while(i<b){
    i=i-1;
    i=i+a;
    k=k+1;
  }

  cout << k << "\n";

  return 0;
}


Measured memory_bytes: 256
class Main
  def self.main lines
    n,m = lines.shift.split.map(&:to_i)
    ab = Array.new(n) {lines.shift.split.map(&:to_i)}
    ab.sort! {|x,y| x[0] <=> y[0]}
#    p ab
    r = 0
    while m > 0
      s = ab.shift
      x = [m, s[1]].min
      m -= x
      r += x * s[0]
    end
    r
  end
end

if $0 == __FILE__
  $stdout = open('/dev/null', 'w')
  r = Main.main STDIN.readlines
  $stdout = STDOUT
  puts r
end

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

using namespace std;
const int INF = 1e9;

vector<int> bfs(int start, vector< vector<int> > &G) {
  vector<int> dist(G.size(), INF);
  queue<int> q;
  q.push(start);
  dist[start] = 0;
  while (!q.empty()) {
    int cur = q.front(); q.pop();

    for (int i = 0; i < G[cur].size(); ++i) {
      int next = G[cur][i];
      if (dist[next] == INF) {
	q.push(next);
	dist[next] = dist[cur] + 1;
      }
    }
  }
  return dist;
}

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  vector< vector<int> > G(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> dist_T = bfs(u, G);
  vector<int> dist_A = bfs(v, G);

  int idx = -1;
  int ma = -1;
  for (int i = 0; i < n; ++i) {
    if (dist_T[i] < dist_A[i] && dist_A[i] > ma) {
      idx = i;
      ma = dist_A[i];
    }
  }

  int meet = G[idx][0];
  int ans = dist_A[meet];
  cout << ans << endl;
  return 0;
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int main(){
	int n; scanf("%d",&n);
	cout<<pow(mint(10),n)-2*pow(mint(9),n)+pow(mint(8),n)<<'\n';
	return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vl A(N);
  rep(i,N) cin >> A[i];
  
  ll ans=0;
  rep(i,60) {
    int count=0;
    rep(j,N) {
      if(A[j]&1ll<<i) count++;
    }
    (ans+=(1ll<<i)%INF*count%INF*(N-count))%=INF;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5628
#include<stdio.h>
int main(void)
{
	int a,b,d,r;
	double x,y,f;
	scanf("%d%d",&a,&b);
	d=a/b;
	r=a%b;
	x=a;y=b;
	f=x/y;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define pb push_back
#define mp make_pair
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define IG cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define ll long long int
#define N 1378
#define maxn 1000003
#define FP ff.open("output.txt")
#define FR ff.open("input.txt")
#define valid(a,b) if(a>=1 && a<row-1 && b>=1 && b<col-1)
fstream ff;

ll a, q, b, c, d, k, h, e, f, t, m, n, i, j, x, y, count, tcase = 0, l, r;

string s1, s2, s;

int main() {
	cin>>n;
	cin>>s;
	for(int i = 0;i<s.size();i++){
		s[i]= 65 + (s[i]-65+n)%26;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

struct union_find {
	int par[214514], size_[214514];
	union_find(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int n, m;
map<int, int>mp;
int sum;
signed main() {
	cin >> n >> m;
	int ans = 0;
	mp[0] = 1;
	rep(i, n) {
		int a; cin >> a;
		sum += a;
		ans += mp[sum % m];
		mp[sum % m]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4224
a[1111],b[1111],c[1111],d[1111],p[333],i,j,x,y,z;main(){for(;scanf("%d%d%d",a,b,c)&&(*a+=*b+*c);){for(i=332;i;p[i--]=2);for(i=0,scanf("%d",p);i++<*p;scanf("%d%d%d%d",a+i,b+i,c+i,d+i));for(i=0;i++<*p;)for(j=0;j++<*p;d[j]?p[a[j]]=p[b[j]]=p[c[j]]=1:(x=p[a[j]]&1)&(y=p[b[j]]&1)?p[c[j]]=0:x&(z=p[c[j]])?p[b[j]]=0:y&z?p[a[j]]=0:0);for(i=0;i<*a;printf("%d\n",p[++i]));}exit(0);}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

P project(P a,P b,P c){
  b-=a,c-=a;
  return a+b*real(c/b);
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  scanf("%lf %lf %lf %lf %d",&ax,&ay,&bx,&by,&n);
  while(n--){
    scanf("%lf %lf",&cx,&cy);
    P p=project(P(ax,ay),P(bx,by),P(cx,cy));    
    printf("%.8f %.8f\n",p.real(),p.imag());
  }
  return 0;
}

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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef long long ll;

const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll Pow10[maxn];
char s[maxn];
int p, n;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  cin >> n >> p;
  cin >> s + 1;
  if (p == 2 || p == 5){
    ll ret = 0;
    for (int i = 1; i <= n; ++i){
      int c = s[i] - '0';
      if (c % p == 0) ret += i;
    }
    cout << ret;
    return 0;
  }
  Pow10[0] = 1;
  for (int i = 1; i <= n; ++i) Pow10[i] = Pow10[i-1] * 10, Pow10[i] %= p;
  ll ans = 0;
  vector<int> cnt(p + 1, 0);
  cnt[0]++;
  ll val = 0;
  for (int i = n; i >= 1; --i){
    int c = s[i] - '0';
    val = Pow10[n - i + 1] * c + val; val %= p;
    ans += cnt[val];
    cnt[val]++;
  }
  cout << ans;
}




Measured memory_bytes: 2048
def main():
    def accumulate(array):
        for i in range(len(array) - 1):
            array[i + 1] += array[i]
        return array

    N = int(input())
    A = list(map(int, raw_input().split()))
    MOD = 10 ** 9 + 7

    X = [[0] * N for i in range(61)]
    for i, a in enumerate(A):
        for j in range(61):
            if (1 << j) & a:
                X[j][i] = 1

    for i in range(61):
        X[i] = accumulate(X[i])


    ans = 0
    for i, a in enumerate(A):
        for j in range(61):
            x = X[j][-1] - X[j][i]
            if (1 << j) & a:
                ans += ((1 << j) % MOD) * ((N - i - 1) - x)
                ans %= MOD

            else:
                ans += ((1 << j) % MOD) * x
                ans %= MOD


    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 185320
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    // 入力の処理
    ll N;
    cin >> N;

    if (N % 2 == 0)
    {
        cout << 0.5 << endl;
    }
    else
    {
        double oddNum = ((N / 2) + 1);
        cout << oddNum / N << endl;
    }

    return;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

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

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;

		try {
			str=bfr.readLine();

			if(str=="") {
				System.exit(0);
			}

			stk=new StringTokenizer(str," ");

			int tatemono_kazu=Integer.parseInt(stk.nextToken());
			int tower_basyo=Integer.parseInt(stk.nextToken());

			int [][] tatemono=new int[tatemono_kazu][2];		//tatemono_ichi takasa
			double[] katamuki=new double[tatemono_kazu];
			double katamuki_max=0;

			for(int i=0; i<tatemono_kazu; i++) {
				str=bfr.readLine();
				stk=new StringTokenizer(str," ");

				for(int j=0; j<2; j++) {
					tatemono[i][j]=Integer.parseInt(stk.nextToken());
				}
				katamuki[i]=((double)(tatemono[i][1]))/((double)(tatemono[i][0]));
				if(katamuki_max<katamuki[i]) {
					katamuki_max=katamuki[i];
				}
				if(str=="") {
					System.exit(0);
				}
			}

			System.out.println(BigDecimal.valueOf(katamuki_max*((double)(tower_basyo))).toPlainString());

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 25984
n, k, q = map(int, input().split())
aa = []
for i in range(q):
    aa += [int(input())]

from collections import Counter
dic = Counter(aa)

cnt = 0
for i in range(1,n+1):
    if dic.get(i, 0) > q-k:
	    print('Yes')
    else:
        print('No')


Measured memory_bytes: 11924
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    int i,x;
    for(i=0;i<5;i++){
        cin>>x;
        if(x==0) cout<<i+1;
    }
    return 0;
}

Measured memory_bytes: 3588
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // 整数の入力
    int a = sc.nextInt();
    String result;
    if (a == 7 || a == 5 || a == 3) {
      result = "YES";
    } else {
       result = "NO"; 
    }
    // 出力
    System.out.println(result);
  } 
}

Measured memory_bytes: 21716
mod = 1000000007
n, m = map(int, input().split())
dat_m = []
dp = [0] * (n + 1)
for i in range(m):
    t = int(input())
    dp[t] = -1

dp[0] = 1
for i in range(1, n + 1):
    if dp[i] == -1:
        dp[i] = 0
        continue
    dp[i] = dp[i - 1]
    if i > 1:
        dp[i] += dp[i - 2]
    if i in dat_m:
        dp[i] = 0
    dp[i] = dp[i] % mod

print(dp[n])

Measured memory_bytes: 44248
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
for i in range(M):
    ans = []
    P, X = map(int, input().split())
    for j in range(N):
        if P == j + 1:
            ans.append(X)
        else:
            ans.append(T[j])
    print(sum(ans))

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    cout << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    cout << ']';
    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    
    if(s <= "2019/04/30"){
        ppp("Heisei");
    }
    else{
        ppp("TBD");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

const int MAX=1e4+5;
const int lim=1e2+1;
int fN[MAX];
int aux;

void calculate(){
    for(int i=1;i<lim;i++){
        for(int j=1;j<lim;j++){
            for(int k=1;k<lim;k++){
                aux=(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(i*k);
                if(aux<MAX) fN[aux]++;
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    calculate();
    for(int i=1;i<=n;i++){
        cout << fN[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int d = sc.nextInt();
	    long x, y;
	    int c = 0;
	    for (int i=0; i < n ; i++) {
            sc.nextLine();
            x = sc.nextInt();
            y = sc.nextInt();
            double dxy = Math.sqrt((x*x) + (y*y));
            if (dxy <= d) {
            	c++;
            }
        }
	    System.out.println(c);
	}
}

Measured memory_bytes: 50836
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define exists(x,m) m.find(x) != m.end()
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

vi primes;
vector<bool> composite;

void prime_sieve(int lim) {
	composite = vector<bool>(lim+1);
	for (int num = 2; num <= lim; num++) {
		if (!composite[num]) primes.pb(num);
		for (int i = 0; i < isize(primes) and num * primes[i] <= lim; i++) {
			composite[num * primes[i]] = true;
			if (num % primes[i] == 0) break;
		}
	}
}

umap<int, int> prime_fact(int x, vi& prime_list) {
	umap<int, int> divisors = umap<int, int>();
	for (int i = 0; prime_list[i]*prime_list[i] <= x; i++) {
		int p = prime_list[i];
		while (x % p == 0) {
			divisors[p]++;
			x /= p;
		}
	}
	if (x != 1) divisors[x]++;
	return divisors;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	int maxx = 0;
	rep(i, n) {
		int x; cin >> x;
		A.pb(x);
		maxx = max(maxx, x);
	}	
	prime_sieve(min(1e3+100, ceil(sqrt(maxx)) + 100));
	umap<int, int> prime_freq = umap<int, int>();
	for (const int& a : A) {
		for (const auto& [div, fre] : prime_fact(a, primes)) {
			prime_freq[div] += 1;
		}
	}
	int max_freq = 0;
	for (const auto& [p, freq] : prime_freq) {
		max_freq = max(max_freq, freq);
	}
	if (max_freq <= 1) {
		cout << "pairwise coprime";
	} else {
		cout << (max_freq < n ? "setwise coprime" : "not coprime");
	}
}

Measured memory_bytes: 10460
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=scan.nextInt();
		}
		int max=0,k=0;
		for(int i=0;i<n-1;i++)
		{
			if(a[i]>=a[i+1])
			{
				k++;
			}
			else
				k=0;
			if(k>max)
				max=k;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 50484
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int result,x,result2,y;
        int mov = 0;
        int go[][] = new int[n][2];
        for(int i = 0; i < n; i++){
            for(int k = 0; k < 2; k++){
               go[i][k] = sc.nextInt();
            }
        }
        for(int i = 1; i < n; i++){
            result = go[i][0] - go[i-1][0];
            x = Math.abs(result);
            result2 = go[i][1] - go[i-1][1];
            y = Math.abs(result2);
            mov = mov + x + y;
            if(result > 0 && result2 > 0 || result < 0 && result2 < 0){
                if(x <= y){
                    mov = mov - x;
                }else{
                    mov = mov - y;
                }
            }
        }
        System.out.println(mov);
    }
}

Measured memory_bytes: 25452
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  cin >> S;
  const int64_t L = static_cast<int64_t>(S.length());
  int64_t begin = 0;
  int64_t end = L - 1;
  int64_t result = 0;
  while (begin < end) {
    if (S.c_str()[begin] == S.c_str()[end]) {
      ++begin;
      --end;
    } else if (S.c_str()[begin] == 'x') {
      ++begin;
      ++result;
    } else if (S.c_str()[end] == 'x') {
      --end;
      ++result;
    } else {
      result = -1;
      break;
    }
  }
  cout << result << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  if(s == "ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }

  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

vector<int> S[2];
int main()
{
	int N; cin >> N;
	int ans = 0;
	if (N % 2 == 0) {
		for (int i = 1; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (j != N - i + 1) {
					ans++;
					S[0].push_back(i);
					S[1].push_back(j);
				}
			}
		}
	}
	else {
		for (int i = 1; i < N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (j != N - i) {
					ans++;
					S[0].push_back(i);
					S[1].push_back(j);
				}
			}
		}
	}
	cout << ans << endl;
	for (int i = 0; i < S[0].size(); i++) {
		cout << S[0][i] << " " << S[1][i] << endl;
	}
}

Measured memory_bytes: 384
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
abc = [LI() for _ in range(N)]
dp = [[0,0,0] for _ in range(N+1)]
for i,j,k in itertools.product(range(N),[0,1,2],[0,1,2]):
    if j==k:
        continue
    if i+1<=N:
        dp[i+1][j] = max(dp[i+1][j],dp[i][k]+abc[i][j])
print(max(dp[-1]))


Measured memory_bytes: 51340
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main() {
  int A, B, T;
  int n =1;
  int sum =0;
  cin >> A >> B >> T;
  while(T+0.5>n*A){
    sum += B;
    n++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

// a x + b y = gcd(a, b)
int extgcd(int a, int b, int& x, int& y) {
	int g = a;
	x = 1;
	y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}


int gcd(int x, int y) {
	int r;
	if(x < y) swap(x, y);

	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

/* mod mでのaの逆元を求める.(gcd(a,m) = 1) */
int modinv(int a, int m) {
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

/* 連立線形方程式を解く.
		A[i] * x ≡ B[i] (mod M[i])
	なる方程式の解が
		x ≡ b (mod m)
	とかけるとき、(b, m)を返す.(存在しなければ(0, -1)) */
pair<int, int> liner_congruence(vector<int> A, vector<int> B, vector<int> M) {
	int x = 0, m = 1;

	for (int i = 0; i < A.size(); ++i) {
		int a = A[i] * m, b = B[i] - A[i] * x, d = gcd(M[i], a);

		if (b % d != 0) // 解なし
			return make_pair(0, -1);

		int t = b / d * modinv(a / d, M[i] / d) % (M[i] / d);
		x = x + m * t;
		m *= M[i] / d;
	}

	return make_pair((x % m + m) % m, m);
}

signed main() {
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	cin >> p >> q;
	for (auto& i : p) i--;
	for (auto& i : q) i--;

	vector<int> a(n, 1), b(n, -1), m(n);
	rep(i, n) {
		int cur = p[i];
		int loop = 0;
		while (cur != p[i] or loop == 0) {
			loop++;
			cur = q[cur];
			if (i == cur) b[i] = loop;
		}
		if(b[i] > loop) b[i] %= loop;
		m[i] = loop;
	}
	//cout << b << endl;
	//cout << m << endl;
	if (any_of(all(b), [](int x) { return x == -1; })) {
		cout << -1 << endl;
	} else {
		auto tmp = liner_congruence(a, b, m);
		if (tmp == make_pair(0LL, -1LL)) cout << -1 << endl;
		else cout << tmp.first << endl;
	}
}



Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    string s; cin >> s;
    REP(i,s.size()){
        if(s[i]==',') cout << ' ';
        else cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

ks = []
ss = Array.new(m) { [] }

m.times do |i|
  _, *s = gets.split.map(&:to_i)
  ss[i] = s
end
ps = gets.split.map(&:to_i)

ans = 0

(1 << n).times do |bit|
  valid = true

  m.times do |i|
    count = ss[i].select { |s| bit[s - 1] == 1 }.count

    if count % 2 != ps[i]
      valid = false
      break
    end
  end

  ans += 1 if valid
end

puts ans


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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b == 2 ? a : gcd(b, a % b);};
ll poww(ll a, ll b, ll md) {
   return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
const int MOD = 1e9+7;
const int SIZE = 1e5+10;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;long long sum=0;
    for(int i=0;i<s.size();i+=1){
        int val = s[i]-48;
        sum = sum+val;
    }
    if(sum%9==0) cout<<"Yes\n";
    else cout<<"No\n";










    return 0;
}




Measured memory_bytes: 3700
require 'prime'

g = Prime::EratosthenesGenerator.new
h = Hash.new(0)
a = 2
while a < 100000
  h[a] = 1
  a = g.next
end
k = Array.new(100001, 0)
h.keys.each do |x|
  k[x] = 1 if h[(x + 1) / 2] == 1
end
1.upto(100000) do |i|
  k[i] += k[i - 1]
end
gets.to_i.times do
  l, r = gets.split.map(&:to_i)
  puts k[r] - k[l - 1]
end

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

int main()
{
    int n; cin>>n;
    vector<int> s(n);
    int res=0;
    for(auto& e: s) { cin>>e; res+=e; }
    sort(begin(s), end(s));
    for(auto& e: s) {
        if (res%10==0 && e%10!=0) {
            res-=e;
            break;
        }
    }
    cout<<(res%10==0 ? 0 : res)<<endl;
}

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

int main(){
    int N;
    cin>>N;
    string ans = "";
    while(N != 0){
        if(N%2 != 0){
            N--;
            ans = "1" + ans;
        }
        else ans = "0" + ans;
        N/= -2;
    }
    if(ans =="") ans = "0";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
mul [] [] = 0
mul (m:ms) (v:vs) = (m*v) + mul ms vs

mult :: [[Int]] -> [Int] -> [Int]
mult [] _ = []
mult (m:ms) v =
  (mul m v):(mult ms v)

main = do
  c <- getContents
  let c' = map (map read) $ map words $ lines c :: [[Int]]
      (m:n:_) = c'!!0
      matrix = take m $ drop 1 c'
      vector = concat $ take n $ drop (1+m) c'
      result = mult matrix vector
--  print matrix
--  print vector
  mapM_ print result

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

int main(){
	
	int n; cin>>n;
	bitset<4000010> bt;
	bt[0] = 1;
	int sum = 0;
	for(int i=0;i<n;i++){
		int a; cin>>a;
		sum += a;
		bt|=(bt<<a);
	}
	
	for(int i=(sum+1)/2;i<sum+1;i++){
		if(bt[i]){ cout<<i<<endl; return 0; }
	}
	
	
	return 0;
}

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

int main(){
    double pai=3.141592653589;
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<cstdlib>

using namespace std;

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

int main()
{
    int n, k;
    cin >> n >> k;
    long long int count = 0;
    int *h = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    qsort(h, n, sizeof(int), compare_int);

    for (int i = k; i < n; i++) {
        count += h[i];
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1916
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????

		var n = ss.Next<int>();
		var m = ss.Next<int>();
		var l = ss.Next<int>();
		int[,] a = new int[n, m];
		int[,] b = new int[m, l];

		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				var num = ss.Next<int>();
				a[i, j] = num;
			}
		}
		for (int i = 0; i < m; i++)
		{
			for (int j = 0; j < l; j++)
			{
				var num = ss.Next<int>();
				b[i, j] = num;
			}
		}

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

			for (int k = 0; k < l; k++)
			{
				long c = 0;
				for (int j = 0; j < m; j++)
				{

					c += a[i, j] * b[j, k];

				}
				if (k == l - 1)
				{
					Console.Write(c);
				}
				else
				{
					Console.Write(c + " ");
				}
			}
			Console.WriteLine("");
		}


		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		//int[] array = ss.Next<int>(10);
		//---------------------------------

	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

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

int main() {
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if(s < t)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}

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

using namespace std;

int main(){
  int N,SN=0,temp;
  cin >> N;
  temp=N;
  while(temp>0){
    SN+=temp%10;
    temp/=10;
  }
  if(N%SN==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

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

#define SIZE 7368791+1
bool num[SIZE];

int main() {
	while(1) {
	    int m, n; cin >> m >> n;
	    if(m*n==0) break;

        memset(num, false, SIZE);

        int j = m;
        rep(i, n) {
            while(num[j]) j++;
            for(int k=j; k<SIZE; k+=j) num[k]=true;
        }

        while(num[j]) j++;
        cout << j << endl;
	}
}



Measured memory_bytes: 10276
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	int a[N-1];
	vector<int> s(N);
	for(int i=0;i<N-1;i++){
		cin>>a[i];
		s[a[i]-1]++;
	}
	for(int i=0;i<s.size();i++){
		cout<<s[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	int a[110];
	rep(i, N) cin >> a[i];


	ll ans = 0;
	rep(i, N) {
		ans += (ll)((D - 1)/a[i] + 1);
	}
	printf("%lld\n", ans + X);
	return 0;
}

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

ll cnt[200005];

void dfs(int v, int p, vector<vector<int>> &G){
    for(auto nv : G[v]){
        if(nv == p) continue;
        cnt[nv] += cnt[v];
        dfs(nv, v, G);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<vector<int>> G(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int p;
        ll x;
        cin >> p >> x;
        --p;
        cnt[p] += x;
    }
    dfs(0, -1, G);
    rep(i,n) cout << cnt[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 27392
from collections import defaultdict
import itertools
n = int(input())
lis = list(map(int,input().split()))
lis = [lis[i]-i for i in range(n)]
  #print(lis)
counter = defaultdict(int)
ans = 0
for num in lis:
    counter[num] += 1
for i,x in enumerate(lis):
    ans += counter[-x-2*i]
print(ans)

Measured memory_bytes: 56008
#include<stdio.h>

int rei[100001];
int sub[100001];
int fin[100001];
int n;

int depth(int);
int height(int);

int main(int argc,char *argv[]){
  int i,j;
  scanf("%d",&n);
  for(i = 0;i < n; ++i){
    rei[i] = -1;
    sub[i] = -1;
    fin[i] = 0;
  }
  for(i = 0; i < n; ++i){
    int ts, hi, mi;
    scanf("%d %d %d", &ts,&hi,&mi);
    if(hi != -1) {
      rei[hi] = ts;
      sub[hi] = mi;
      fin[ts]++; 
    }
    if(mi != -1) {
      rei[mi] = ts;
      sub[mi] = hi;
      fin[ts]++;
    }
  }
  
  for(i = 0; i < n; ++i) {
    int deg = depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
	   i, rei[i], sub[i], fin[i], deg, height(i));
    if(deg == 0) {
      printf("root\n");
    } else if(fin[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}

int depth(int i) {
  if (rei[i] == -1)return 0;
  return depth(rei[i]) + 1;
}

int height(int i){
  int j, p = 0;
  
  for (j = 0; j < n; ++j) {
    if (rei[j] == i){
    int t = height(j) + 1;
    if(t > p) p = t;
  }
}
return p;
}
	 
       



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

ll binary_serch(vector<ll> a, ll x, ll l, ll r) {
  ll lb = l-1; ll ub = r;
  while(ub - lb > 1) {
    ll m = (lb + ub) / 2;
    if (a[m] >= x) ub = m;
    else lb = m;
  }
  return ub;
}

int main() {
  int n;
  cin >> n;
  vector<ll> L(n);
  rep(i,n) cin>>L[i];
  sort(L.begin(), L.end());
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      int k = binary_serch(L, L[j]+L[i], j+1, n);
      ans += k - j - 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<vi> graph(n,vi());
    vi h(n);
    vi h2(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        graph[x-1].push_back(y-1);
        h[y-1]++;
        h2[y-1]++;
    }
    stack<int> st;
    vi dp(n,-1);
    for(int i=0;i<n;i++){
        if(h[i]==0){
            st.push(i);
            dp[i]=1;
        }
    }
    vi ans;
    while(st.size()){
        int i=st.top();
        st.pop();
        ans.push_back(i);
        for(auto j:graph[i]){
            h[j]--;
            if(h[j]==0){
                st.push(j);
                dp[j]=dp[i]+1;
            }
        }
    }
    queue<int> que;
    vi dp2(n,-1);
    for(int i=0;i<n;i++){
        if(h2[i]==0){
            que.push(i);
            dp2[i]=1;
        }
    }  
    vi ans2;
    while(!que.empty()){
        int i=que.front();
        que.pop();
        ans2.push_back(i);
        for(auto j:graph[i]){
            h2[j]--;
            if(h2[j]==0){
                que.push(j);
                dp2[j]=dp2[i]+1;
            }
        }
    }
    /*
    cout << "ans" << endl;
    for(int i:ans) cout << i+1 << endl;
    cout << "ans2" << endl;
    for(int i:ans2) cout << i+1 << endl;
    int maxi=0;
    for(int i:dp) cout << i << " ";
    cout << endl;
    for(int i:dp) maxi=max(maxi,i);
    cout << "maxi " << maxi << endl;
    */
    int maxi2=0;
    //for(int i:dp2) cout << i << " ";
    //cout << endl;
    for(int i:dp2) maxi2=max(maxi2,i);
    //cout << "maxi2 " << maxi2 << endl;
    cout << maxi2-1 << endl;
    

    return 0;
}

Measured memory_bytes: 11396
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner *bufio.Scanner

func printIt() {
	rows := nextInt()
	cols := nextInt()
	matrix := make([][]int, 0)
	for r := 0; r < rows; r++ {
		var nums []int
		for c := 0; c < cols; c++ {
			nums = append(nums, nextInt())
		}
		matrix = append(matrix, nums)
	}
	vector := make([]int, cols)
	for i := 0; i < cols; i++ {
		vector[i] = nextInt()
	}
	for r := 0; r < rows; r++ {
		sum := 0
		for c := 0; c < cols; c++ {
			sum += vector[c] * matrix[r][c]
		}
		fmt.Println(sum)
	}
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1320