akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int n, k;

  while(cin >> n >> k){
    vector<LLI> h(n); cin >> h;

    sort(RALL(h));

    LLI ans = 0;

    FOR(i,k,n){
      ans += h[i];
    }

    cout << ans << endl;
  }

  return 0;
}


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

int main() {
    int a[3];
    rep(i, 3) cin >> a[i];

    int ans = 0;
    while (!(a[0] == a[1] && a[0] == a[2] && a[1] == a[2])) {
        int maxv = *max_element(a, a + 3);
        int maxCnt = count(a, a + 3, maxv);
        if (maxCnt == 1) {
            rep(i, 3) if (a[i] != maxv) a[i]++;
        } else if (maxCnt == 2) {
            rep(i, 3) if (a[i] != maxv) a[i] += 2;
        }
        ans++;
    }

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


Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}

object Main {
  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ) {
      val a = new Array[Int](10)
      for(i<-1 to n) {
        val m = readInt
        a(m) += 1
      }
      a.foreach { x => if(x==0) println("-") else println("*"*x) }
    }
  }
}

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

int main() {

int M,D;
cin >> M >> D;
//int *num=new int[3];

//int num[]={300000,200000,100000,0};
//string *name=new string[N+1];
int res=0;
for(int i=1;i<=M;i++){
for(int j=1;j<=D;j++){
int d10=j/10;
int d1=j%10;
if(i==d1*d10 && d1>=2 && d10>=2){res++;

//cout << i << "-"<<j << endl;
}

}
}

cout << res << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define ll long long
using namespace std;
int main(void){
string s;
  ll A, V, B, W, T;
  cin>>A>>V>>B>>W>>T;  cout<<((V>W && abs(A-B)<=(V-W)*T)? "YES" : "NO")<<endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
 int N,K;
 std::cin>>N>>K;
 std::vector<int> p(N);

 for(int i=0;i<N;i++){
  std::cin>>p[i];
 }

 std::sort(p.begin(),p.end());
 
 int ans=0;
 for(int i=0;i<K;i++){
  ans+=p[i];
 }

 std::cout<<ans<<std::endl;

 return 0;
}

Measured memory_bytes: 3628
n = input()

c = len(n)
ans = 0 
for i in range(3,c):
    ans += 3**i - ((2**i -2)*3) -3


a = [3,5,7]

for i in range(c-1):
    b = []
    for num in a:
        for s in ["3","5","7"]:
            b.append(int(str(num) + s))
        
    for ke in b:
        a.append(ke)


for num in a:
    if num <= int(n) and len(str(num)) == c:
        if str(num).count("3") >0 and str(num).count("5") >0 and str(num).count("7") >0 :
            
            ans += 1


print(ans)

Measured memory_bytes: 12288
#include<iostream>
using namespace std;
long long arr[100007],brr[100007],crr[100007],anw1[100007],anw2[100007],anw3[100007];
main()
{
    long long n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i]>>brr[i]>>crr[i];
    }
    anw1[1]=max(brr[1],crr[1]);
    anw2[1]=max(arr[1],crr[1]);
    anw3[1]=max(arr[1],brr[1]);
    for(int i=2;i<=n;i++)
    {
        anw1[i]=max(anw2[i-1],anw3[i-1])+arr[i];
        anw2[i]=max(anw1[i-1],anw3[i-1])+brr[i];
        anw3[i]=max(anw1[i-1],anw2[i-1])+crr[i];
    }
    cout<<max(anw1[n],max(anw2[n],anw3[n]));
}


Measured memory_bytes: 4992
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+1;

int main()
{
    ll a,b;
    cin >> a >> b;
    ll ans=-INF;
    ans=max(ans,a+b);
    ans=max(ans,a-b);
    ans=max(ans,a*b);
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b ? "true" : "false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vector<bool> v) {
	string res;
	for(int i = 0; i < (int) v.size(); i++)
		res += char('0' + v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	for(int i = 0; i < S; i++)
		res += char('0' + b[i]);
	return res;
}

template<class T> string to_string(T v) {
    bool f = 1;
    string res;
    for(auto& x : v) {
		if(!f)
			res += ' ';
		f = 0;
		res += to_string(x);
	}
    return res;
}
 
void DBG() {
	cerr << "]" << endl;
}

template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};

vector<set<int>> adj;
vector<int> vis;

int dfs(int u){
	int cnt = 1;
	for(int v: adj[u]){
		if(vis[v] == 0){
			vis[v] = 1;
			cnt += dfs(v);
		}
	}
	return cnt;
}

void solve() {
	int n, m;
	cin >> n >> m;
	adj.resize(n + 1);
	vis.resize(n + 1);
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	priority_queue<int, vector<int>, greater<int>> pq;
	vector<int> am;
	for(int i = 1; i <= n; i++){
		if(vis[i] == 0){
			vis[i] = 1;
			//pq.push(dfs(i));
			am.push_back(dfs(i));
		}
	}
	sort(am.begin(), am.end());
	int a1 = 0;
	for(int i = 0; i < am.size(); i++){
		a1 += max(am[i] - a1, 0);
	}
	/*
	int ans = 0;
	while(!pq.empty() && pq.top() > ans){
		ans += pq.top() - ans;
		pq.pop();
	}*/
	cout << a1 << '\n';
}	
 
int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
 	
	int t = 1;
	//cin >> t;
	for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	}
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, a[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	int zero = 0;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		zero += (a[i] == 0);
	}
	if (zero) return 0*puts("0");
	int ans = 1LL;
	for(int i=0; i<n; i++){
		if (a[i] <= 1000000000000000000/ans) ans *= a[i];
		else return 0*puts("-1");
	}	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4424
#include<iostream>

using namespace std;

string s, t;

int main() {
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if(s[i] == t[i]) {
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#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 ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
ll MOD = 1000000007;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	ll ans = 1;
	REP(i,n)
	{
		ans = (ll)(ans * (i+1)) % MOD;
	}
	cout << ans % MOD << endl;
	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 ll;
typedef unsigned long long ull;

void dfs(vector<int> &v,int a){
    int tmp;
    for(int i=1;i<=4;i++){
        tmp=a;
        tmp *= 10;
        tmp += i;
        if(tmp>11111){
            v.push_back(tmp);
        }else if(tmp!=11111){
            dfs(v, tmp);
        }
    }

}

int main(void) {
    int n;
    cin >> n;
    vector<vector<int> > v(n,vector<int>(10,0)),p(n,vector<int>(11,0));
    int tmp;
    rep(i,n){
        rep(j,10){
            cin >> tmp;
            v[i][j]=tmp;
        }
    }
    rep(i,n){
        rep(j,11){
            cin >> tmp;
            p[i][j]=tmp;
        }
    }
    bool flg;
    int res=INT_MIN,value;
    vector<int> lst;
    vector<int> ncnt(n,0);
    dfs(lst,0);
    // cout << lst.size() << endl;
    // rep(i,lst.size()){
    //     cout << lst[i] << endl;
    // }
    int e;
    int amari;
    rep(i,lst.size()){
        e=lst[i];
        value=0;
        rep(j,5){
            amari = e % 10;
            e = e / 10;
            rep(k,n){
                if(amari==4)ncnt[k] +=v[k][2*j]+v[k][2*j+1];
                else if(amari==3) ncnt[k] += v[k][2*j];
                else if(amari==2) ncnt[k] += v[k][2*j+1];
            }
        }

        rep(j,n){
            // cout << ncnt[j] << endl;
            value += p[j][ncnt[j]];
        }
        if(value>=res)res=value;
        ncnt.clear();
        ncnt= vector<int>(n,0);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

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

    cout << std::lcm(360, X) / X << endl;

    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    Int ans = max({a * c, b * d, a * d, b * c});
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	vint adj[100001];
	scan(N>>M);
	rep(i,M){
		int u,v;
		scan(u>>v);
		u--; v--;
		adj[u].push_back(v);
	}
	int S,T;
	scan(S>>T);
	S--; T--;
	bool dis[100001][3]={};
	dis[S][0]=1;
	vint record;
	record.push_back(S);
	for(int ho=1;record.size();ho++){
		vint before=record;
		record.clear();
		rep(i,before.size()){
			int u=before[i];
			rep(j,adj[u].size()){

				int v=adj[u][j];
				//printf("ho:%d u:%d v:%d dis:%d\n",ho,u+1,v+1,dis[v][ho%3]);
				if(dis[v][ho%3]) continue;
				else if(ho%3==0&&v==T){
					prin(ho/3);
					return 0;
				}
				dis[v][ho%3]=1;
				record.push_back(v);
			}
		}
	}
	prin(-1);
	return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    ll p = 1;
    for (ll i = 1; i <= n; i++) {
        p *= i;
        p %= MODLL;
    }

    cout << p << endl;

    return 0;
}




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

#define int long long

#define inf 1000000007LL
#define mod 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)

signed main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  if(H % h) {
    cout << "Yes" << endl;
    rep(i, H) {
      rep(j, W) {
        int x = -1;
        if(j == 0 && i % h == 0) {
          x = 999999999;
        }
        if(j == 0 && i % h == h - 1) {
          x = -1000000000;
        }
        if(j == W - 1) {
          cout << x << endl;
        }
        else {
          cout << x << " ";
        }
      }
    }
    return 0;
  }
  if(W % w) {
    cout << "Yes" << endl;
    rep(i, H) {
      rep(j, W) {
        int x = -1;
        if(i == 0 && j % w == 0) {
          x = 999999999;
        }
        if(i == 0 && j % w == w - 1) {
          x = -1000000000;
        }
        if(j == W - 1) {
          cout << x << endl;
        }
        else {
          cout << x << " ";
        }
      }
    }
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define db double
#define For(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
void writeln(ll x){write(x);puts("");}
void writep(ll x){write(x);putchar(' ');}

int const N=1e5+3;
int top,n,m,cnt,sta[N];
struct point{
	db x,y;
    point operator - (point A) const{return (point){x-A.x,y-A.y};}
    point operator + (point A) const{return (point){x+A.x,y+A.y};}
    void print(){printf("%.10lf %.10lf\n",x,y);}
}A,B,C,D,c[N],p1[N],p2[N];

point operator *(db x,point A){return (point){x*A.x,x*A.y};}
db CJ(point A,point B){return A.x*B.y-B.x*A.y;}//叉积 
db DJ(point A,point B){return A.x*B.x+A.y*B.y;}//点积 
db dis(point A){return sqrt(A.x*A.x+A.y*A.y);}//向量长度 
bool cmp(point A,point B){return (CJ(A,B)>0 || CJ(A,B)==0 && dis(A)<dis(B));}//按极角排序 
void Convex(point *A,int &n){//求凸包 
	for (int i=1;i<=n;i++)
	  if (A[i].y<A[1].y || A[i].y==A[1].y && A[i].x<A[1].x) swap(A[i],A[1]);
    point base=A[1];top=0;
	for (int i=1;i<=n;i++) A[i]=A[i]-base;
	sort(A+2,A+n+1,cmp);
	sta[++top]=1;
	for (int i=2;i<=n;sta[++top]=i,i++)
	  while (top>1 && CJ(A[i]-A[sta[top-1]],A[sta[top]]-A[sta[top-1]])>=0) top--;
	for (int i=1;i<=top;i++) A[i]=A[sta[i]]+base;
	n=top;A[n+1]=A[1];
}
void Minkowski(point A[],point B[]){//闵可夫斯基（凸包合并） 
	for (int i=1;i<=n;i++) p1[i]=A[i+1]-A[i];
	for (int i=1;i<=m;i++) p2[i]=B[i+1]-B[i];
	int i=1,j=1;c[cnt=1]=A[1]+B[1];
	while (i<=n && j<=m)
	  if (CJ(p1[i],p2[j])>=0) cnt++,c[cnt]=c[cnt-1]+p1[i++];
	  else cnt++,c[cnt]=c[cnt-1]+p2[j++];
	while (i<=n) cnt++,c[cnt]=c[cnt-1]+p1[i++];
	while (j<=m) cnt++,c[cnt]=c[cnt-1]+p2[j++];	
}
int check(point p){//判断一个点是否在凸包内 
	if (CJ(p,c[2])>0 || CJ(c[cnt],p)>0) return 0;
	int pos=lower_bound(c+1,c+cnt+1,p,cmp)-c-1;
	return CJ(c[pos%cnt+1]-c[pos],p-c[pos])>=0; 
}
point CGL_1_A(point A,point B,point C){//点在直线上的投影点
	db d=dis(B-A);
	return (A+(DJ(C-A,B-A)/d/d*(B-A)));
}
point CGL_1_B(point A,point B,point C){//点关于直线的对称点
	point P=CGL_1_A(A,B,C);
	return (C+2*(P-C));
}
int CGL_1_C(point A,point B,point C){//向量的位置关系(向量AC和向量AB) 
    if (CJ(B-A,C-A)>0) return 1;//逆时针 
    if (CJ(B-A,C-A)<0) return 2;//顺时针 
    if (DJ(C-A,B-A)<0) return 3;//方向相反
	if (dis(C-A)>dis(B-A)) return 4;//方向相同 AC>AB
	if (dis(C-A)<=dis(B-A)) return 5;//方向相同 AB>AC
}
int CGL_2_A(point A,point B,point C,point D){
	if (CJ(B-A,D-C)==0) return 2; 
	if (DJ(B-A,D-C)==0) return 1; 
	return 0; 
}

signed main(){
	for (int q=read();q;q--){
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y,&D.x,&D.y);
		writeln(CGL_2_A(A,B,C,D));
	}
	return 0;
}


Measured memory_bytes: 3240
n,l,t = map(int,input().split())
c = []
s = 0
for i in range(n):
  x,w = map(int,input().split())
  if w == 1:
    c.append((x+t)%l)
    s += (x+t)//l
  else:
    c.append((x-t)%l)
    s += (x-t)//l
    
c.sort()
s %= n
c = c[s:] + c[:s]
print(*[i for i in c], sep='\n')

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

int main(void){
    int N,line[1000],i,o,sum,t,max=-1,len;
    char line1[10];
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&line[i]);
    for(i=0;i<N;i++){
        for(o=i+1;o<N;o++){
            sum=line[i]*line[o];
            len=sprintf(line1,"%d",sum);
            for(t=1;line1[t] && line1[t-1]+1==line1[t];t++);
            if(len == t && max < sum)
                max=sum;
        }
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 612
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var N = Console.ReadLine().ToInt32();
        var pnls = new decimal[N+ 1,N + 1];
        
        var pn = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => decimal.Parse(x)).ToList();
        
        pnls[0, 0] = 1;
        /// pnls[0, 1] = 1 - pn[0];
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j <= N; j++)
            {
                if (j - 1 >= 0)
                    pnls[i + 1, j] = pnls[i, j - 1] * pn[i] + pnls[i, j] * (1 - pn[i]);
                else
                    pnls[i + 1, j] = pnls[i, j] * (1 - pn[i]);

            }
        }
        decimal sum = 0;
        for (int i = 0; i <= N; i++)
        {
            if (i > N / 2)
                sum += pnls[N, i];
        }
        Console.WriteLine(sum);
        Console.ReadLine();
    }

    public static void PrintArray<T>(T[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            for (int j = 0; j < array.GetLength(1); j++)
            {
                Console.Write(array[i, j] + " ");
            }
            Console.WriteLine();
        }
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    #endregion
}



Measured memory_bytes: 153432
using System;

namespace AtCoder_Beginner_Contest148_A_Round_One
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B;
            A = int.Parse(Console.ReadLine());
            B = int.Parse(Console.ReadLine());
            if (6-(A+B)==1)
            {
             Console.WriteLine(1);
            }
            else if (6 - (A + B) == 2)
            {
                Console.WriteLine(2);
            }
            else if (6 - (A + B) == 3 )
            {
                Console.WriteLine(3);
            }
            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Linq;

namespace abc135_a
{
    static class Program
    {
        static void Main(string[] args)
        {
            var items = Console.ReadLine().ToLongArray();
            var a = items[0];
            var b = items[1];

            var k = a + b;
            if (k % 2 == 0)
            {
                Console.WriteLine($"{k / 2}");
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }

        static long ToLong(this string s)
        {
            return long.Parse(s);
        }

        static long[] ToLongArray(this string s, char separator = ' ')
        {
            return s.Split(separator).Select(m => m.ToLong()).ToArray();
        }
    }
}


Measured memory_bytes: 13396
#k = int(input())
h, w,k = map(int, input().split())
#al = list(map(int, input().split()))
cl=[list(input()) for i in range(h)]
import itertools
import copy
def countBlack(l):
    res=0
    for li in l:
        res+= li.count('#')
    return res

rows=[0,1]
cols=[0,1]
ans=0
for rowpt in itertools.product(rows,repeat=h):
    for colpt in itertools.product(cols,repeat=w):
        cl_temp=copy.deepcopy(cl)
        # 行を塗る
        for i in range(h):
            if rowpt[i]==1:
                for j in range(w):
                    cl_temp[i][j]='r'
        for j in range(w):
            if colpt[j]==1:
                for i in range(h):
                    cl_temp[i][j]='r'
        if countBlack(cl_temp)==k:
            ans+=1
print(ans)

Measured memory_bytes: 9160
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int N, M;
  std::cin >> N >> M;

  vt<std::pair<ll,ll>> ab(N);
  rep(i,N)
    std::cin >> ab[i].first >> ab[i].second;

  sort(ab.begin(),ab.end());
  ll ans = 0;
  int cnt = 0;
  int i = 0;
  while(cnt < M) {
    if(M-cnt >= ab[i].second) {
    ans += (ab[i].first)*(ab[i].second);
    cnt += ab[i].second;
    }
    else {
      ans += (ab[i].first)*(M-cnt);
      cnt = M;
    }
    ++i;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
N = int(input())
L1 = [x for x in map(int, input().split())]
L2 = [x for x in map(int, input().split())]
P1 = L1[:]
P2 = L2[:]
for i in range(1, N):
  P1[i] += P1[i-1]
for j in range(N-2, -1, -1):
  P2[j] += P2[j+1]
L3 = [0]*N
for k in range(N):
  L3[k] = P1[k]+P2[k]
print(max(L3))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	cout << (a*b)/gcd(a,b) << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    ll n, a, b;
    cin >> n >> a >> b;
    if (a + b - 1 <= n && n <= a * b) {
        ll cnt = a * b - n;
        vector<ll> ans;
        rrep(i, b) {
            ll start = 1LL * i * a;
            if (cnt == 0) rep(j, a) ans.push_back(start + j);
            else if (a-1 <= cnt) ans.push_back(start), cnt -= a-1;
            else {
                cnt = 0;
                rep(j, a-cnt) ans.push_back(start + j);
            }
        }
        map<ll, int> mp;
        rep(i, n) mp[ans[i]] = 0;
        int num = 1;
        for (auto&& p : mp) p.se = num++;
        rep(i, n) ans[i] = mp[ans[i]];
        rep(i, n) cout << ans[i] << (i == n-1 ? '\n' : ' ');
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 25092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
ll w[100000],d[100000];
int n,k;
int check(ll x){
	int i;
	ll cnt=0;
	FOR(i,0,n){
		if(x<w[i]) continue;
		cnt+=((x-w[i])/d[i]+1LL);
		if(cnt>=k) return 1;
	}
	return 0;
}
int main(void)
{
	int i;
	ll left,right,mid;
	scanf("%d%d",&n,&k);
	FOR(i,0,n) scanf("%lld%lld",w+i,d+i);
	left=0,right=1000000000000000000000LL;
	while(right-left>1){
		mid=(right+left)/2;
		if(check(mid)) right=mid;
		else left=mid;
	}
	printf("%lld\n",right);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    int n;
    while(cin >> n, n) {
        vector<ll> v(1000);
        vector<bool> entered(1000, false);
        ll prev = 0;
        for(int i=0; i<n; ++i) {
            int mon, d, h, m, id;
            char f;
            scanf("%d/%d %d:%d %c %d", &mon, &d, &h, &m, &f, &id);
            int time = h * 60 + m;
            if(entered[0]) {
                for(int j=1; j<1000; ++j) {
                    if(entered[j]) {
                        v[j] += time - prev;
                    }
                }
            }
            entered[id] = 'I' == f;
            prev = time;
        }
        cout << *max_element(v.begin(), v.end()) << endl;
    }
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  int flag[5]={5,7,5,7,7};
  while(cin >> n,n){
    string str;
    vector<int> cnt;
    rep(i,n){
      cin >> str;
      int tmp = str.size();
      cnt.push_back(tmp);
    }
    bool finish = false;
    rep(i,n){
      //cout << "#" << endl;
      int stage = 0;
      int sum = cnt[i];
      if(sum > flag[0]) continue;
      else if(sum == flag[0]) {
        stage++;
        sum = 0;
      }
      for(int j=i+1; j<n; j++){
        //cout << stage  << " " << sum << endl;
        sum += cnt[j];
        if(sum > flag[stage]) break;
        else if(sum == flag[stage]){
          stage++;
          sum = 0;
        }
        if(stage == 5) {
          cout << i+1 << endl;
          finish  = true;
          break;
        }
      }
      if(finish == true) break;
    }
  }
  return 0;
}




Measured memory_bytes: 2992
DEBUG = false 

input = $stdin.gets.chomp.split( /\s/ ).map{ |n| n.to_i }
n_val = input[ 0 ]
m_val = input[ 1 ]
q_val = input[ 2 ]
m_list = $stdin.gets.chomp.split( /\s/ ).map{ |n| n.to_i }
q_list = $stdin.gets.chomp.split( /\s/ ).map{ |n| n.to_i }

students = Array.new
n_val.times{ |n|
	students << n
}

batton  = 0
leftnum = n_val
m_list.each{ |p|
	if p % 2 == 0
		nextbatton = (batton + p) % leftnum
	else
		nextbatton = (batton - p) % leftnum
	end

	printf( "delete batton index = %d(th)\n", nextbatton ) if DEBUG
	students.delete_at( nextbatton )
	p students if DEBUG
	leftnum -= 1
	#batton = nextbatton + 1
	batton = nextbatton % leftnum
	printf( "\nnext batton index = %d(th)\n", batton ) if DEBUG
}

q_list.each{ |q|
	if students.include?( q )	
		puts "1"
	else
		puts "0"
	end
}


Measured memory_bytes: 25468
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,k;
	cin>>n;
	int a[n],b[n];
	for(i=0;i<n;i++)
	cin>>a[i]>>b[i];
	for(i=0;i<n-2;i++)
		if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2])
		{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;

ll color[500005]={0};

void BFS(vector<ll> adj[] , int s)
{
    queue<ll> Q;
    color[s] = 1;
    Q.push(s);

    while(!Q.empty())
    {
        ll p = Q.front();
        Q.pop();
        for(int i=0 ; i<adj[p].size() ; i++)
        {
            if(color[adj[p][i]] == 0)
            {
                if(color[p]==1)
                    color[adj[p][i]] = 2;
                else
                    color[adj[p][i]] = 1;
                Q.push(adj[p][i]);
            }
        }
    }
}

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

    int n;
    cin >> n;
    vector<ll>  adj[n+1];
    for(int i=0 ; i<(n-1) ; i++)
    {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    BFS(adj,1);

    ll cc = 0;
   for(int i=1 ; i<=n ; i++)
    {
        if(color[i] == 1)
            cc++;
    }
    if(cc > n/2)
    {
        for(int i=1 ; i<=n ; i++)
        {
            if(color[i] == 1)
                color[i] = 2;
            else
                color[i] = 1;
        }
        cc=0;
        for(int i=1 ; i<=n ; i++)
        {
            if(color[i] == 1)
                cc++;
        }
    }
    ll ans[n+1];
    ll ka = n/3;
    if(cc <= ka)
    {
       vector<ll> t0,t1,t2;
       for(int i=1 ; i<=n ; i++)
       {
           if(i%3==0)
            t0.push_back(i);
           else if(i%3==1)
            t1.push_back(i);
           else
            t2.push_back(i);
       }

       int p1=0,p2=0,p0=0;
       for(int i=1 ; i<=n ; i++)
       {
           if(color[i] == 1)
                ans[i] = t0[p0++];
           else
           {
               if(p1<t1.size())
                 ans[i] = t1[p1++];
               else if(p2 < t2.size())
                ans[i] = t2[p2++];
              else if(p0<t0.size())
                ans[i] = t0[p0++];
           }
       }
       for(int i=1 ; i<=n ;i++)
        cout << ans[i] << " ";
    }
    else
    {
       vector<ll> t0,t1,t2;
       for(int i=1 ; i<=n ; i++)
       {
           if(i%3==0)
            t0.push_back(i);
           else if(i%3==1)
            t1.push_back(i);
           else
            t2.push_back(i);
       }

       int p1=0,p2=0,p0=0;
       for(int i=1 ; i<=n ; i++)
       {
           if(color[i] == 1)
           {
               if(p1<t1.size())
               {
                   ans[i] = t1[p1];
                   p1++;
               }
               else if(p0<t0.size())
                ans[i] = t0[p0++];
           }
           else
           {
               if(p2<t2.size())
               {
                   ans[i] = t2[p2];
                   p2++;
               }
               else if(p0<t0.size())
                ans[i] = t0[p0++];
           }
       }
       for(int i=1 ; i<=n ;i++)
        cout << ans[i] << " ";
    }
    return 0;
}


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

using str = string;
using ll = long long;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    str s;cin>>s;
    
    int ans=s.size();
    
    for(int i=s.size()-2;i>0;i-=2)
    {
        bool c=true;
        ans-=2;
        for(int j=0;j<i/2;j++)if(s[j]!=s[j+i/2])c=false;
        if(c)break;
    }
    
    cout<<ans<<"\n";
    
    return 0;
}



Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
int main()
{
	int N;
	std::string S;
	std::cin >> N >> S;
	int count = 0;
	for (int i = 0; i < N - 2; ++i) {
		if ((S[i] == 'A') && (S[i + 1] == 'B') && (S[i + 2] == 'C')) {
			++count;
		}
	}
	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int k,s;
  cin>>k>>s;
  
  int ans=0;
  for(int x=0;x<=s;x++){
    for(int y=0;y<=s-x;y++){
      int z=s-x-y;
      if(x<=k&&y<=k&&z<=k)ans++;
    }
  }
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()

{

    int a,b,i;
    scanf("%d",&a);
    scanf("%d",&b);
    i=(a*b);
    if(i%2==0){
        printf("Even\n");
    }
    else{
        printf("Odd\n");
    }




    return 0;
}


Measured memory_bytes: 1572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;
	priority_queue<P, V<P>, less<P>> pq;

	rep(i, n) {
		int a;
		cin >> a;
		pq.push(P(a, 1));
	}
	rep(i, m) {
		int b, c;
		cin >> b >> c;
		pq.push(P(c, b));
	}

	int card = 0;
	ll sum = 0;

	while (card < n) {
		P p = pq.top();pq.pop();
		if (card + p.second <= n) {
			sum += (ll)p.first * p.second;
			card += p.second;
		}
		else {
			sum += (ll)p.first * (n - card);
			card = n;
		}
	}

	cout << sum << endl;

}

Measured memory_bytes: 2420
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    let mut lock = stdin.lock();
    let mut lines = lock.lines();
    let n = lines.next().unwrap().unwrap().parse().unwrap();
    let mut a = vec![vec![0; n]; n];

    for line in lines {
        let parsed: Vec<usize> = line
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect();

        let i = parsed[0];
        let adj = parsed[2..].iter();

        for j in adj {
            a[i - 1][j - 1] = 1;
        }
    }

    for line in a {
        println!(
            "{}",
            line.iter()
                .map(ToString::to_string)
                .collect::<Vec<_>>()
                .join(" ")
        );
    }
}



Measured memory_bytes: 5048
#include <iostream>
#include <algorithm>
#include <vector>

using Int = long long int;
using std::vector;

constexpr Int INF = std::numeric_limits<Int>::max() / 3;
constexpr int S = 10000;

struct Block {
    int w, s;
    Int v;
    bool operator<(const Block& b) const {
        return w + s < b.w + b.s;
    }
};

int main() {
    int n;
    std::cin >> n;
    
    vector<Block> blocks(n);
    for(auto& b : blocks) {
        std::cin >> b.w >> b.s >> b.v;
    }
    std::sort(blocks.begin(), blocks.end());

    vector<Int> dp(S * 2 + 1, -INF);
    dp[0] = 0;
    // key is weight

    for(const auto& b : blocks) {
        for(int w = b.s; w >= 0; --w) {
            dp[w + b.w] = std::max(dp[w + b.w], dp[w] + b.v);
        }
    }

    std::cout << *std::max_element(dp.begin(), dp.end()) << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    string G;
    cin >> G;
    cin >> S;
    cin >> G;
    char B = S[0];
    cout << "A" << B << "C\n"; 
}

Measured memory_bytes: 256
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

def read_int_list():
    return list(map(int,input().split(' ')))
import math

A,B,C,D = read_int_map()
if math.ceil(C/B) > math.ceil(A/D):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 61976
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <stdio.h>
#include <vector>
#include <stack>
#include <iomanip>
const int SIZE = 1000005;

using namespace std;
int n,q,b,c;
int a[1000005];
long long int ans,ji;

int main()
{
    cin>>n;
    ans = 0;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++)
    {
        cin>>ji;
        ans += ji;
        a[ji]++;
    }


    cin>>q;
    while(q--)
    {
        cin>>b>>c;
        int j = c-b;
        ans += (j*a[b]);
        a[c] += a[b];
        a[b] = 0;

        cout<<ans<<endl;
    }


    return 0;
}


Measured memory_bytes: 7524
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
MOD = 10 ** 9 + 7
prime_factors = dict()

for i in range(1, n+1):
    j = 2
    while j ** 2 <= i:
        ext = 0
        while i % j == 0:
            ext += 1
            i //= j
        if j in prime_factors:
            prime_factors[j] += ext
        else:
            prime_factors[j] = ext
        j += 1
    if i != 1:
        if i in prime_factors:
            prime_factors[i] += 1
        else:
            prime_factors[i] = 1

ans = 1
for pf in prime_factors:
    ans = (ans * (prime_factors[pf] + 1)) % MOD
print(ans)


Measured memory_bytes: 69148
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class WUFT
  attr_accessor:node,:rank,:weight
  def initialize(n)
    @node=Array.new(n){|i| i}
    @rank=array(n,1,0)
    @weight=array(n,1,0)
  end

  def find(x)
    return x if @node[x]==x
    y=find(@node[x])
    @weight[x]+=@weight[@node[x]]
    @node[x]=y
    return y
  end

  def union(x,y,z)
    rx=find(x)
    ry=find(y)
    if @rank[rx]<@rank[ry]
      @node[rx]=ry
      @weight[rx]=z-@weight[x]+@weight[y]
    else
      @node[ry]=rx
      @weight[ry]=-z-@weight[y]+@weight[x]
      @rank[rx]+=1 if @rank[rx]==@rank[ry]
    end 
  end

  def diff(x,y)
    return @weight[x]-@weight[y]
  end

  def same?(x,y)
    return find(x)==find(y)
  end
end


n,q=get_i
wuft=WUFT.new(n)
q.times do
  que=get_i
  if que[0].zero?
    wuft.union(que[1],que[2],que[3])
  else
    if wuft.same?(que[1],que[2])
      puts wuft.diff(que[1],que[2])
    else
      puts "?"
    end
  end
end


Measured memory_bytes: 9368
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,W;
int vx[]={1,0,-1,0};
int vy[]={0,1,0,-1};
using namespace std;
int dp[101][10001]={};
//dp[i][j] i???????????§??§j?????????????¶???????????????§??????
int w[101]={},v[101]={};
void solve(){
  cin >> N >> W ;
  FOR(i,1,N+1){
    cin >>v[i]>>w[i];
  }
  REP(i,N+1){
    REP(j,W+1){
      if(i<=0 || j<=0) dp[i][j]=0;
      else if (j-w[i]>=0)dp[i][j] = max (v[i]+ dp[i-1][j-w[i]],dp[i-1][j]);
      else dp[i][j]= dp[i-1][j];
    }
  }

  cout << dp[N][W]<<endl;



}


int main(){
solve();
}

Measured memory_bytes: 5108
input = $stdin.readlines
input.map!{|a| a.chomp("\n").to_i}
hasu= input.map{|a| a%10}
hasu.sort!
hasu.delete(0)
if hasu !=[] then
hasu.delete_at(0)
kai = hasu.map{|a| 10 - a }
print input.inject(:+) + kai.inject(:+)
else
print input.inject(:+)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<vector<int>> edge;
vector<int> ans;
int dfs(int now) {
    if(ans[now] != -1) {
        return ans[now];
    } else {
        int tmp = 0;
        for(auto next : edge[now]) {
            tmp = max(tmp, dfs(next));
        }
        ans[now] = tmp + 1;
        return tmp + 1;
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    edge.resize(n);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
    }
    ans.resize(n, -1);
    for(int i = 0; i < n; i++) {
        ans[i] = dfs(i);
    }
    cout << (*max_element(all(ans))) - 1 << endl;
}

Measured memory_bytes: 10932