akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  vector<int> cnt(11,0);
  for(int i=0; i<4; i++){
    int a;
    cin >> a;
    cnt[a]++;
  }
  if(cnt[1] and cnt[4] and cnt[9] and cnt[7]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int t,n,s,f,o;
    for(int i=0;i<100;i++){
        o=0;
        cin>>t;
        cin>>n;
          if(t==0){
            break;
        }
        for(int a=0;a<n;a++){
            cin>>s>>f;
            o=o+(f-s);
        }
        if(o>=t){
            cout<<"OK"<<endl;
        }
        else    {
            cout<<t-o<<endl;
        }
        
    }

    

}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;

class unionFind{

private:
	std::vector<int> par;
	std::vector<int> rank;

public:
	void init(int n){
		par.resize(n);
		rank.resize(n);
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}

	int root(int x){
		if(par[x] == x){
			return x;
		}else{
			par[x] = root(par[x]);
			return par[x];
		}
	}

	void unite(int x, int y){
		x = root(x);
		y = root(y);
		if(x == y)return;
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y])rank[x]++;
		}
	}

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

};

int main(){


	int N, K, L; std::cin >> N >> K >> L;
	unionFind road, rail;
	road.init(N); rail.init(N);
	rep(i, K){
		int p, q; std::cin >> p >> q;
		road.unite(p - 1, q - 1);
	}
	rep(i, L){
		int r, s; std::cin >> r >> s;
		rail.unite(r - 1, s - 1);
	}


	std::vector<std::pair<int, int>> p(N);
	std::map<std::pair<int, int>, int> m;

	rep(i, N){
		p[i] = std::make_pair(road.root(i), rail.root(i));
		m[p[i]]++;
	}

	for(int i = 0; i < N; i++){
		std::cout << m[p[i]] << " ";
	}

	
	return 0;
}

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

struct edge{
    int to,cost;
};

vector<edge> G[100010];
int res[100010];

void dfs(int v, int p,int c) {
    res[v] = c;
    for(auto e : G[v]) {
        if(e.to == p) continue;
        if(e.cost % 2) dfs(e.to, v, 1-c);
        else dfs(e.to, v, c);
    }
}


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

int N;
cin >> N;
rep(i,N-1){
    int u,v,w;
    cin >> u >> v >> w;
    u--;v--;
    G[u].push_back({v,w});
    G[v].push_back({u,w});
}

rep(i,N) res[i] = 0;
dfs(0, -1, 1);
rep(i,N) cout << res[i] << endl;

return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,k,a[9999][9999],b[9999];
int main(){
  cin>>n>>k;
  r(i,k)r(j,n/2)scanf("%d",&a[i][j]);
  while(1){
    r(i,n)b[i+1]=rand()%2;
    r(i,k){
      int cnt=0;
      r(j,n/2)cnt+=b[a[i][j]];
      if(cnt < n/8 || 3*n/8 < cnt)goto L;
    }
    r(i,n)cout<<b[i+1];
    cout<<endl;
    return 0;
    L:;
  }
}

Measured memory_bytes: 6152
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;

int nm;
vector<pair<int,int> > mat;
vector<vector<int> > DP;

int slave(int h,int r){
    if(DP[h][r] >= 0) return DP[h][r];
    int ret = 0;
    for(int i=0;i<nm;i++){
        if(h < mat[i].first && r < mat[i].second){
            ret = max(ret,slave(mat[i].first,mat[i].second)+1);
        }
    }
    return DP[h][r] = ret;
}

int main(){
    while(true){
        mat.clear();
        DP.clear();
        int n,m;
        cin >> n;
        if(n==0) return 0;
        for(int i=0;i<n;i++){
            int h,r;
            cin >> h >> r;
            mat.push_back(make_pair(h,r));
        }
        cin >> m;
        for(int i=0;i<m;i++){
            int h,r;
            cin >> h >> r;
            mat.push_back(make_pair(h,r));
        }
        nm = n+m;
        for(int i=0;i<1002;i++){
            DP.push_back(vector<int>(1002,-1));
        }
        cout << slave(0,0) << endl;

    }
    return 0;
}

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

int main(){
	string a;
  	cin >> a;
  	bool x=true;
  	for (int i=0; i<a.size()-1;i++){
    	for (int j=i+1;j<a.size();j++){
        	if(a.at(i)==a.at(j)) x=false;
        }
    }
  	if (x==true) cout <<"yes"<<endl;
  	else cout <<"no"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std; 
signed
main()
{
double r;
cin>>r;
cout<<setprecision(9)<<2*3.141592653589793238*r;



		
}


Measured memory_bytes: 3792
function main()
	n = parse(Int, readline())
	s = chomp(readline())
	a = Array{Int}(n+1)
    a[1] = 0
	for i in 1:n
		if s[i] == 'I'
			a[i+1] = a[i] + 1
		else
			a[i+1] = a[i] - 1
		end
	end
	println(maximum(a))
end

main()

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

int sum_i(vector<int> a, int i) {
  int sum = 0;
  for(int j=0; j<5; j++) {
    if(j == i) {
      sum += a.at(i);
    }
    else {
      sum += (a.at(j) + 9) / 10 * 10;
    }
  }
  return sum;
}

int main() {
  vector<int> a(5);
  for(int i=0; i<5; i++) {
    cin >> a.at(i);
  }
  int ans = sum_i(a, 0);
  
  for(int i=0; i<5; i++) {
    ans = min(ans, sum_i(a, i));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = r*pi*2;
        System.out.printf("%f %f", area, length);
    }
}


Measured memory_bytes: 28408
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int x;
    cin >> x;
    int a = floor(x / 200);
    int ans = 10 - a;
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>

struct grid {
	int x;
	int y;
};

struct grid area(int num) {
	struct grid grid[200] = { {0,0} };
	int next;
	int position;
	int left = 0;
	int right = 0;
	int top = 0;
	int bottom = 0;
	int count;

	for (count = 1; count < num; count++) {
		scanf("%d", &next);
		scanf("%d", &position);
		switch (position) {
		case 0:grid[count].x = grid[next].x - 1;
			grid[count].y = grid[next].y;
			if (left > grid[count].x)
				left = grid[count].x;
			break;
		case 1:grid[count].x = grid[next].x;
			grid[count].y = grid[next].y - 1;
			if (bottom > grid[count].y)
				bottom = grid[count].y;
			break;
		case 2:grid[count].x = grid[next].x + 1;
			grid[count].y = grid[next].y;
			if (right < grid[count].x)
				right = grid[count].x;
			break;
		case 3:grid[count].x = grid[next].x;
			grid[count].y = grid[next].y + 1;
			if (top < grid[count].y)
				top = grid[count].y;
			break;
		}
	}
	grid[0].x = right - left + 1;
	grid[0].y = top - bottom + 1;
	return  grid[0];
}

int main(void) {
	int num;
	struct grid result;

	while (1) {
		scanf("%d", &num);
		if (num == 0)
			break;
		result = area(num);
		printf("%d %d\n", result.x, result.y);
	}
	return 0;
}


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

int c[100005];

int main(void){
    int n,m,l,r,ans=0;cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        c[l]++;c[r+1]--;
    }
    if(c[1]==m)ans++;
    for(int i=2;i<=n;i++){
        c[i]+=c[i-1];
        if(c[i]==m)ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((a + b) %2 == 0 ? (a+b)/2 : (a+b)/2+1);
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    long long n,A[200000],p,q,r,s=0,i,j,k,ans=1e15;
    cin>>n;
    rep(i,n) cin>>A[i];
    p=A[0],q=0,r=A[1]+A[2],j=0,k=2;
    rep(i,n-3) s+=A[i+3];
    for(i=1;i<n-2;i++){
        q+=A[i],r-=A[i];
        while(abs(p-q)>abs(p-q+2*A[j+1])) p+=A[j+1],q-=A[j+1],j++;
        while(abs(r-s)>abs(r-s+2*A[k+1])) r+=A[k+1],s-=A[k+1],k++;
        ans=min(ans,max({p,q,r,s})-min({p,q,r,s}));
    }
    cout<<ans;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a<b){
    for (int i = 0; i < b; i++){
      cout << a;
    }
    cout << "\n";
  }else{
    for (int i = 0; i < a; i++){
      cout << b;
    }
    cout << "\n";
  }
}

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

public class Main {
 
    public static void main(String[] args) throws Exception {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String[] rc = br.readLine().split(" ");
    	int r = Integer.parseInt(rc[0]);
    	int c = Integer.parseInt(rc[1]);
    	int[][] table = new int[r + 1][c + 1];
    	for (int i = 0; i < r; i++) {
    		table[i] = convertInt(br.readLine().split(" "));
    	}
    	for (int i = 0; i <= r; i++) {
    		for (int j = 0; j <= c; j++) {
    			if (j == c) {
    				continue;
    			}
    			if (i != r) {
    				table[r][j] = table[r][j] + table[i][j];
    			}
    			table[i][c] = table[i][c] + table[i][j];
    		}
    	}
    	for (int[] row : table) {
    		int cnt = 0;
    		for (int n : row) {
    			System.out.print(n);
    			if (cnt != c) {
    				System.out.print(" ");
    			}
    			cnt++;
    		}
    		System.out.println("");
    	}

    }

    private static int[] convertInt(String[] str) {
    	int len = str.length;
    	int[] iArray = new int[len + 1];
    	for (int i = 0; i < len; i++) {
    		iArray[i] = Integer.parseInt(str[i]);
    	}
    	return iArray;
    }
}

Measured memory_bytes: 33240
import numpy as np

X=int(input())
ans=[0,0]

for i in range(-120,120):
  a=i
  for j in range(-120 , 120):
    b=j
    if (a**5 - b**5) ==X:
      ans[0]=a
      ans[1]=b

print("{} {}".format(ans[0],ans[1]))

Measured memory_bytes: 27124
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

char swapcase(char ch) {
    return (char)(ch - 'a' + 'A');
}

int main() {
    fastIO;
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << swapcase(s1[0]);
    cout << swapcase(s2[0]);
    cout << swapcase(s3[0]);
    cout << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 200005            //array size 
#define PI 3.1415926535
using namespace std;

// #define TRACE
// #ifdef TRACE
// #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
//     template <typename Arg1>
//     void __f(const char* name, Arg1&& arg1){
//         cout << name << " : " << arg1 << std::endl;
//         //use cerr if u want to display at the bottom
//     }
//     template <typename Arg1, typename... Args>
//     void __f(const char* names, Arg1&& arg1, Args&&... args){
//         const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
//     }
// #else
// #define trace(...)
// #endif

int frog(vector<int> h,int n)
{
    if(n==1) return h[1];
    if(n==2) return abs(h[2]-h[1]);

    vector<int> dp(n+1);
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);

    for(int i=3;i<=n;i++)
    {
        int ans1=abs(h[i]-h[i-1])+dp[i-1];
        int ans2=abs(h[i]-h[i-2])+dp[i-2];
        dp[i]=min(ans1,ans2);
    }
    return dp[n];
}

int32_t main(){

	ios::sync_with_stdio(false);
    cin.tie(NULL);
   
    //main body
    int n; cin>>n;
    vector<int> h;
    h.pb(0);
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;
        h.pb(x);
    }
    
    cout<<frog(h,n)<<" ";
    
    return 0;
}

Measured memory_bytes: 2804
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e30
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N;
ll ans;
ll a[1000000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}

int main() {
	cin>>N;
	ll fourcount=0;
	ll twocount=0;
	rep(i,0,N){
		cin>>a[i];
		if(a[i]%4==0)fourcount++;
		else if(a[i]%2==0)twocount++;
	}
	if(twocount>=2){
		ans += twocount-1;
	}
	if(fourcount!=0){
		ans+=2*fourcount+1;
	}
	if(twocount==N)cout<<"Yes"<<endl;
	else if(ans>=N)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  dump((10*g+b)%4 == 0 ? "YES" : "NO");
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    if(n % 2 == 0){
        cout << 0.5000000000000 << endl;
    }else{
        cout << fixed << setprecision(15) << (double)((n+1)/2)/n << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = Vec::with_capacity(n);
    for _ in 0..n {
        v.push(get!(usize));
    }
    let mut tv = v.clone();
    tv.sort_by(|x, y| y.cmp(&x));
    //eprintln!("{:?}", tv);
    let biggest = tv[0];
    let second = tv[1];
    for i in 0..n {
        if v[i] != biggest {
            println!("{}", biggest);
        } else {
            println!("{}", second);
        }
    }
}


Measured memory_bytes: 9724
def Base_10_to_n(X, n): #さいとからぱくった
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

def main():
    N, K = map(int, input().split())
    nsin = Base_10_to_n(N, K)
    print(len(nsin))

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  string s;
  cin>>n>>s;
  if(s.size()%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  string u=s.substr(0,s.size()/2);
  if(u==s.substr(s.size()/2,s.size()/2)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int n;
string a;
int main()
{
	cin>>n>>a;

	string s1=a.substr(0,a.size()/2),s2=a.substr(a.size()/2);
	//cout<<s1<<" "<<s2<<endl;
	if(s1==s2) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
x_arr = Array.new
y_arr = Array.new
loop do
  x,y = gets.chomp.split(' ').map{|x| x.to_i}
  break if x == 0 && y == 0
  x_arr << x
  y_arr << y
end

i=0
while i < x_arr.size
  if x_arr[i] < y_arr[i]
      puts "#{x_arr[i]} #{y_arr[i]}"
  else
      puts "#{y_arr[i]} #{x_arr[i]}"
  end
  i=i+1
end

Measured memory_bytes: 6116
#include<stdio.h>
int main(void)
{
	int n,a[100],i,c,m;
	c=0;
	m=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		if(a[i]==1){
			c++;
			if(m<c) m=c;
		}
		if(a[i]==0){
			if(m<c) m=c;
			c=0;
		}
	}
	m++;
	printf("%d\n",m);
	return 0;
}
		


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

using namespace std;

int func(int x){
	int res = 0;
	while(1){
		if(x%2 == 0){
			x /= 2;
			res++;
		}else{
			return res;
		}
	}
}

int main(){
	int N; cin >> N;
	int max_count = 0;
	int ans = 1;
	for(int i = 1; i <= N; ++i){
		int k = func(i);
		if(max_count < k){
			max_count = k;
			ans = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
x, k, d = map(int, input().split())
x = abs(x)
if k <= x // d:
    print(abs(abs(x) - d * k))
else:
    m = x // d
    k -= m
    x -= d * m
    x = abs(x)
    if k % 2 == 1:
        print(abs(abs(x) - d))
    else:
        print(abs(x))

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();
		int T=0;
		int f=0;
		int s2=0;
		int past=0;
		for(int i=0;i!=N;i++) {
			int s = sc.nextInt();
			if(i==0) {//f=0s2=0 T=0 past=0s2=5
				f=s;
				s2=s-past;
				past=s;
			}else {
				s2=s-past;
				past=s;
			}
			
			
			
			if(T<s2) {
				T=s2;
			}
			if(i==N-1) {			
				s2=K-s+f;
				}
			if(T<s2) {
				T=s2;
			}
			
		}
		System.out.println(K-T);
	}

}


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

int main() {
  int64_t a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<int64_t> vec(4);
  vec.at(0)=a*c;
  vec.at(1)=b*c;
  vec.at(2)=a*d;
  vec.at(3)=b*d;
  sort(vec.begin(), vec.end());
  cout<<vec.at(3)<<endl;

}



Measured memory_bytes: 3588
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

string ng = "UNRESTORABLE";

int main(){
	string s, t;
	cin>>s>>t;
	int n = s.size(), m = t.size();
	cerr<<n<<" "<<m<<endl;
	string res = "";
	rep(i, n-m+1){
		bool ok = true;
		rep(j, m){
			if(s[i+j]!='?' && s[i+j]!=t[j]) ok = false;
		}
		if(ok){
			string ss = s.substr(0, i) + t + s.substr(0+i+m);
			rep(j, n) if(ss[j]=='?') ss[j] = 'a';
			if(res=="") res = ss;
			chmin(res, ss);
		}
	}
	if(res=="") res = ng;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  int ans=0;
  for(int i=0; i<s.size(); i++) {
    if(s.at(i) != t.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  string N;
  cin>>N;
  int s;
  s=N.size();
  char a;
  a=N.at(s-1);
  if(a=='3') cout<<"bon"<<endl;
  else if(a=='0' ||a=='1'||a=='6'||a=='8') cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

color = [0] * 9
for a in A:
    if a < 400:
        color[0] += 1
    elif a < 800:
        color[1] += 1
    elif a < 1200:
        color[2] += 1
    elif a < 1600:
        color[3] += 1
    elif a < 2000:
        color[4] += 1
    elif a < 2400:
        color[5] += 1
    elif a < 2800:
        color[6] += 1
    elif a < 3200:
        color[7] += 1
    else:
        color[8] += 1

ans = 0
for i in range(8):
    if color[i] != 0:
        ans += 1

print('1' if ans == 0 else ans, end=' ')
print(ans + color[8])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589
#define endl "\n"
#define int long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define fr(i,a,b) for (int i = (a); i < (b); ++i)

void solve(){
    int n, k;
    cin >> n >> k;
    int h[n], dp[n + k + k];
    fr(i, 0, n) cin >> h[i];
    fr(i, 0, n + k) dp[i] = 1e18;
    dp[0] = 0;
    fr(i, 0, n - 1){
        fr(j, 1, k + 1){
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1];
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int t;
    t = 1;
    //cin >> t;
    while(t--) {solve();}
    return 0;
}


Measured memory_bytes: 1792
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n, k = lr()
p = lr()

p.sort()
print(sum(p[:k]))

Measured memory_bytes: 72832
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var x = long.Parse(inputs[1]);

            var list = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();

            var result = 1;
            var d = new int[n + 1];
            for (var i = 1; i < n + 1; i++)
            {
                d[i] = d[i - 1] + list[i - 1];
                if (d[i] > x)
                {
                    break;
                }
                result++;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28124
#include <iostream>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point{
public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return equals(x, p.x) && equals(y, p.y);
  }

  double abs() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
};

typedef Point Vector;

struct Segment{
  Point p1, p2;
};

typedef Segment Line;

double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

bool isOrthogonal(Vector a, Vector b){
  return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
  return equals(dot(a1 - a2, b1 - b2), 0.0);
}

bool isOrthogonal(Segment s1, Segment s2){
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b){
  return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
  return equals(cross(a1 - a2, b1 - b2), 0.0);
}

bool isParallel(Segment s1, Segment s2){
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

int main(void){
  int q;
  int x0, y0, x1, y1, x2, y2, x3, y3;
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    Point *p0 = new Point(x0, y0);
    Point *p1 = new Point(x1, y1);
    Point *p2 = new Point(x2, y2);
    Point *p3 = new Point(x3, y3);
    if(isOrthogonal(*p0, *p1, *p2, *p3)) cout << 1 << endl;
    else if(isParallel(*p0, *p1, *p2, *p3)) cout << 2 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 1316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define pb push_back
using namespace std;
typedef long long ll;
const int N=2e5+10;
vector<int>E[N];
int c[N],u,v;
int n,sz[N],num[N];
ll ans[N];
ll C(ll x)
{
    return 1ll*x*(x-1)/2+x;
}
void dfs(int u,int fa)
{
    sz[u]=1;
    for(int v:E[u])
    {
        if(v==fa)continue;
        dfs(v,u);
        sz[u]+=sz[v];
    }
}
void dfs2(int u,int fa)
{
    int tmp=num[c[u]];
    for(int v:E[u])
    {
        if(v==fa)continue;
        num[c[u]]=sz[v];
        dfs2(v,u);
        ans[c[u]]-=C(num[c[u]]);
    }
    num[c[u]]=tmp-sz[u];
}
int main()
{
	scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        E[i].clear();
        num[i]=sz[i]=0;
    }
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&c[i]);
    }
    for(int i=1;i<n;++i)
    {
        scanf("%d%d",&u,&v);
        E[u].pb(v),E[v].pb(u);
    }
    dfs(1,-1);
    for(int i=1;i<=n;++i){
 	   num[i]=sz[1];
   	   ans[i]=C(n);
//   	   printf("%d:%lld\n",i,ans[i]);
    }
    dfs2(1,-1);
    for(int i=1;i<=n;++i){
    	ans[i]-=C(num[i]);
    	printf("%lld\n",ans[i]);
	}
    return 0;
}

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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  vector<int> l(4, 0);
  
  for (int i = 0; i < N; i++) {
    string s;
    
    cin >> s;
    
    if (s == "AC") {
      l[0]++;
    }
    
    if (s == "WA") {
      l[1]++;
    }
    
    if (s == "TLE") {
      l[2]++;
    }
    
    if (s == "RE") {
      l[3]++;
    }
  }
  
  cout << "AC x " << l[0] << endl;
  cout << "WA x " << l[1] << endl;
  cout << "TLE x " << l[2] << endl;
  cout << "RE x " << l[3] << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	struct classes {
		int a, b;
		bool operator < (const classes& x) const {
			return b > x.b;
		}
	};
	vector <classes> v;
	int n, a ,b;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> b;
		a = i;
		v.push_back((classes){a, b});
	}
	sort(v.begin(), v.end());
	for (int i = n - 1; i >= 0; i--) cout << v[i].a << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 1780
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		int sum = 0;
		for (int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i,i+1));
		}

		String result = "";
		if (sum % 9 == 0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.println(result);

		sc.close();

	}

}


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

int main() {
    
    string str1,str2;
    
    cin >> str1 >> str2;
    for(int i = 0; i < str1.size(); i++){
        if(str1[i] != str2[str1.size()-i-1]){
        cout << "NO" << endl;
        return 0;
        }
    }
    
    cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int A = 0;
    int B = 0;
    int ans = 0;
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d %d", &A, &B);
    
    /* 入力を受け付ける部分終わり*/
    
    
    /* 何か処理*/
    ans = A*B - A -B +1;
    
    if(1 == 0){
      /* 真の場合の処理 */
      
    }else{
      /* 偽の場合の処理 */
      
    }
    
    for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    }
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
    printf("%d", ans); // %dの部分にansの値が表示される
    
    /* 出力する部分*/
    
    
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define gcd __gcd

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)
#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for(typeof((c).begin())v=(c).begin();v!=(c).end();++v)

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

clock_t start;
void Time(bool timeIt) {
	if (!timeIt) return;
	clock_t end = clock();
	double elapsed_time = ((db)end - (db)start) / (db)CLOCKS_PER_SEC;
	printf("Time elapsed = %0.4lf\n", elapsed_time); 
}

#define LINF (long long)1e18
#define EPS 1e-9
#define INF 1000000007ll
#define SIZE 2010
#define MAX_SUM 4000001

ll a[SIZE];
int main() {
	start = clock();
	int n, sum = 0;
	scanf("%d", &n);
	for (int i = 0 ; i < n ; ++i) {
		scanf("%lld", &a[i]); 
		sum += a[i];
	}

	bitset<MAX_SUM> p;
	p.reset();
	p[0] = 1;

	for (int i = n - 1 ; i >= 0 ; --i) {
		p |= (p << a[i]);
	}
	for (int i = sum / 2 + sum % 2 ; i < MAX_SUM ; ++i) {
		if (p[i]) {
			printf("%d\n", i);
			break;
		}
	}

	Time(false);
	return 0;
}

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

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

  bool ans = false;
  for (ll i = 0; i <= n; i++)
    for (ll j = 0; j <= m; j++) {
      ll val = i * m + j * n - 2 * i * j;
      if (val == k) ans = true;
    }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3484
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>
 
using namespace std;
 
int N;
vector<long long> v;
vector<vector<long long>> dp; 
long long LIM = std::numeric_limits<long long>::min();
 
long long deque(long long i, long long j)
{
  long long c = (N - j - i) % 2 == 0 ? 1 : -1; 
 
  if (i+1 == j) return v[i] * c;
  if (dp[i+1][j] == LIM) dp[i+1][j] = deque(i+1, j); 
  if (dp[i][j-1] == LIM) dp[i][j-1] = deque(i, j-1);
 
  long long a = v[i]*c + dp[i+1][j];
  long long b = v[j-1]*c + dp[i][j-1];
 
  return c < 0 ? min(a, b) : max(a, b); 
}
 
int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
 
  std::cin >> N;
  v.resize(N);
  dp = vector<vector<long long>>(N+1, vector<long long>(N+1, LIM));
 
  for (int i = 0; i < N; ++i)
  {
    long long val;
    cin >> val;
    v[i] = val;
  }
 
  std::cout << deque(0, N); 
 
  return 0;
}

Measured memory_bytes: 70912
n,k = map(int,input().split())
mod = 998244353
dp = [0]*(n+10)
dpsum = [0]*(n+10)
dp[1] = dpsum[1] = 1
L = [0]*k
R = [0]*k
for i in range(k):
    l,r = map(int,input().split())
    L[i],R[i] = l,r
for i in range(2,n+1):
    for j in range(k):
        li = i-R[j]
        ri = i-L[j]
        if ri < 0: continue
        li = max(li,1)
        dp[i] += dpsum[ri]-dpsum[li-1]
        dp[i] %= mod
    dpsum[i] = dpsum[i-1]+dp[i]
    dpsum[i] %= mod
print(dp[n])

Measured memory_bytes: 24652
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] ab = scanner.nextLine().split(" ", 2);

        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        String s = scanner.nextLine();

        if (a + b + 1 != s.length()) {
            System.out.println("No");
            return;
        }

        for (int i = 0; i <= a + b; i++) {
            char ch = s.charAt(i);
            if (i == a) {
                if (ch != '-') {
                    System.out.println("No");
                    return;
                }
            } else {
                if (!('0' <= ch && ch <= '9')) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int R;
    string s;
    cin >> R;
    if (R < 1200) {
        s = "ABC";
    } else if (R >= 1200 && R < 2800) {
        s = "ARC";
    } else {
        s = "AGC";
    }

    cout << s << endl;
}

Measured memory_bytes: 256
import heapq
import math

n, m= map(int, input().split())
lst = list(map(int, input().split()))

heap_lst = []
for i in lst:
    heap_lst.append((-i, i))

heapq.heapify(heap_lst)
for i in range(m):
    a, b = heapq.heappop(heap_lst)
    b = math.floor(b/2)
    heapq.heappush(heap_lst, (-b, b))

res = 0
for tpl in heap_lst:
    res += tpl[1]
print(res)

Measured memory_bytes: 20804
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int a, b; cin >> a >> b;
  	int n, cnt = 0;
  
  	for (n = a; n <= b; n++) {
      	int t[5];
      	int tmp = n;
      	for (int i=0; i<5; i++) {
			t[i] = tmp % 10;
          	tmp /= 10;
        }
      	if (t[0]==t[4] && t[1]==t[3]) cnt++;
    }
  	cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=5e5+50;
const int mod=1e9+7;
using namespace std;
int n,a[nmax],i,mn,lb[nmax],ub[nmax];
string s;
ll sm;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>s;
	n=(int)s.size();
	for(i=n;i>=0;i--)
	{
		if(i==n)
		{
			lb[i]=0,ub[i]=n+5;
		}
		else if(s[i]=='>')
		{
			lb[i]=lb[i+1]+1;
			ub[i]=n+5;
		}
		else
		{
			lb[i]=0;
			ub[i]=ub[i+1]-1;
		}
	}
	a[0]=lb[0];
	for(i=0;i<n;i++)
	{
		if(s[i]=='>')a[i+1]=lb[i+1];
		else a[i+1]=max(lb[i+1],a[i]+1);
	}
	for(i=0;i<=n;i++)sm+=1LL*a[i];
	cout<<sm<<endl;
	return 0;
}


Measured memory_bytes: 6684
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N,Q;
	cin >> N >> Q;
	vi parent(N,0);
	for(int i=0; i<N-1; i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		parent[b]=a;
	}

	vi counter(N,0);
	for(int i=0; i<Q; i++){
		int p,x;
		cin >> p >> x;
		p--;
		counter[p]+=x;
	}

	for(int i=1; i<N; i++){
		counter[i]+=counter[parent[i]];
	}

	for(int i=0; i<N; i++){
		cout << counter[i] << " ";
	}
	cout << endl;

	return 0;
}

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

using namespace std;

const int maxn = 2007;
const int maxm = 4e6 + 7;
const int mod = 1e9 + 7;

int n;
int K;
int f[maxn][maxn];
int fac[maxm];
int inv[maxm];

int Add(int x,int y){return (x += y) >= mod ? x - mod : x;}
int Sub(int x,int y){return (x -= y) <    0 ? x + mod : x;}
int Mul(int x,int y){return 1LL * x * y % mod;}
int Pow(int x,int k,int re = 1){
	for(; k; k >>= 1,x = Mul(x,x))
		if(k & 1)re = Mul(re,x);
	return re;
}
int C(int n,int m){
	if(n < m || m < 0)return 0;
	return Mul(fac[n],Mul(inv[m],inv[n - m]));
}
int main(){
	cin >> n >> K;
	if(K == 1){
		puts("1");
		return 0;
	}
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= n * K; ++i)
		fac[i] = Mul(fac[i - 1],i);
	inv[n * K] = Pow(fac[n * K],mod - 2);
	for(int i = n * K - 1; i; --i)
		inv[i] = Mul(inv[i + 1],i + 1);
	f[1][0] = 1;
	for(int i = 1; i <= n; ++i){
		for(int j = 0; j <= i; ++j){
			//printf("%d %d %d\n",i,j,f[i][j]);
			f[i + 1][j] = Add(f[i + 1][j],f[i][j]);
			if(j + 1 <= n)f[i][j + 1] = Add(f[i][j + 1],Mul(f[i][j],Mul(n - j,C(n * K - j * (K - 1) - i - 1,K - 2))));
		}
	}
	printf("%d\n",f[n][n]);
	return 0;
}


Measured memory_bytes: 47232
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

vector<bool> d(10,0);

bool check( int p ){
	stringstream ss;
	ss << p;
	string s = ss.str();
	bool f = true;
	rep(i,0,s.size()){
		if( d[s[i]-'0'] )
			f = false;
	}
	ret f;
}

int main(){
	int n,k;
	cin >> n >> k;
	
	rep(i,0,k){
		int tmp;
		cin >> tmp;
		d[tmp]=1;
	}
	
	rep(i,n,100001){
		if(check(i)){
			P(i);
			break;
		}
	}

	ret 0;
}

Measured memory_bytes: 384
def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]

    n = len(l)

    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i):
        if l[i] == 0:
            return srs[i-1]
        result = srs[i-1] + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        return result
    
    srs = {-1: 0}
    for i in range(n):
        srs[i] = dp(i)
    
    answer = srs[n-1] + sel[n-1]
    answer %= MOD
    print(answer)


main()


Measured memory_bytes: 26588
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC164
{
    class B
    {
        static void Main(string[] args)
        {
            var ABCD = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];

            var tcount = 0;
            var acount = 0;
            for (int i = 0; 0 < A; i++)
            {
                tcount++;
                A -= D;
            }

            for (int i = 0; 0 < C; i++)
            {
                acount++;
                C -= B;
            }

            if (acount <= tcount) Console.WriteLine("Yes");
            else Console.WriteLine("No");


        }
    }
}


Measured memory_bytes: 28236
/* 
 * Project: NOMURA Programing Contest B - Postdocs
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/30
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

string t;
int k;

void solve() {

    for (int i=0;i<t.length();i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t << "\n";

}

int main() {

    cin >> t;

    solve();

}

Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	map<int, int> mp;
	FOR(i, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	int ret = 0;
	FORR(x, mp) {
		ret += (x.second-x.first >= 0 ? x.second-x.first : x.second);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4736
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        List<Job> jobList = new ArrayList<Job>();
        for(int i = 0; i < n ; i++) {
          jobList.add(new Main().new Job(scanner.nextLong(),scanner.nextLong()));
        }
        jobList = jobList.stream().sorted((j1 , j2) -> (int) (j1.getDeadLine()- j2.getDeadLine())).collect(Collectors.toList());
       
        long timeSum = 0;
        for (int j = 0 ; j < n; j++ ) {
          timeSum += (jobList.get(j).getCost());
          if(timeSum > jobList.get(j).getDeadLine()) {
            System.out.println("No");
            return;
          }
        }
        System.out.println("Yes");
    }
    
   public class Job {
      private long cost;
      private long deadline;
        
      public Job( long cost, long deadline) {
        this.cost = cost;
        this.deadline = deadline;
      }
      public long getCost() {
        return this.cost;
      }
      public long getDeadLine() {
        return this.deadline;
      }
      public String toString() {
        return "cost:" + cost + " deadline:" + deadline; 
      }
    }
}

Measured memory_bytes: 112872
import math

N=input().replace('\n','')
K=int(input().replace('\n',''))

def C(n,k):
    return (math.factorial(n)//math.factorial(n-k))//math.factorial(k)

def calc(n,k):
    if n<k or k<0:
        return 0
    return (9**k)*C(n,k)

s=0
l=len(N)
counter=0
for i,num in enumerate(N):
    if (K-counter)==0:
        s+=1
        break
    if int(num)==0:
        continue
    if i==l-1:
        s+=(int(num))*calc(l-i-1,K-counter-1)
    else:
        s+=(int(num)-1)*calc(l-i-1,K-counter-1)
    s+=calc(l-i-1,K-counter)
    counter+=1

print(s)

Measured memory_bytes: 3064
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")

#include<bits/stdc++.h>

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f(i, a ,b) for(int i = (int)a; i <=(int)(b);i++)
#define endl "\n"
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;

using namespace std;

const int N = 2e5+5,MOD = 1000000007;
const long long int INF = 0xFFFFFFFFFFFFFFFL;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void IOS()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
   	cout.precision(10);
   	cout << fixed;
}
int a[N];	
int32_t main()
{
	IOS();
	int n,x;
	cin >> n;
	priority_queue<int> pq;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		x = a[i];
		pq.push(x);
	}		
	int high = pq.top();
	pq.pop();
	int twohigh = pq.top();
	for(int i = 1; i <= n; i++)
	{
		if(a[i] != high)cout << high;
		else cout << twohigh;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3316