akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;
ll x, y;

vector<ll> vi[2];
vector<vector<bool>> g;

int main() {
	cin >> s >> x >> y;
	bool f = 0;
	ll cnt = 0;
	g.resize(8000);
	rep(i, 8000)g[i].resize(20000, 0);
	rep(i, s.size()) {
		g[i].resize(20000, 0);
		if (s[i] == 'F')cnt++;
		else {
			if (!f)vi[0].push_back(cnt);
			else vi[1].push_back(cnt);
			cnt = 0;
			f = !f;
		}
	}
	if (!f)vi[0].push_back(cnt);
	else vi[1].push_back(cnt);
	//if (vi[1].size() <= 1 && vi[0].size() == 1) {
	//	if (x != vi[0][0]) {
	//		cout << "No" << endl;
	//		return 0;
	//	}
	//}
	g[0][10000] = 1;
	if (vi[0].size() >= 1) {
		g[1][10000 + vi[0][0]] = 1;
		FOR(i, 1, vi[0].size()) {
			rep(j, 20000) {
				if (g[i][j]) {
					if (j + vi[0][i] < 20000)g[i + 1][j + vi[0][i]] = 1;
					if (i != 0 && j - vi[0][i] >= 0)g[i + 1][j - vi[0][i]] = 1;
				}
			}
		}
	}
	if (!g[vi[0].size()][x + 10000]) {
		cout << "No" << endl;
		return 0;
	}
	g.clear();
	g.resize(8000);
	rep(i, 8000)g[i].resize(20000, 0);
	g[0][10000] = 1;
	rep(i, vi[1].size()) {
		rep(j, 20000) {
			if (g[i][j]) {
				if (j + vi[1][i] < 20000)g[i + 1][j + vi[1][i]] = 1;
				if (j - vi[1][i] >= 0)g[i + 1][j - vi[1][i]] = 1;
			}
		}
	}
	if (!g[vi[1].size()][y + 10000]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

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

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


    printf("%d\n",N*N*N);

    return 0;
}

Measured memory_bytes: 256
ans = 0

def search(num, target):
  global ans
  if len(num) == len(target):
    if int(num) <= int(target) and "3" in num and "5" in num and "7" in num:
      ans+=1
  else:
    search(num+"3", target)
    search(num+"5", target)
    search(num+"7", target)
  

N = input()
length = len(N)
for i in range(3, length):
  ans += 3**i - 3 * (2**i - 1)
  



    
search("", N)
    
if len(N) >= 3:
  print(ans)
else:
  print(0)

Measured memory_bytes: 3064
from math import floor, ceil, sqrt
N, M = [int(elem) for elem in input().split(' ')]

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    try:
        b, e = fct.pop()  # base, exponent
    except:
        return []
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

M_divisors = divisorize(factorize(M))
threshold = M // N
max_possible_divisor = 1
for M_divisor in M_divisors:
    divisor = num(M_divisor)
    if divisor <= threshold:
        max_possible_divisor = max(max_possible_divisor, divisor)
print(max_possible_divisor)


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

int main()
{
string s;
cin >> s;
sort(s.begin(), s.end());  
s.erase(unique(s.begin(), s.end()), s.end());

if(s.size() == 1) cout << "No" << endl;
else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

hour = h + (m / 60)

hour_dis = m / 60
hour_pos = (h + hour_dis) * 5
min_pos = m

dist = abs(hour_pos - min_pos)
if dist > 30:
  dist = 60 - dist

angle = (dist * 90) / 15

res = math.sqrt((a**2)+(b**2)-(2*a*b*math.cos(math.radians(angle))))

print(res)


Measured memory_bytes: 9584
#include<stdio.h>
int main(){
	int a;
	int b;
	int c;
	scanf("%d%d%d", &a, &b, &c);
	if(a < b && b < c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

typedef pair<int, int> i_i;

int N;
i_i pp;

void dfs(int u, int p, vector<vector<int> >& G, vector<int>& num) {
	num[u] = 1;
	for (int i = 0; i < G[u].size(); i++) {
		int v = G[u][i];
		if (v == p) continue;
		dfs(v, u, G, num);
		num[u] += num[v];
		if (num[v] == N / 2)
			pp = i_i(u, v);
	}
}

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return (v[x] < 0) ? x : (v[x] = find(v[x])); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (-v[x] < -v[y]) swap(x, y);
			v[x] += v[y]; v[y] = x;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int x, y; cin >> N >> x >> y;
	x--; y--;
	if (N == 2) {
		cout << "Yes" << endl;
		return 0;
	}
	if (N % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	vector<vector<int> > G(N);
	vector<int> d(N), A, B;
	for (int i = 0; i < N - 1; i++) {
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
		d[a]++; d[b]++;
		A.push_back(a);
		B.push_back(b);
	}
	vector<int> num(N);
	dfs(0, -1, G, num);
	union_find uf(N);
	for (int i = 0; i < N - 1; i++) {
		int a = A[i], b = B[i];
		if (i_i(a, b) == pp || i_i(b, a) == pp) {
			d[a]--; d[b]--;
		}
		else uf.unite(a, b);
	}
	for (int u = 0; u < N; u++)
		if (d[u] >= 3) {
			cout << "No" << endl;
			return 0;
		}
	if (uf.same(x, y)) {
		cout << "No" << endl;
		return 0;
	}
	if (d[x] == 1 && d[y] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 18084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    int a, b; cin >> a >> b;
    int fi=0, se=0, th=0;
    rep(i,n){
        int num; cin >> num;
        if(num<=a) fi++;
        else if(num<=b) se++;
        else th++;
    }
    cout << min({fi,se,th}) << endl;

    return 0;
}

Measured memory_bytes: 256
while(1):
    line = input()
    words = line.split()
    a = int(words[0])
    op = words[1]
    b = int(words[2])
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    elif op == '?':
        break

Measured memory_bytes: 7624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();
        String ss = s.substring(k - 1, k);
        for (int i = 0; i < n; i++) {
            String ans = s.substring(i, i + 1);
            if(ans.equals(ss)) System.out.print(ans);
            else System.out.print("*");
        }
    }
}

Measured memory_bytes: 35828
n = int(input())
a = list(map(int, input().split()))


if n%2 == 0:
    for i in range(n-1,-1,-2):
        print(a[i], end=' ')
    for i in range(0, n, 2):
        print(a[i], end=' ')
    
elif n%2 == 1:
    for i in range(n-1,-1,-2):
        print(a[i], end=' ')
    for i in range(1, n, 2):
        print(a[i], end=' ')
    


Measured memory_bytes: 26176
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(i&1) ans++;
	}
	float x;
	x=n;
	printf("%.10f\n",ans/x);
	return 0;
}

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

typedef pair<int, int>  pi;
typedef long long       ll;
const ll INF=1e18;
const int MAX=2e5+9;
int n, a[MAX];
map<pi, ll> memo;

ll dp(int i, int rest) {
    if (i>n) {
        if (rest) {
            return -INF;
        }

        return 0;
    }

    if (memo.find({i, rest})!=memo.end()) {
        return memo[{i, rest}];
    }

    if (rest>((n-i+1)+1)/2) {
        return memo[{i, rest}]=-INF;
    }

    memo[{i, rest}]=dp(i+1, rest);
    if (rest) {
        memo[{i, rest}]=max(memo[{i, rest}], a[i]+dp(i+2, rest-1));
    }

    return memo[{i, rest}];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for (int i=1; i<=n; ++i) {
        cin >> a[i];
    }

    cout << dp(1, n/2);

    return 0;
}


Measured memory_bytes: 35676
M=[]
n=int(input())
for i in range(n):
	b=list(map(int,input().split()))
	M.append(b)
ans=0
from copy import copy
t=[0]
dis=copy(M[0])
dis[0]=10**12
for i in range(n):
	if dis[i]==-1:
		dis[i]=10**10
for i in range(n-1):
	p=10**10
	for j in range(n):
		if dis[j]<p:
			p=dis[j]
			q=j
	ans+=p
	t.append(q)
	dis[q]=10**12
	for j in range(n):
		if dis[j]>M[j][q] and M[j][q]!=-1 and dis[j]!=10**12:
			dis[j]=M[j][q]
print(ans)







Measured memory_bytes: 6624
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string n;
    cin >> n;
    ll sum = 0;
    rep(i, sz(n)){
        sum += n[i] - '0';
    }
    Yes(sum % 9 == 0);



}



Measured memory_bytes: 3748
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n,m;
  cin>>n>>m;
 int arr[m];
  for (int i=0;i<m;i++)
 cin>>arr[i];
  for (int i=1;i<m;i++) arr[i]+=arr[i-1];
  if(arr[m-1]>n) cout<<"-1";
  else cout<<n-arr[m-1];
  return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <math.h>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
int H,W,X;
int nx,ny,dx,dy; ll K;

const ll MOD=1000000007;
 
bool g[1000][1000];
 
ll md(ll a,ll b,bool c){
 
            ll p=X,q=a,r=a;
            ll P=-1,Q=-1,R=-1;
 
    string s;
    while (b > 0) {
        s.push_back('0' + (b & 1));
        b >>= 1;
    }
    if(s[0]&1){ P=p,Q=q,R=r; } 
    
    for(int i=1; i<s.size(); i++){
      q=((p*q%MOD)+(q*r%MOD))%MOD; p=(p*p)%MOD; r=(r*r)%MOD;
      if(s[i]&1){
        if(P<0) { Q=q; P=p; R=r; }
        else { Q=((p*Q%MOD)+(q*R%MOD))%MOD; P=(p*P)%MOD; R=(r*R)%MOD;}
      } 
    }

    if(c) return Q;
    else return P;
    
}
 
int main(){
 
cin>>H>>W>>K;
 
for(int h=0; h<H; h++){
 for(int w=0; w<W; w++){
  char C; scanf(" %c",&C);
  if(C=='#') { g[w][h]=1; X++;}
  if(w>0&&g[w-1][h]==1&&g[w][h]==1) dx++;
  if(h>0&&g[w][h-1]==1&&g[w][h]==1) dy++;
 }
}
 
for(int h=0; h<H; h++) if(g[0][h]==1&&g[W-1][h]==1) nx++;
for(int w=0; w<W; w++) if(g[w][0]==1&&g[w][H-1]==1) ny++;
 
 if(ny==0&&nx>0){
  ll f2=X-dx,g2=-dx; 
  ll a=md(nx,K-2,0),b=md(nx,K-2,1); 
  a=(a*f2)%MOD; 
  b=(b*g2)%MOD;
  a=(a+b)%MOD;
  if(K>2&&a<0) cout<<a+MOD<<endl;
  if(K>2&&a>=0) cout<<a<<endl;
  if(K==2) cout<<f2<<endl;
  if(K==1||K==0) cout<<1<<endl;
  }
 if(ny>0&&nx==0){
  ll f2=X-dy,g2=-dy;
  ll a=md(ny,K-2,0),b=md(ny,K-2,1);
  a=(a*f2)%MOD; 
  b=(b*g2)%MOD;
  a=(a+b)%MOD;
  if(K>2&&a<0) cout<<a+MOD<<endl;
  if(K>2&&a>=0) cout<<a<<endl;
  if(K==2) cout<<f2<<endl;
  if(K==1||K==0) cout<<1<<endl;
  }
 if(nx>0&&ny>0){
   cout<<1<<endl;
  }
 if(nx==0&&ny==0){
   ll a=md(nx,K-1,0);
   if(K==1||K==0) cout<<1<<endl;
   else  if(a<0) cout<<a+MOD<<endl;
  else if(a>=0) cout<<a<<endl;
  }
  
  //cout<<dy<<endl;

return 0;
 
}

Measured memory_bytes: 1280
n = int(input())

a = list(map(int,input().split()))

a.insert(0,0)
a.append(0)

s = 0

for i in range(n+1):
    s += abs(a[i+1]-a[i])

for i in range(1,n+1):
    ans = s + abs(a[i-1]-a[i+1]) - (abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))
    print(ans)
    

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int A, B, C, D;

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

    cin >> A >> B >> C >> D;

    REP(i, 101) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main()
{
	cin >> n;
	ans = 1;
	sum = 1;

	REP(i, n)
	{
		ll a, b;
		cin >> a >> b;
		k = max((ans - 1) / a + 1, (sum - 1) / b + 1);
		ans = k*a;
		sum = k*b;
	}
	cout << ans + sum << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    N = input(int)
    print(N ** 3)
    return

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

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

    vector<vector<pair<int, ll> > > v(n);
    pair<int, int> p[n];
    ll w[n];
    int ans[n];
    for(int i = 0; i < n - 1; i++){
        cin >> p[i].first >> p[i].second >> w[i];
        p[i].first--;
        p[i].second--;
        v[p[i].first].push_back(make_pair(p[i].second, w[i]));
        v[p[i].second].push_back(make_pair(p[i].first, w[i]));
        ans[i] = -1;
    }
    ans[n - 1] = -1;

    queue<int> q;
    q.push(0);
    ans[0] = 0;
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int i = 0; i < v[now].size(); i++){
            if(ans[v[now][i].first] == -1){
                if(v[now][i].second % 2 == 0){
                    ans[v[now][i].first] = ans[now];
                }else{
                    if(ans[now] == 0){
                        ans[v[now][i].first] = 1;
                    }else{
                        ans[v[now][i].first] = 0;
                    }
                }
                q.push(v[now][i].first);
            }
        }
    }

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

Measured memory_bytes: 12672
n = int(input())
a = list(map(int, input().split()))
nli = list(range(n))[::-1]
bli = [0]*n

for i in nli:
    num = 2
    ball = 0
    while (i+1)*num<=n:
        ball += bli[(i+1)*num-1]
        num += 1
    if ball%2 == a[i]:
        bli[i]=0
    else:
        bli[i]=1

print(bli.count(1))

for i in range(n):
    if bli[i]:
        print(i+1)

Measured memory_bytes: 15012
#include <iostream>
#define MAXN 2000
using namespace std;
int main(){
	int N, X, Y;
	cin >> N >> X >> Y;
	int cnt[MAXN+1] = {0};
	for(int i=1; i<=N; i++)
		for(int j=i+1; j<=N; j++)
			cnt[min(j-i, abs(j-Y) + abs(i-X) + 1)] ++;
	for(int i=1; i<N; i++)
		cout << cnt[i] << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e7 + 1;

int main() {
    cout << fixed << setprecision(10);
    
    string S; cin >> S;
    // 下の桁から考える
    // 筆算的に、上からだと、下の桁が繰り下がりかどうかがわからない
    reverse(S.begin(), S.end());
    // 一個上の桁で支払う可能性があるので、一桁増やす
    S += '0';
    int N = S.size();
    // 下からi桁目まで考えたときの繰り下がり[j]が0か1か
    vector<vector<int>> dp(N+1, vector<int>(2, INF));
    dp[0][0] = 0;
    rep(i, N) rep(j, 2) {
        int x = S[i] - '0';
        x += j;
        rep(a, 10) {
            int ni = i+1, nj = 0;
            int b = a-x;
            // cout << "a " << a << " b " << b << "  x " << x << endl;
            if (b < 0) {
                nj = 1;
                b += 10;
            }
            dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
        }
    }
    cout << dp[N][0] << endl;
    return 0;
}

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

#define line_buf 512

int main(){
    
    char line[line_buf];
    int a,b;

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d %d",&a,&b);
    
    if(a == b){
        printf("Draw");
        return 0;
    }

    if(a != 1 && b != 1){
        if(a < b)printf("Bob");
        else printf("Alice");
        return 0;
    }

    if(a == 1)printf("Alice");
    else printf("Bob");

    return 0;
}

Measured memory_bytes: 128
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B) =  explode(" ",trim(fgets(STDIN)));
//$l = explode(" ",trim(fgets(STDIN)));


$v = intdiv($N,2)+1;
$res=0;

for($i=1;$i<$v;$i++) {
  if ($N-$i != $i) {
    $res++;
  }
}
printf("%d\n",$res);


Measured memory_bytes: 4856
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()

end = "abcdefghijklmnopqrstuvwxyz"[::-1]

if S == end:
  print(-1)
  exit()

lastChar = S[-1]
set_used = set(S)

if len(S)<len(end): #付け加える文字が残っている場合
  for i in range(ord('a'), ord('z')+1):
    if not chr(i) in set_used:
      print(S + chr(i))
      exit()
else: #全文字使っている場合、全探索
  prevord = -1
  for i, c in enumerate(S[::-1]): #iは後ろから何文字目か(0-indexed)
    if ord(c)<prevord: #Si, Si+1が昇順だったら
      #Siを、i-1までで一度も使っていない一番若い文字に変える
      ansS_exceptLast = S[0:-i-1]
      for cc in range(ord(c)+1, ord('z')+1):
        if not chr(cc) in ansS_exceptLast:
          print(ansS_exceptLast+chr(cc))
          exit()
    else:
      prevord = ord(c)



Measured memory_bytes: 4016
//
//  Competitive Programming
//  Don't Copy Be Original - Ehsaan Rahman
//  Copyright © 2020 Ehsaan Rahman. All rights reserved.
//
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<bitset>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<chrono>
#include<list>
#include<climits>
#include<iomanip>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #define PBDS tree<long long int,null_type,less<long long int>, rb_tree_tag,tree_order_statistics_node_update>
// using namespace __gnu_pbds;
#define arrsize 100001
#define dpsize 1001
#define vpp vector<PP>
#define vll vector<ll>
#define vcc vector<char>
#define vbb vector<bool>
#define w(t) while(t--)
#define PP pair<ll,ll>
#define szs(x) x.length()
#define szv(x) x.size()
#define INF 1999999996000000010
#define ll long long int
#define takeINP(arr,n) for(long long int i=0;i<n;i++) cin>>arr[i];
#define f(i,s,e) for(long long int i=s;i<e;i++)
#define cf(i,s,e) for(long long int i=s;i<=e;i++)
#define rf(i,e,s) for(long long int i=e-1;i>=s;i--)
#define mem(arr) memset(arr,0,sizeof(arr));
#define MOD 1000000007
#define pp(a,b) make_pair(a,b)
#define pb push_back
#define print(arr,s,e) f(i,s,e) cout<<arr[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define vll vector<ll>
#define triplet pair<ll,pair<ll,ll> >
#define MITR(a,b) map<a,b>::reverse_iterator 
using namespace std;
using namespace chrono;

///Author - Ehsaan Rahman - Don't Copy Be Original
///---------------Functions---------------------///
ll advceil(ll num,ll den){return (num%den==0?num/den:num/den+1);}
ll lstbt(ll val){ ll msk = val&(val-1); return log2(val^msk);}
ll expo(ll a,ll b){	ll res=1;	while(b>0){		if(b&1) res = (res%MOD*a%MOD)%MOD;		a = (a%MOD*a%MOD);		b/=2;	}	return res;}
ll gcd(ll a,ll b){ return a==0?b:gcd(b%a,a); }

///---------x------------x----------x-----------///

void solve(){
	string s; cin>>s;
	ll ans = 0;
	f(i,0,szs(s)) ans+=(s[i]-'0');
	if(ans%9==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r" ,stdin);
		freopen("output.txt", "w" ,stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    auto start1 = high_resolution_clock::now();
    solve();
    auto stop1 = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop1 - start1);
    #ifndef ONLINE_JUDGE
		cerr << "Time: " << duration.count() / 1000.0 << endl;
	    cout<<duration.count()/1000.0<<endl;
    #endif
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 998244353;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
 
int dp[3030][6010];
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int N, S;
	cin >> N >> S;
	int A[N];
	rep(i,N) cin >> A[i];
	dp[0][0] = 1;
	rep(i,N){
		rep(j,S+1){
			dp[i+1][j] += dp[i][j] * 2;
			dp[i+1][j+A[i]] += dp[i][j];
			dp[i+1][j] %= MOD;
			dp[i+1][j+A[i]] %= MOD;
		}
	}
	cout << dp[N][S] << endl;
 }

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

const int MAX=10000;

int p[MAX];
int rank[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        p[i]=i;
        rank[i]=0;
    }
}

int findset(int x){
    if(p[x]==x){
        return x;
    }
    else{
        return p[x]=findset(p[x]);
    }
}

void unite(int x, int y) {
	x = findset(x);
	y = findset(y);
	if (x == y) return;

	if (rank[x] < rank[y]) {
		p[x] = y;
	}
	else {
		p[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

bool same(int x, int y) {
	return findset(x) == findset(y);
}

main() {
	int n, q;
	cin >> n >> q;
	init(n);
	for (int i = 0;i<q;i++) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a) cout << same(b, c) << endl;
		else unite(b, c);
	}
}


Measured memory_bytes: 3168
#include <stdio.h>

int partition(int*, int, int);

int main(){
  int i,j,n,A[100000],a;

  scanf("%d",&n);

  for(i=1;i<=n;i++) scanf("%d",&A[i]);
  i=1;

  a=partition(A, i, n);
  for(i=1;i<a;i++) printf("%d ",A[i]);
  printf("[%d] ",A[a]);
  for(i=a+1;i<n;i++) printf("%d ",A[i]);
  printf("%d\n",A[n]);

  return 0;
}

int partition(int* A,int p,int r){
  int x,i,j,tmp;
  
  x = A[r];
  i = p-1;
  for (j = p;j<=r-1;j++){
    if (A[j] <= x){
      i = i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
      
    tmp=A[i+1];
      A[i+1]=A[r];
      A[r]=tmp;
 
  return i+1;
}



Measured memory_bytes: 2108
import copy
n=int(input())
V=list(map(int, input().split(" ")))
d1=[0 for i in range(100000)]
for i in V[::2]:
    d1[i-1]+=1
d2=[0 for i in range(100000)]
for i in V[1::2]:
    d2[i-1]+=1

m1=max(d1)
m2=max(d2)
maxind1 = [i for i, x in enumerate(d1) if x == m1]
maxind2 = [i for i, x in enumerate(d2) if x == m2]

#in1=d1.index(max(d1))
#in2=d2.index(max(d2))



if (maxind1[0] == maxind2[0]) and (len(maxind1) == 1) and (len(maxind2) == 1):
    #if m1>m2:
    #d2[maxind2[0]]=0
    tmp=copy.copy(d2)
    tmp[maxind2[0]]=0
    result1=n-max(d1)-max(tmp)

    #else:
    #d1[maxind1[0]]=0
    tmp=copy.copy(d1)
    tmp[maxind1[0]]=0
    result2=n-max(tmp)-max(d2)
    print(int(min(result1,result2)))
else:
#print(d1[:5])
#print(d2[:5])
    tmp1=n/2-max(d1)
    tmp2=n/2-max(d2)
    print(int(tmp1+tmp2))

Measured memory_bytes: 14916
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++) 
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//constexpr ll mod = 1000000007;
//constexpr ll INF = mod * mod;
//constexpr double pi = 3.14159265358979;

int main(){
    bool table[1000010];
    memset(table, false, sizeof(table));
    for(int i=1; i<=1000; ++i)for(int j=1; j<=1000; ++j){
        if(i<=9 && j<=9) table[i*j] = true;
    }
    
    int n;
    scanf("%d", &n);
    puts(table[n] ? "Yes" : "No");
}

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

int main(){
 int m,f,r;
 while(true){
  cin >> m >> f >> r;
  if(m==-1&&f==-1&&r==-1) break;
  if(m== -1 || f==-1) cout << "F"<<endl;
  else if(80<=m+f) cout << "A"<<endl;
  else if(65<=m+f && m+f<80) cout << "B" <<endl;
  else if(50<=m+f && m+f<65) cout << "C" <<endl;
  else if(30<=m+f && m+f<50){
   if(50<=r) cout<<"C"<<endl;
   else cout<<"D"<<endl;
  }
  else if(m+f<30) cout<<"F"<<endl;
 }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int main(){
    int A,B;
    cin>>A>>B;
    cout<<max(A+B,max(A*B,A-B))<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        string[] S = Console.ReadLine().Split('/');
        if (int.Parse(S[1]) <= 4) Console.WriteLine("Heisei");
        else Console.WriteLine("TBD");
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    int x, y; cin >> x >> y;
    if (c * 2 < a + b) {
        if (x > y) {
            cout << c * 2 * y + (x - y) * min(2 * c, a) << endl;
        } else {
            cout << c * 2 * x + (y - x) * min(c * 2, b) << endl;
        }
    } else {
        cout << a * x + b * y << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200200;
int i,j,k,n,m,ch,ans;
struct tree { int ad,ma;} T[N<<2];
struct cc {
	int l,r;
	bool operator < (const cc &n) const {
		if (l==n.l) return r<n.r;
		return l<n.l;
	}
} A[N];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
}
void up(int k) {
	T[k].ma=max(T[k<<1].ma,T[k<<1|1].ma);
}
void down(int k) {
	if (T[k].ad) {
		T[k<<1].ma+=T[k].ad;
		T[k<<1|1].ma+=T[k].ad;
		T[k<<1].ad+=T[k].ad;
		T[k<<1|1].ad+=T[k].ad;
		T[k].ad=0;
	}
}
void T_build(int L,int R,int k) {
	if (L==R) {
		T[k].ma=L;
		return; 
	} 
	int mid=(L+R)>>1;
	T_build(L,mid,k<<1);
	T_build(mid+1,R,k<<1|1);
	up(k);
}
void T_add(int L,int R,int l,int r,int ad,int k) {
	if (L==l && R==r) {
		T[k].ad+=ad;
		T[k].ma+=ad;
		return;
	}
	down(k);
	int mid=(L+R)>>1;
	if (r<=mid) T_add(L,mid,l,r,ad,k<<1);
	else {
		if (l>mid) T_add(mid+1,R,l,r,ad,k<<1|1);
		else T_add(L,mid,l,mid,ad,k<<1),T_add(mid+1,R,mid+1,r,ad,k<<1|1);
	}
	up(k);
}
int T_query(int L,int R,int l,int r,int k) {
	if (L==l && R==r) return T[k].ma;
	down(k);
	int mid=(L+R)>>1;
	if (r<=mid) return T_query(L,mid,l,r,k<<1);
	if (l>mid) return T_query(mid+1,R,l,r,k<<1|1);
	return max(T_query(L,mid,l,mid,k<<1),T_query(mid+1,R,mid+1,r,k<<1|1));
}
int main() {
	R(n);R(m);
	T_build(0,m+1,1);
	ans=max(0,n-m);
	for (i=1;i<=n;i++) R(A[i].l),R(A[i].r);
	sort(A+1,A+n+1);
	for (i=1;i<=n;i++) {
		j=i;
		while (j<n && A[j+1].l==A[i].l) j++;
		for (k=i;k<=j;k++) T_add(0,m+1,A[i].l+1,A[k].r,1,1);
		ans=max(ans,T_query(0,m+1,A[i].l+1,m+1,1)-A[i].l-m-1);
		i=j;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    string s;
    cin >> s;
    if (s.size() < 26) {
        for (char c = 'a'; c <= 'z'; ++c) {
            bool in = 0;
            for (char t : s)
                in |= t == c;
            if (!in) {
                cout << s << c << endl;
                exit(0);
            }   
        }   
    }   
    else {
        for (int i = (int)s.size() - 2; i >= 0; --i) {
            int pos = -1;
            for (int j  = i + 1; j < s.size(); ++j) {
                if (s[j] > s[i]) {
                    if (pos == -1 || s[j] < s[pos]) {
                        pos = j;
                    }           
                }   
            }   
            if (pos != -1) {
                swap(s[i], s[pos]);
                cout << s.substr(0, i + 1) << endl;
                exit(0);
            }   
        }
        cout << -1 << endl;
    }   
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N, M, X, Y, Z;
vector<vector<ll>> node(100001, vector<ll>(0, 0));
bool flag[100001] = {};
ll ans = 0;

void DFS(ll cur) {
	flag[cur] = true;
	for (int i = 0; i < node[cur].size(); i++) {
		if (flag[node[cur][i]])continue;
		DFS(node[cur][i]);
	}
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> X >> Y >> Z;
		node[X].push_back(Y);
		node[Y].push_back(X);
	}
	for (int i = 1; i <= N; i++) {
		if (flag[i])continue;
		DFS(i);
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 8960
n = int(input())
c = [int(i) for i in input().split()]
c.sort(reverse=True)
a = []
b = []
for i in range(n):
    if i % 2 == 0:
        a.append(c[i])
    else:
        b.append(c[i])
print(sum(a) - sum(b))

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
	int N;
	cin >> N;
	double rec = 0;
	if (N % 2 == 0) {
		rec = N / 2;
	}
	else {
		rec = N / 2 + 1;
	}
	cout << setprecision(7) << rec / N << endl;
	return 0;
}

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

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int ret = b/c-(a-1)/c;
	int ret2= b/d-(a-1)/d,ret3= b/(c*d/__gcd(c,d))-(a-1)/(c*d/__gcd(c,d));
	cout << b-a+1-ret-ret2+ret3;
	return 0;
}


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

public class Main {	

	private static void solve(){
		//Implement solution here.
		int S = ni();
		int W = ni();
		System.out.println(S <= W ? "unsafe" : "safe");
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

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

Measured memory_bytes: 25372
#include "bits/stdc++.h"
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[s.size()-1]=='s'){
	s+='e';
	s+='s';
	}
	else
	{
		s+='s';
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll ans=0;
    for(ll i=0;i<s.length();i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    long long n, m, l;
    cin >> n >> m >> l;
    vector<vector<long long> > a(n, vector<long long>(m));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a.at(i).at(j);
        }
    }
    vector<vector<long long> > b(m, vector<long long>(l));
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> b.at(i).at(j);
        }
    }
    vector<vector<long long> > c(n, vector<long long>(l, 0));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            for (int k = 0; k < m; k++)
            {
                c.at(i).at(j) += a.at(i).at(k) * b.at(k).at(j);
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            if (j == l - 1)
            {
                cout << c.at(i).at(j);
                continue;
            }
            cout << c.at(i).at(j) << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3220
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<set>
#include<string>
#include<climits>
using namespace std;

static int N, M, a, b;
static int citys[100];
int main()
{
	while (scanf("%d%d", &N, &M) != EOF)
	{
		fill(citys, citys + N + 1, 0);
		for (int i = 0; i < M; i++)
		{
			scanf("%d%d", &a, &b);
			citys[a]++;
			citys[b]++;
		}
		for (int i = 1; i <= N; i++) printf("%d\n", citys[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  char c[H+1][W+1];
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> c[i][j];
    }
  }

  for(int i=1;i<=2*H;i++){
    for(int j=1;j<=W;j++){
      cout << c[(i+1)/2][j];
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n, q;
    cin >> n >> q;

    vector<tuple<int, int, int>> events;
    for (int i = 0; i < n; ++i) {
        int s, t, x;
        cin >> s >> t >> x;

        events.emplace_back(s - x, 0, x);
        events.emplace_back(t - x, 1, x);
    }

    vi ans(q);
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        events.emplace_back(x, 2, i);
    }

    sort(all(events));
    multiset<int> ms;
    for (auto& evt : events) {
        int x, op, y;
        tie(x, op, y) = evt;

        if (op == 2) {
            // cout << "QUERY " << x << '\n';
            // query
            ans[y] = ms.empty() ? -1 : *begin(ms);
        } else if (op == 0) {
            // cout << "OPEN " << y << '\n';
            // open interval
            ms.insert(y);
        } else if (op == 1) {
            // cout << "CLOSE " << y << '\n';
            // remove interval
            ms.erase(ms.find(y));
        }
    }

    for (int x : ans) {
        cout << x << '\n';
    }

    return 0;
}


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

const int MAX = 1e5 + 111;

int n, m;

int cnt[MAX];

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;    
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        cnt[a]++;
        cnt[b]++;
    }
    for (int i = 0; i < n; ++i) {
        if (cnt[i] % 2 == 1) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main()
{

	int H,W;
	
	while( true ) {
		cin>>H>>W;	
		if( 0==H && 0==W ) { break; }
		for( int i=0; i<H; i++ ) {
			for( int j=0; j<W; j++ ) {
				if( 0==i || H-1==i || 0==j || W-1== j ) {
					cout <<"#"; 
				} else {
					cout <<"."; 
				}
			}
			cout <<endl;  
		}
		cout <<endl; 
	}
	
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main()
{
  int N, M, Q;
  while(1){
    cin >> N >> M >> Q;
    if(N == 0 && M == 0 && Q == 0) break;

    set<int>s; rep(i, N) s.insert(i);
    vector<set<int>>can(M, s);
    s.clear();
    string bS, bB; bS = bB = "";
    //    rep(i, N) bS += "0";
    rep(i, M) bB += "0";
    rep(j, Q){
      string S, B;
      cin >> S >> B;
      set<int>s;
      rep(i, S.size()/* N */) if(S[i] == '1') s.insert(i);
      //      for(auto x: s) cout << x << endl;
      rep(i, B.size()/* M */){
	set<int>tmp;
	if(B[i] != bB[i])set_intersection(can[i].begin(),can[i].end(), s.begin(),s.end(),inserter(tmp,tmp.begin()));
	else set_difference(can[i].begin(),can[i].end(), s.begin(),s.end(), inserter(tmp,tmp.begin()));
	//	for(auto x:tmp) cout << x << endl;
	can[i] = tmp;
      }
      bB = B;
    }
    
    rep(i, can.size()/* M */){
      if(can[i].size() == 1){
	int x = *can[i].begin();
	if(x <= 9) cout << x;
	else cout << (char)('A'+x-10);
      }else{
	cout << "?";
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 4816
use std::i64;
use std::cmp;

// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn main(){
    input! {
        n: usize, w_lim: usize,
        wv: [(usize, usize); n],
    }

    let (w, v): (Vec<_>, Vec<_>)= wv.into_iter().unzip();
    let mut dp = vec![vec![0; w_lim+1]; n+1];
    for i in 1 .. w_lim+1 {
        for j in 1 .. n+1 {
            if i >= w[j-1] {
                dp[j][i] = cmp::max(dp[j-1][i], dp[j-1][i-w[j-1]]+v[j-1]);
            } else {
                dp[j][i] = dp[j-1][i];
            }
        }
    }
    println!("{}", dp[n][w_lim]);
}




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

int N;
ll H[100005];

int solve(int p, int ans) {
    if(p >= N) return ans;
    int c = 0;
    for(int i = p;i<N-1;i++) {
        if(H[i] >= H[i+1]) c++;
        else break;
    }
    return solve(p+c+1, max(ans, c));
}

int main() {
    cin >> N;
    for(int i = 0;i<N;i++) cin >> H[i];
    int ans = solve(0,0);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 114514810;
int n, ma, mb;
vector<int> a, b, c;

int dp[44][444][444];

int rec(int i, int wa, int wb) {
    int &r = dp[i][wa][wb];
    if (r != -1) return r;
    if (i == n) {
        if (wa * mb != wb * ma || wa == 0 || wb == 0) return r = INF;
        return r = 0;
    }
    return r = min(rec(i + 1, wa + a[i], wb + b[i]) + c[i], rec(i + 1, wa, wb));
}

int main() {
    cin >> n >> ma >> mb;
    a.resize(n); b.resize(n); c.resize(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    memset(dp, -1, sizeof(dp));
    int ans = rec(0, 0, 0);
    cout << (ans == INF ? -1 : ans) << endl;

    return 0;
}


Measured memory_bytes: 34176