akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    rep(i, n) rep(j, n) cin >> a[i][j];

    vector<int> sum(1 << n);
    rep(i, n){
        rep(s, 1 << i){
            sum[s|(1<<i)] = sum[s];
            rep(j, i){
                if((s >> j) % 2 == 0){
                    continue;
                }
                sum[s|(1<<i)] += a[i][j];
            }
        }
    }

    vector<int> dp(1 << n);
    rep(s, 1 << n){
        for(int t = s; t != 0; t = (t - 1) & s){
            dp[s] = max(dp[s], dp[s^t] + sum[t]);
        }
    }
    cout << dp[(1<<n)-1] << endl;

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h> 
#define ll long long int 
using namespace std; 
  
int main() 
{  
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL);  
    int a,b;
     cin>>a>>b;
     cout<<((a*3)+b)/2<<endl;
    return 0; 
} 


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

int n;
int M[2][105],dp[2][105];
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n)
    {
        for(int i = 0; i < 2; i++)
            for(int j = 0; j < n; j++)
                cin >> M[i][j];

        memset(dp, 0, sizeof dp);
        for(int i = 0; i < 2; i++)
            for(int j = 0; j < n; j++)
                if(i == 0)
                    dp[i][j] = M[i][j] + (j? dp[i][j-1] : 0);
                else
                    dp[i][j] = M[i][j] + max(j? dp[i][j-1] : 0, dp[i-1][j]);
    
        cout << dp[1][n-1] << '\n';
    }
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>

string s;
int c[30], d[10], ans;
void solve()
{
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> s;
    for (int i = 0; i < 4; i++) {
        c[s[i] - 'A']++;
    }
    for (int i = 'A'; i <= 'Z'; i++) {
        if (c[i - 'A'] == 2) {
            ans++;
        }
    }
    if (ans == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
S = input()
ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        c = True
        for k in range(i, j+1):
            if S[k]!='A' and S[k]!='C' and S[k]!='G' and S[k]!='T':
                c = False
        if c and ans < j-i+1:
            ans = j-i+1
print(ans)

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); 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; }

int main()
{
	ll N, K, Q;
	ll A[100005];
	int tmp;

	cin >> N >> K >> Q;
	memset(A, 0, sizeof(A));

	rep(i, Q)
	{
		cin >> tmp;
		A[tmp]++;
	}

	rep(i, N)
	{
		if (K - (Q - A[i + 1]) <= 0)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Solve s= new Solve();
		s.solve();
	}

}
class Solve{
	 Scanner sc = new Scanner(System.in) ;

	 void solve() {
	 int N=sc.nextInt();
	 int L=sc.nextInt();
	 int sum=0;
	 int res=100000000;
	 int[] app=new int[N];
	 
	 for(int i=0;i<N;i++) {
		 app[i]=L+i;
		 sum+=app[i];
	 }
	 for(int i=0;i<N;i++) {
		 int judge=sum-app[i];
		 if(Math.abs(sum-judge)<Math.abs(sum-res)) {
			 res=judge;
		 }
	 }
	 System.out.println(res);
	 }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);

llong oddsolve(llong a)
{
    return (a+1)/2%2;
}
llong solve(llong a)
{
    if(a%2==1 ) return oddsolve(a);
    else return oddsolve(a+1)^(a+1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    llong a,b; cin>>a>>b;
    cout<<(solve(b)^solve(a-1))<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            long n = s.length();
            long ans = n * (n - 1) / 2;
            long ex = 0;
            int[] freq = new int[26];
            for (int i = 0; i < n; i++) {
                int c = s.charAt(i) - 'a';
                freq[c]++;
            }
            for (int i = 0; i < 26; i++) {
                long x = freq[i];

                ex += (x * (x - 1) / 2);
            }
            out.println(1 + ans - ex);
        }

    }
}



Measured memory_bytes: 26868
open Base
open Stdio

let () =
  let arr =
    Caml.Scanf.scanf "%d %d %d %d %d" (fun a b c d e -> [|a; b; c; d; e|])
  in
  let count = ref 0 in
  let ans = ref (-1) in
  while (phys_equal !ans (-1)) do
    if phys_equal arr.(!count) 0
    then ans := !count + 1
    else count := !count + 1
  done;
  !ans |> Int.to_string |> print_endline;


Measured memory_bytes: 5836
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main()
    {
      int line = int.Parse(System.Console.ReadLine()); 
      string[] src = new string[32]{"1","1","1","2","1","2","1","5","2","2","1","5","1","2","1","14","1","5","1","5","2","2","1","15","2","2","5","4","1","4","1","51"};
      Console.WriteLine("{0}", src[line-1]);     
    }
  }
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n;
    cin>>n;
    if(n%10==0){
        cout<<"pon"<<endl;
    }else if(n%10==1){
        cout<<"pon"<<endl;
    }else if(n%10==2){
        cout<<"hon"<<endl;
    }else if(n%10==3){
        cout<<"bon"<<endl;
    }else if(n%10==4){
        cout<<"hon"<<endl;
    }else if(n%10==5){
        cout<<"hon"<<endl;
    }else if(n%10==6){
        cout<<"pon"<<endl;
    }else if(n%10==7){
        cout<<"hon"<<endl;
    }else if(n%10==8){
        cout<<"pon"<<endl;
    }else if(n%10==9){
        cout<<"hon"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
# 1 ? r, c ? 100
# (r + 1) × (c + 1) 

require 'matrix'

r, c = gets.split.map(&:to_i)
ary = []

ARGF.each do |line|
  ary << line.split.map(&:to_i)
end

# puts Matrix[ary]
# column 列ベクトル

table = Matrix[ary]


r.times do |i|
  col = table.column(i).to_a[0]
  print col.join("\s")
  print "\s"
  puts  col.inject(:+)
end

c.times do |i|
  print table.row(0).inject(0){|m, row| m + row[i]}
  print "\s"
end
 
puts table.inject(:+).inject(:+)

Measured memory_bytes: 11120
import java.util.Scanner;

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

		String a = "";
		int sum;

		Scanner sc = new Scanner(System.in);

		while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		}

		sc.close();
	}
}



Measured memory_bytes: 26664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int a,b,c,d,n,m,i,j,k,sum,total;
//long long int ;
//float ;
//double
char s[11],t[11],u[11];
int main(void){
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if (strcmp(u,s)==0)
    {
        printf("%d %d\n",a-1,b);
    } else if (strcmp(u,t)==0)
    {
        printf("%d %d\n",a,b-1);
    }
    
    return 0;
}

Measured memory_bytes: 128
N,A,B=map(int,input().split())
a=list(range(N-A+1,N+1))
for i in range(B-1,0,-1):
    a.append(i)
m,M=B,N-A
for j in range(A-1):
    for i in range(min(M,m+B-2),m-1,-1):
        a.append(i)
    m=min(M,m+B-2)+1
    if len(a)==N:
        break
print(*a if len(a)==N else [-1])

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

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

  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int tmp;
  for (int i = 0; i < N; i++)
  {
    for (int j = N - 1; j > i ; j--)
    {
      if (a.at(j) > a.at(j - 1))
      {
        tmp = a.at(j);
        a.at(j) = a.at(j - 1);
        a.at(j - 1) = tmp;
      }
    }
  }
  //cout << a.at(0) << endl << a.at(1) << endl << a.at(2) << endl;
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0)
    {
      alice += a.at(i);
    }
    else
    {
      bob += a.at(i);
    }
  }
  cout << alice - bob << endl;

}


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

int main() {
    int A , B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
m = min(A)
while m > 0:
    for i in range(0,len(A)):
        if A[i] != m:
            A[i] = A[i]%m
    z = A.count(0)
    A = sorted(A)[z:]
    m = A[0]
    if m == 1:
        break
    else:
        if [_%m for _ in A] == [0]*len(A):
            break
print(m)

Measured memory_bytes: 14252
//投影
#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
const double EPS=1e-6;
#define equals(a,b) (fabs(a)-fabs(b)<EPS)
enum{
	online_Front=-2,
	clock_Wise=-1,
	on_Segment=0,
	counter_clock_Wise=1,
	online_Back=2
};
const int INFTY=1<<29;
struct Point{
	double x,y;
	Point(double x,double y):x(x),y(y){}
	Point(){}
	Point(const Point&a){x=a.x;y=a.y;}
	Point operator+(const Point&a){
		return Point(x+a.x,y+a.y);
	}
	Point operator-(const Point&a){
		return Point(x-a.x,y-a.y);
	}
	Point operator*(double k){
		return Point(k*x,k*y);
	}
	Point operator/(double k){
		return Point(x/k,y/k);
	}
	bool operator==(const Point&a){
		return equals(x,a.x)&&equals(y,a.y);
	} 
};
typedef Point Vector;
Point operator*(double k,const Point&a){
	return Point(k*a.x,k*a.y);
}
double norm(const Point&a){
	return a.x*a.x+a.y*a.y;
}
double abs(const Point&a){
	return sqrt(norm(a));
}
double dot_product(const Point&a,const Point&b){
	return a.x*b.x+a.y*b.y;
}
double cross_product(const Point&a,const Point&b){
	return a.x*b.y-a.y*b.x;
}
bool is_Vertical(Vector&a,Vector&b){
	return equals(dot_product(a,b),0.0);
}
bool is_Parallel(Vector&a,Vector&b){
	return equals(cross_product(a,b),0.0);
}
Point projection_Point(Point&p1,Point&p2,Point&p){
	Vector base=p2-p1;
	double r=dot_product(base,p-p1)/norm(base);
	return p1+base*r;
}
Point reflection_Point(Point&p1,Point&p2,Point&p){
	Point temp=projection_Point(p1,p2,p);
	return 2*temp-p;
}
int Counter_Clockwise(Point&p0,Point&p1,Point&p2){
	Vector a=p1-p0;
	Vector b=p2-p0;
	if(cross_product(a,b)>EPS)return counter_clock_Wise;
	if(cross_product(a,b)<-EPS)return clock_Wise;
	if(dot_product(a,b)<-EPS)return online_Back;
	if(norm(a)<norm(b))return online_Front;
	return on_Segment;
}
void print(int flag){
	switch(flag){
		case -2:cout<<"ONLINE_FRONT"<<endl;break;
		case -1:cout<<"CLOCKWISE"<<endl;break;
		case 0:cout<<"ON_SEGMENT"<<endl;break;
		case 1:cout<<"COUNTER_CLOCKWISE"<<endl;break;
		case 2:cout<<"ONLINE_BACK"<<endl;break;
	}
}
int main(){
	Point p1,p2;
	Point temp;
	scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%lf%lf",&temp.x,&temp.y);
		print(Counter_Clockwise(p1,p2,temp));
	}
	return 0;
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    vi A(N);
    REP(i, 0, N) cin >> A[i];
    
    sort(A.begin(), A.end());
    vector<bool> erats(1000001, false);
    vector<bool> dup(1000001, false);
    vector<int> ans;
    REP(i, 0, N){
        if(i != 0 && A[i-1] == A[i])  dup[A[i]] = true;
        erats[A[i]] = true;
    }


    REP(i, 1, 1000001){
        if(erats[i]){
            if(!dup[i]) ans.push_back(i);
            int j = i * 2;
            while(j <= 1000000){
                erats[j] = false;
                j += i;
            }
        } 
    }
    cout << ans.size() << endl;    
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int K, A, B;

void solve() {
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++) {
        if (!(i % K)) {
            cout << "OK";
            return;
        }
    }
    cout << "NG";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

bool isOK(int index, int key,vector<int> A)
{
	if(A[index] >= key)return true;
	else return false;
}

int binsrch(vector<int> A, int key)
{
	int left=-1;
	int right=A.size();
	while(abs(right - left) > 1)
	{
		int mid=left + (right - left)/2;
		if(isOK(mid,key,A))right=mid;
		else left=mid;
	}
	return left;
}

int main()
{
	int n;cin >> n;
	vector<int> l(n);
	rep(i,n)cin >> l[i];
	sort(l.begin(),l.end());
	int count=0;
	for(int i=0;i<(n-2);i++)
		for(int j=i+1;j<(n-1);j++)
		{
			int find = lower_bound(l.begin(),l.end(),l[j]+l[i])-l.begin();
			//if(find==n)find--;
			count+=find-j-1;
			//cout<<i<<":"<<j<<":"<<find<<endl;
		}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 1;
const int MOD = int(1e9) + 7;

int n;

int dp[2][N];
vector <vector <int> > adj;

void dfs (int u, int pr) {
	long long s1, s2;
	s1 = s2 = 1ll;
	for (int v : adj[u]) {
		if (v == pr)
			continue;
		dfs(v, u);
		s1 *= ((dp[0][v] + dp[1][v]) % MOD);	// for u to be white, v can be any colour
		s1 %= MOD;
		s2 *= (dp[0][v] % MOD);	// v should be white
		s2 %= MOD;
		// TODO take care of modulus & data types!!!
	}
	dp[0][u] = s1;
	dp[1][u] = s2;
	/*
	if (cnt == 0) { // has no child!
		dp[0][u] = 1;	// ways to colour white with no children - only 1 way
		dp[1][u] = 1;	// ways to colour black with no children - only 1 way
	} */
	return;
}
 
int main () {
	cin >> n;
	adj.assign(n, vector <int>());
	for (int i = 0, x, y; i < n - 1; i++) {
		cin >> x >> y;
		x--, y--;	// IMP TODO
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs(0, -1);
	cout << (dp[0][0] + dp[1][0]) % MOD << "\n";
	return 0;
}

Measured memory_bytes: 13440
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
double dp[3001][3001],p[3001];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout<<setprecision(12)<<fixed;
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,n;
    	cin>>n;
    	repi(i,1,n)
    	cin>>p[i];
    	lld ans=0.0;
    	dp[1][1] = p[1]; dp[1][0] = 1.00 - p[1];
    	
    	repi(i,2,n)
    	{
    		repi(j,0,i)
    		{
    			if(j!=0)
    			dp[i][j]=dp[i-1][j-1]*p[i] + dp[i-1][j]*(1.0-p[i]);
    			else
    			dp[i][j]=dp[i-1][j]*(1.0-p[i]);
			}
		}
		repi(j,(n+1)/2,n)
		{
			ans+=dp[n][j];
		}
    	cout<<ans;
    } 
	return 0;
}

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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  if(N % X == 0){
  	cout << (N / X) * T << endl;
  }else{
  	cout << ((N / X) + 1 ) * T << endl; 
  }
  return 0;
}


Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let s: Vec<bool> = i
        .read_line()
        .as_bytes()
        .iter()
        .map(|&x| x == b'W')
        .collect();

    writeln!(o, "{}", solve(&s)).unwrap();
}
fn solve(s: &[bool]) -> usize {
    let mut result = 0;
    let mut blacks = 0;
    for &s in s {
        if s {
            result += blacks;
        } else {
            blacks += 1;
        }
    }
    result
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
n = gets.chomp.to_i
nums = gets.chomp.split(" ").map(&:to_i)

change_count = 0
n.times do |nn|
  s = n - 1 - nn
  nm = nn + 1
  min = nums[nn]
  hoge = -111
  s.times do
    if min > nums[nm]
      hoge = nm
      min = nums[nm]
    end
    nm += 1
  end
  #入れ替え作業
  if hoge > 0
    tmp = nums[nn]
    nums[nn] = nums[hoge]
    nums[hoge] = tmp
    change_count += 1
  end
end

puts nums.join(" ")
puts change_count


Measured memory_bytes: 8884
def gcd(a,b):
    if dp[a][b]==-1:
        if b==0:
            return a
        else:
            ans=gcd(b,a%b)
            dp[a][b]=ans
            return ans
    else:
        return dp[a][b]

K=int(input())

dp=[[-1 for i in range(K+1)] for j in range(K+1)]

total=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            num=gcd(k,gcd(i,j))
            total+=num

print(total)

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

int main(){
   int a,b;
   cin>>a>>b;
   double x,y;
   x=a;
   y=b;
   int d=a/b;
   int r=a%b;
  double f=x/y;
   cout<<d<<" "<<r<<" ";
   printf("%.5lf\n", f);
    return 0;
    }


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

ll n, k;
ll h[MAXN];
int main() {
    cin >> n >> k;
    rep(i, n) {
        cin >> h[i];
    }

    sort(h, h+n);

    ll ans = 0;
    for(ll i=0; i<n-k; ++i) {
        ans += h[i];
    }

    cout << ans << endl;
    
}



Measured memory_bytes: 1792
N,M,C=(int(i) for i in input().split())
lstb=[int(i) for i in input().split()]
L=[[int(i) for i in input().split()] for j in range(N)]
a=0
for i in range(N):
  b=0
  for j in range(M):
    b+=lstb[j]*L[i][j]
    
  if b+C>0:
      a+=1
print(a)

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc086/tasks/arc089_a

#include <iostream>
#include <vector>
using namespace std;

bool is_reachable_at_shortest_path(int t, int x, int y) {
    if (abs(x)+abs(y) != t) {
        return false;
    }
    return true;
}

bool is_travelable(int t, int x, int y) {
    if (t < 0) {
        return false;
    }
    if (t == 0) {
        return x == 0 && y == 0;
    }
    return is_travelable(t-2, x, y) || is_reachable_at_shortest_path(t, x, y) ;
}
int main() {
    int N;
    cin >> N;
    int t{}, x{}, y{};
    int tt{}, xx{}, yy{};
    for (int i=0; i < N; ++i) {
        cin >> tt;
        cin >> xx;
        cin >> yy;
        if (!is_travelable(tt-t, xx-x, yy-y)) {
            cout << "No" << endl;
            return 0;
        }
        t = tt;
        x = xx;
        y = yy;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,n,r,x,y,z[10]={0};
	scanf("%d %d",&x,&y);
	for(i=0;i<y;i++){
		scanf("%d",&n);
			z[n]=1;
	}
	for(i=x;;i++){
		n=i;
		while(n>0){
			r=n%10;
			if(z[r]==1) break;
				n/=10;
		}
		if(n==0){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
    double d;
    cin >> d;
    if( d >= 1.0 && d<=sqrt(2)){
        d = 2.0;
    } else if ( d>=2.0&& d<=3.0*sqrt(2)/2.0){
        d = 3.0;
    }else{
        d *= sqrt(2);
    }
    cout << setprecision(10) << d << endl;
    return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;i++)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;





int main(){
	ll h, w, n;
	cin >> h >> w >> n;


	map<pair<ll,ll>,ll> data;
	rep(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		for (ll j = 0; j < 3; j++) {
			for (ll k = 0; k < 3; k++) {
				if (1 <= a-j && a-j <= h-2 && 1 <= b-k && b-k <= w-2){
					auto p = make_pair(a - j, b - k);
					data[p]++;
				}
			}
		}
	}
	
	ll cnt=0;
	vector<ll> ans(10);
	for (auto x : data) {
		ans[x.second]++;
		cnt++;
	}

	ans[0] = (h - 2)*(w - 2) - cnt;

	rep(i, 0, 10) {
		cout << ans[i] << endl;
	}

	
	return 0;
}



Measured memory_bytes: 56448
n=10**5
def primes(n):
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1, int(n**0.5)//3+1):
        if sieve[i]:
            k = 3*i+1|1
            sieve[k*k//3::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2, 3] + [3*i+1|1 for i in range(1, n//3-correction) if sieve[i]]
ps=primes(n)
likes=[-1]
from bisect import bisect_left,bisect_right
for i in ps:
    p=(i+1)//2
    if p==ps[bisect_left(ps,p)]:
        likes.append(i)
q=int(input())
qs=[map(int,input().split())for i in range(q)]
for a,b in qs:
    a=bisect_left(likes,a)
    b=bisect_right(likes,b)
    print(b-a)

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()
{
    IOS;
    int n,x;
    cin>>n>>x;
    vector<int> a(n+1,0);
    FOR(i,0,n) cin>>a[i];
    int ans = 0;
    FOR(i,1,n+1)
    {
        if(a[i]+a[i-1] > x)
        {
            ans += (a[i]+a[i-1]-x);
            a[i] -= (a[i]+a[i-1]-x);
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#!/usr/local/gnu/bin/bash
read s
sarr=(`echo $s | fold -1`)
len=${#s}
mularr=(1 2 4 8 16 32 64 128 256 512)
num=0
for((i=0;i<len;i++))
do
    tmpnum=$((mularr[i]*sarr[i]))
    for((j=i+1;j<len;j++))
    do
        tmpnum=$((tmpnum*10+mularr[j-1]*sarr[i]))
    done
    num=$((num+tmpnum))
done
echo $num


Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair

#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++)     
void fastIO(void);

void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);







int main()
{
   ll a;
   string s;
   cin>>a>>s;
   if(a<3200) cout<<"red\n";
   else cout<<s<<endl;
   
}























void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}

void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m)+m)%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}


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


Measured memory_bytes: 5264
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll L, R, d, cnt=0;
    cin >> L >> R >> d;
    FOR(i,L,R+1){
        if(i%d==0){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;  
}


Measured memory_bytes: 3592
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
	int count = 0;
	int N;

	cin >> N;

	for(int i=1; i<N+1; i++){
		if((i%2) == 1){
			count++;
		}
	}
	printf("%.10f\n", (double)count / (double)N);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


int h, w;
string field[1100];

Int dp[1100][1100];

int main(){
    cin >> h >> w;
    for(int i = 0;i < h;i++)cin >> field[i];

    dp[h-1][w-1] = 1;
    
    for(int i = h-1;i >= 0;i--){
        for(int j = w-1;j >= 0;j--){
            if(i == h-1 && j == w-1)continue;
            dp[i][j] = 0;
            if(i+1 < h)dp[i][j] += dp[i+1][j];
            if(j+1 < w)dp[i][j] += dp[i][j+1];
            dp[i][j] %= MOD;
            if(field[i][j] == '#')dp[i][j] = 0;
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    int minValue = *min_element(A.begin(), A.end());
    int maxValue = *max_element(A.begin(), A.end());
    vector<pair<int, int>> ans;
    if (maxValue <= 0) {
        for (int i = N - 1; i >= 1; i--) ans.emplace_back(i + 1, i);
    } else if (minValue >= 0) {
        for (int i = 2; i <= N; i++) ans.emplace_back(i - 1, i);
    } else {
        if (abs(minValue) <= abs(maxValue)) {
            int index = distance(A.begin(), max_element(A.begin(), A.end())) + 1;
            for (int i = 1; i <= N; i++) if (i != index && A[i - 1] < 0) ans.emplace_back(index, i);
            for (int i = 2; i <= N; i++) ans.emplace_back(i - 1, i);
        } else {
            int index = distance(A.begin(), min_element(A.begin(), A.end())) + 1;
            for (int i = 1; i <= N; i++) if (i != index && A[i - 1] > 0) ans.emplace_back(index, i);
            for (int i = N - 1; i >= 1; i--) ans.emplace_back(i + 1, i);
        }
    }
    cout << ans.size() << endl;
    for (auto temp : ans) {
        cout << temp.first << " " << temp.second << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e9
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}
 
int main()
{
    int n;
    cin >> n;

    string s;
    cin >> s;

    char a[] = {'A', 'B', 'C', 'D', 'E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','X','Y','Z'};

    for(int i=0;i<s.size();i++)
        cout << char((s[i]-'A'+n)%26 + 'A');

    cout << "\n";
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), sorted_a(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sorted_a[i] = a[i];
  }
  sort(sorted_a.begin(), sorted_a.end());
  for (i = 0; i < a.size(); i++) {
    if (a[i] == sorted_a[n - 1]) {
      cout << sorted_a[n - 2] << endl;
    } else {
      cout << sorted_a[n - 1] << endl;
    }
  }
  return 0;
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

const int MOD = 998244353;

int fpow(int x, int y) {
    int t = 1;
    for (; y > 0; y >>= 1) {
        if (y & 1) t = (1LL * t * x) % MOD;
        x = (1LL * x * x) % MOD;
    }
    return t;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    unordered_map<int, int> f;
    for (auto &v : a) {cin >> v; ++f[v];}
    if (a[0] != 0 || f[0] > 1) {cout << 0 << '\n'; return 0;}
    int mx = 0;
    for (auto p : f) mx = max(mx, p.first);
    if (mx == 0) {cout << "1\n"; return 0;}
    long long ans = 1LL;
    for (int i = mx; i > 0; --i) {
        // if (f[i - 1] == 0) {cout << "0\n"; return 0;}
        (ans *= fpow(f[i - 1], f[i])) %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4772
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;
ll mod = 1e9+7;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n+1, 0);
    for( int i = 1; i <= n; i++ ) cin >> a[i];
    for( int i = 0; i < n; i++ ) a[i+1] += a[i];
    vector<int> f( h*w );
    for( int i = 0; i < n; i++ ) for( int j = a[i]; j < a[i+1]; j++ ) f[j] = i+1;
    vector<vector<int>> g(h, vector<int>(w));
    int i = 0;
    while( true ) {
        for( int j = 0; j < w; j++ ) g[i][j] = f[i*w+j];
        i++;
        if( i == h ) break;
        for( int j = w-1; 0 <= j; j-- ) g[i][j] = f[i*w+(w-j)-1];
        i++;
        if( i == h ) break;
    }
    for( int i = 0; i < h; i++ ) {
        for( int j = 0; j < w; j++ ) {
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
    return 0;  
}

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

int main(){
  int n; cin >> n;
  int ans = 1;
  if(n < 105) ans = 0;
  else{
    if(n >= 135 && n < 165) ans++;
    if(n >= 165 && n < 189) ans += 2;
    if(n >= 189 && n < 195) ans += 3;
    if(n >= 195) ans += 4;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3584
r, c = gets.chop.split(' ').map(&:to_i)

table = Array.new(r+1).map{Array.new(c+1,0)}

r.times do |i|
  row = gets.chop.split(' ').map(&:to_i)
  c.times do |j|
    table[i][j] = row[j]
    table[r][j] += row[j]
    table[i][c] += row[j]
    table[r][c] += row[j]
  end
end


table.each do |row|
  row.each_with_index do |column,cindex|
    print column
    print ' ' if cindex != c
  end
  puts ''
end



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

typedef long long ll;

ll n;
ll res;

int main()
{
    cin >> n;
    for (ll i = 1; i * i <= n; i++) if (n % i == 0) {
        if (i > 1 && n / (i - 1) == n % (i - 1)) res += i - 1;
        ll b = n / i;
        if (i != b && b > 1 && n / (b - 1) == n % (b - 1)) res += b - 1;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>vec(n);
  rep(i,n) cin >> vec[i];
  int ans = 0;
  rep(i,n)rep(j,n)rep(k,n){
    if(i<j && j<k){
      if(vec[i]==vec[j] || vec[j]== vec[k]||vec[k]==vec[i])continue;
      if(vec[i]+vec[j]+vec[k]<=max({vec[i],vec[j],vec[k]})*2)continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int parent[100009];
int sizee[100009];

void make_set(int v) {
    parent[v] = v;
    sizee[v] = 1;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (sizee[a] < sizee[b])
            swap(a, b);
        parent[b] = a;
        sizee[a] += sizee[b];
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, M;
    cin >> N >> M;
    FOR(i, 1, N) {
        make_set(i);
    }
    vector<PII> V;
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        V.pb({x, y});
    }
    vector<ll> A;
    A.pb((ll) N * ((ll) N - 1LL) / 2LL);
    FORD(i, M - 1, 0) {
        int x = V[i].first;
        int y = V[i].second;
        int a = find_set(x);
        int b = find_set(y);
        if (a == b) {
            A.pb(A[SZ(A) - 1]);
        } else {
            ll c = sizee[a] * sizee[b];
            A.pb(A[SZ(A) - 1] - c);
        }
        union_sets(x, y);
    }
    FORD(i, SZ(A) - 2, 0) {
        cout << A[i] << '\n';
    }

}

Measured memory_bytes: 3828
#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;
  vector<char> c(n);
  rep(i,n) cin >> c.at(i);

  int ans = 0;
  int l = 0;
  int r = n-1;
  while (true) {
    while (c.at(l) == 'R' && l < n-1) l++;
    while (c.at(r) == 'W' && r > 0) r--;
    if(l >= r) break;
    ans++;
    l++;
    r--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644