akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
using namespace std;
bool isPrime(int x) {
    if(x <= 1) return false;
    for(int i=2;i<=sqrt(x);i++) {
        if(x%i==0) return false;
    }
    return true;

}

int main() {
    int n; cin >> n;
    int ans = 0;
    while(n--) {
        int x; cin >> x;
        if(isPrime(x)) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3084
#include<iostream>
using namespace std;
int main(){
  int n,a,b,x,y;
  cin>>n>>a>>b;
  if(a>=b and n>a+b){
    x=b;
    y=0;
  }
  else if(a<b and n>a+b){
    x=a;
    y=0;
  }
  else if(n<=a+b and a>=b){
    y=a+b-n;
    x=b;
  }
  else if(n<=a+b and a<b){
    y=a+b-n;
    x=a;
  }
  cout<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
 
namespace ALDS1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int N = int.Parse(input);
            int[] list = new int[N];
            input = Console.ReadLine();
            string[] num = input.Split(' ');
            for (int i = 0; i < N; i++)
            {
                list[i] = int.Parse(num[i]);
            }
 
            selectionSort(list, N);
 
        }
 
        public static void selectionSort(int[] arr, int N)
        {
            int tmp, minj;
            int count = 0;
             
            for (int i = 0; i < N; i++)
                {
                    minj = i;
                    for (int j = i; j < N; j++)
                    {
                        if (arr[j] < arr[minj])
                        {
                            minj = j;
                        }
                    }
                    if (i != minj)
                    {
                        tmp = arr[i];
                        arr[i] = arr[minj];
                        arr[minj] = tmp;
                        count++;
                    }
                }
 
            string output = ArrayJoin(arr);
            Console.WriteLine(output);
            Console.WriteLine(count);
 
        }
 
        private static string ArrayJoin(int[] arr)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < arr.Length; i++)
            {
                if (sb.Length > 0)
                {
                    sb.Append(" ");
                }
                sb.Append(arr[i]);
            }
            return sb.ToString();
        }
    }
}

Measured memory_bytes: 9124
n, m = map(int, input().split())
cnt = [[] for _ in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    cnt[p-1].append((y, i))
ans = [None]*m
for p, li in enumerate(cnt):
    if not li:
        continue
    li.sort()
    for j, (y, i) in enumerate(li):
        ans[i] = '{:06d}{:06d}'.format(p+1, j+1)
print('\n'.join(ans))


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

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

int n;
vector<int>V(105);
signed main() {
	cin >> n;
	rep(i, n)cin >> V[i];
	vector<int>ans;
	rep(i, n) {
		for (int j = n - i - 1; j >= 0; j--) {
			if (V[j] == j + 1) {
				ans.push_back(V[j]);
				V.erase(V.begin() + j);
				goto ok;
			}
		}
		cout << -1 << endl;
		return 0;
	ok:;
	}
	reverse(all(ans));
	for (int a : ans)cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    bool a=true,b=false,c=false;
    string str;
    while(cin>>str){
        if(str=="A,B"||str=="B,A"){
            swap(a,b);
        }
        else if(str=="B,C" || str=="C,B"){
            swap(b,c);
        }
        else if(str=="A,C" || str=="C,A"){
            swap(a,c);
        }
    }
    if(a){
        cout<<"A"<<endl;
    }
    else if(b){
        cout<<"B"<<endl;
    }
    else{
        cout<<"C"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3192
main(o,a,b,c){for(;~scanf("%d%d%d"+o*4,&a,&b,&c);)o=o?0:!puts(a*a-b*b-c*c==0|b*b-a*a-c*c==0|c*c-b*b-a*a==0?"YES":"NO");}

Measured memory_bytes: 0
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
a,b = iim()
import fractions
print(a*b//fractions.gcd(a,b))


Measured memory_bytes: 5076
#include<stdio.h>

int main(void)
{
    int n;
    char s[100], t[100];

    scanf("%d", &n);
    scanf("%s %s", &s, &t);

    for(int i=0;i<n;i++){
        printf("%c%c", s[i], t[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n,m = map(int,input().split())
H = [[0 for _ in range(n)] for _ in range(n) ]

for _ in range(m):
    a, b = map(int,input().split())
    H[a-1][b-1] = 1
    H[b-1][a-1] = 1
    
l = [0 for _ in range(n)]
ans = 0

def dfs(node,visited):
    global ans
    if visited.count(0) == 0:
        ans += 1 
        return 0
    else:
        visited[node] = 1
        for node_,edge_ in enumerate(H[node]):
            if edge_ == 1 and visited[node_] != 1:
                visited[node_] = 1
                visited[node] = 1
                dfs(node_,visited)
                visited[node_] = 0

dfs(0,l)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
int C1,C2;
int D1,D2;
char S[1010][1010];
int d[1010][1010];

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

struct Node{
	P p;
	int cost;
	Node(int cost2,P p2){
		cost=cost2;
		p=p2;
	}
	bool operator>(const Node &a) const {
		return (cost>a.cost);
	}
};


void Dijkstra(int sx,int sy){
	priority_queue<Node,vector<Node>,greater<Node>> Q;
	REP(i,N)REP(j,M){
		d[i][j]=INF;
	}
	d[sx][sy]=0;
	Q.push(Node(0,P(sx,sy)));
	while(Q.size()){
		Node p=Q.top();Q.pop();
		int vx=p.p.first,vy=p.p.second;
		if(d[vx][vy]<p.cost)continue;
		REP(i,4){
			int nx=vx+dx[i],ny=vy+dy[i];
			if(nx<0||ny<0||nx>=N||ny>=M||S[nx][ny]=='#')continue;
			if(d[nx][ny]>d[vx][vy]){
				d[nx][ny]=d[vx][vy];
				Q.push(Node(d[nx][ny],P(nx,ny)));
			}
		}
		for(int dx=-2;dx<=2;dx++){
			for(int dy=-2;dy<=2;dy++){
				int nx=vx+dx,ny=vy+dy;
				if(nx<0||ny<0||nx>=N||ny>=M||S[nx][ny]=='#')continue;
				if(d[nx][ny]>d[vx][vy]+1){
					d[nx][ny]=d[vx][vy]+1;
					Q.push(Node(d[nx][ny],P(nx,ny)));
				}
			}
		}
	}
}

signed main(){
	cin>>N>>M;
	cin>>C1>>C2;C1--,C2--;
	cin>>D1>>D2;D1--,D2--;
	REP(i,N){
		cin>>S[i];
	}
	Dijkstra(C1,C2);
	if(d[D1][D2]==INF){
		cout<<-1<<endl;
	}
	else{
		cout<<d[D1][D2]<<endl;
	}
	return 0;
}


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

int main(){
	int n;
	float x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		float s1 = (y2 - y1) / (x2 - x1);
		float s2 = (y4 - y3) / (x4 - x3);
		if(s1 == s2){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main() {
	fast();
 
    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    ll n, r;
    cin >> n >> r;
    if(n>=10){
        out(r);
    }
    else{
        out(r+((100)*(10-n)));
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int MAX = 1e5+10;
const int MAX1 = 1e5+10;
const int INF = 1e9+10;


int x[10][10];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string r;
    cin >> r;
    int a[5];
    for(int i = 0;i < 4;i++){
        a[i] = r[i] - '0';
    }
    int x1 = a[0];
    for(int i = 1;i < 4;i++){
        x[0][i] = a[i];
    }
    for(int i = 1;i < 4;i++){
        x[1][i] = -a[i];
    }
    int t = x1;
    for(int m = 0;m < 2;m++){
        for(int k = 0;k < 2;k++){
            for(int i = 0;i < 2;i++){
                t += x[m][1];
                t += x[k][2];
                t += x[i][3];
                if(t == 7){
                    cout << a[0];
                    if(m){
                        cout << '-' << a[1];
                    }
                    else{
                        cout << '+' << a[1];
                    }
                    if(k){
                        cout << '-' << a[2];
                    }
                    else{
                        cout << '+' << a[2];
                    }
                    if(i){
                        cout << '-' << a[3];
                    }
                    else{
                        cout << '+' << a[3];
                    }
                    cout << "=7";
                    return 0;
                }
                t = x1;
            }
        }

    }


}


/*
3 4
1 2
2 3
4 1
2 1
3
1 2
2 3
1 2

*/


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

long long mod = 1000000007;

int main(){
	int n,k,num,flag;
	flag=0;
	vector<long long>t,a;
	long long ans=1;
	long long tmp;
	long long max=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> tmp;
		t.push_back(tmp);
	}
	for(int i=0;i<n;i++){
		cin >> tmp;
		a.push_back(tmp);
	}
	reverse(a.begin(),a.end());
	max= t[t.size()-1];
	if(a[a.size()-1]!=max){
		flag = 1;
	}
	k=0;
	while(1){
		if(t[k]==max){
			num = k;
			break;
		}
		k+=1;
	}
	if(a[n-num-1]!=max)flag=1;
	long long h1=0;
	for(int i=0;i<num;i++){
		if(h1<t[i]){
			h1 =t[i];
		}else{
			ans= ans*h1%mod;
		}
	}
	h1=0;
	for(int i=0;i<n-num-1;i++){
		if(h1<a[i]){
			h1 =a[i];
		}else{
			ans= ans*h1%mod;
		}
	}
	if(flag==1)cout << 0 <<endl;
	else cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 2676
#include<stdbool.h>

bool alp[26];
main(c){
        while((c=getchar())!='\n') alp[c-'a'] = true;
        for(int i=0; i<26; i++) if(!alp[i]) {
                putchar(i+'a');
                return 0;
        }
        puts("None");
        return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    for _ in 1..n {
        let a = sc.cin::<usize>() - 1;
        let b = sc.cin::<usize>() - 1;
        g[a].push(b);
        g[b].push(a);
    }
    let mut cs: Vec<usize> = (0..n).map(|_| sc.cin()).collect();
    cs.sort();
    let mut memo = vec![None; n];
    let mut s = vec![0];
    while let Some(u) = s.pop() {
        if ! memo[u].is_none() { continue }
        memo[u] = cs.pop();
        // trace!(u, memo[u]);
        for &v in g[u].iter() {
            if ! memo[v].is_none() { continue }
            s.push(v);
        }
    }
    let nodes = memo.iter().map(|a| a.unwrap()).collect::<Vec<usize>>();
    let mut ans = 0;
    for u in 0..n {
        for &v in g[u].iter() {
            if u < v {
                ans += min!(nodes[u], nodes[v]);
            }
        }
    }
    put!(ans);
    put!(..nodes);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

using namespace std;
int main()
{
    int N;
    cin >> N;
    
    vector<int> A;
    int num;
    for(int i=0; i<N; i++){
        cin >> num;
        A.push_back(num);
    }

    std::sort(A.begin(), A.end() );

    int min_cost;
    
    int cost, target_num;
    for(int i = A.front(); i <= A.back(); i++){
        cost = 0;
        target_num = i;
    
        for(vector<int>::iterator it = A.begin(); it != A.end(); it++){
            cost += (*it - target_num) * (*it - target_num);
        }
        if ( i == A.front() || min_cost > cost){
            min_cost = cost;
        }
    }
    cout << min_cost << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    long long num,i,j,sum,a[10002],temp,key;
    while (scanf("%lld",&num)!=EOF&&num!=0) {
        for (i=0; i<num; i++) {
            scanf("%lld",&key);
            if (i==0) {
                a[i]=key;
            } else {
                j=i-1;
                while (key<a[j]&&j>=0) {
                    a[j+1]=a[j];
                    j--;
                }
                a[j+1]=key;
            }
        }
        sum=0;
        for (i=0; i<num-1; i++) {
            sum+=a[i]*(num-1-i);
        }
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 676
#include <cstdio> 
#include <ctime> 
#include <cmath>   
#include <cstring>
#include <cstdlib>          
#include <iostream>                                      
#include <map>                
#include <queue>                
#include <stack>                 
#include <vector>             
#include <string>  
#include <algorithm>  
#define e 2.718281828459045     
#define pi 3.141592653589793239 
using namespace std;
typedef long long ll;            //>10^18
typedef long double ld;          //3.3621e-4932 ~ 1.18937e4932
typedef unsigned long long ull;  //>10^20
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
const int INF = 0x3f3f3f3f;      
const int INFS = 0xc0c0c0c0;     
const double eps = 1e-8;     
ll prime[MAXN];
bool vis[MAXN];
int cnt = 0;
int isPrime(int num){
    if(num == 2 || num == 3)
        return 1;
    if(num % 6 != 1 && num % 6 != 5 || num == 1)	//不在6的倍数两侧的一定不是质数
        return 0;
    int tmp = sqrt(num);
    for(int i = 5; i <= tmp; i += 6 )
        if(num % i == 0 || num % (i + 2) == 0)
            return 0;
    return 1;
}
void eulerSieve(int n){
	for(int i = 2;i <= n; i++){
		if(!vis[i]){
            prime[cnt++] = i;
            vis[i] = true;
        }
		for(int j = 0; j < cnt; j++){
			if(i * prime[j] > n) break;//判断是否越界
			vis[i * prime[j]] = true;//筛数
			if(i % prime[j] == 0) break;//核心判断
		}
	}
    //for(int i = 0; i < cnt; i++) cout << prime[i] << " ";
}    
int main(int argc, char *argv[]){
	int n; cin >> n;
	int cnt = 0;
	for(int i = 1; i < n; i++){
		for(int j = 1; j < n; j++){
			if(i * j >= n) break;
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main(void){
  const int MOD = 1e9+7;
  int H, W;
  cin >> H >> W;
  char a[H][W];
  int d[H][W];
  // d[i][j]: (i, j)への行き方の場合の数
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) {cin >> a[i][j]; d[i][j] = 0;}
  
  queue<pair<int, int> > que;
  d[0][0] = 1;
  que.push(make_pair(0, 0));
  while(que.size()){
    auto q = que.front(); que.pop();
    int y = q.first;
    int x = q.second;
    if(x+1 < W && a[y][x+1] == '.') {
      if(d[y][x+1] == 0) que.push(make_pair(y, x+1));
      d[y][x+1] += d[y][x];
      d[y][x+1] %= MOD;
    }
    if(y+1 < H && a[y+1][x] == '.') {
      if(d[y+1][x] == 0) que.push(make_pair(y+1, x));
      d[y+1][x] += d[y][x];
      d[y+1][x] %= MOD;
    }
  }
  /*
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      cout << d[i][j] << " ";
    }
    cout << endl;
  }
*/
  cout << d[H-1][W-1] << endl;
  return 0;
  
}

Measured memory_bytes: 5120
from collections import Counter
n=int(input())
a=sorted([int(i) for i in input().split()])
cnt=Counter(a)
key=sorted(list(cnt.keys()))[::-1]
one=two=0
for i in key:
    if cnt[i]>=4 and one==0:
        one=two=i
        break
    elif cnt[i]>=2:
        if one==0:
            one=i
        else:
            two=i
            break
print(one*two)

Measured memory_bytes: 70936
#include<iostream>

using namespace std;

int main(){

  int data[10][10];
  string in;

  while(cin >> in){

    for(int i = 0; i < 10; i++){
      data[0][i] = in[i] - 48;
      //cout << in[i] << " " <<data[0][i]<<" ";
    }
    // cout << endl;
    

    for(int i = 1; i < 10; i++){
      for(int j = 0; j < 10-i; j++){
	if(data[i-1][j] + data[i-1][j+1] >= 10){
	  data[i][j] = (data[i-1][j] + data[i-1][j+1]) % 10;
	}else{
	  data[i][j] = data[i-1][j] + data[i-1][j+1];
	}
      }
    }

    cout << data[9][0]<< endl;
  }

  return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
	int a;

	cin >> a;

	for (int i = 9; i > 0; i--) {
		if ((i == 1) && (a != 1)) {
			cout << "No" << endl;
			break;
		}

		if (a % i != 0) {
			continue;
		}
		else if(a / i < 10){
			cout << "Yes" << endl;
			break;
		}
		else {
			cout << "No" << endl;
			break;
		}
	}

	
	return 0;
}

Measured memory_bytes: 256
s = sorted(list(input()))
t = sorted(list(input()))
t.reverse()

len_s = len(s)
len_t = len(t)

ans = 'None'

for s_, t_ in zip( s,t ):
  if ord(s_) < ord(t_):
    ans = 'Yes'
    break
  elif ord(s_) > ord(t_):
    ans = 'No'
    break

if ans == 'None':
  if len_s < len_t:
    ans = 'Yes'
  else:
    ans = 'No'
    
print(ans)

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

int R,N;

void solve(){
    vector<int> lx(N),rx(N),y(N);
    for(int i=0;i<N;i++) cin>>lx[i]>>rx[i]>>y[i];

    vector<int> high(2*R,0);
    for(int i=0;i<N;i++){
        for(int j=lx[i];j<rx[i];j++){
            if(j<-R||j>=R) continue;
            high[j+R]=max(high[j+R],y[i]);
        }
    }

    vector<int> mi(2*R+1,100);
    for(int i=0;i<=2*R;i++){
        if(i-1>=0) mi[i]=min(mi[i],high[i-1]);
        if(i<2*R) mi[i]=min(mi[i],high[i]);
    }

    double ans=10000.0;
    for(int h=0;h<=2*R;h++){
        double x=R-h;
        double y2=R*R-x*x;
        double z=sqrt(y2);
        ans=min(ans,mi[h]-z+R);
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

int main(){
  while(1){
      cin>>R>>N;
      if(R==0&&N==0) break;
      solve();
  }

  return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

double a, b, x;

int main() {
  cin >> a >> b >> x;

  double s = x / a;
  double rad;
  if (s >= a * b / 2) {
    rad = atan2((b - s / a) * 2, a);
  } else {
    rad = atan2(b, 2 * s / b);
  }
  double PI = acos(-1);
  double ans = rad / PI * 180.0;

  cout << setprecision(7) << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    string s; cin>>s;
    int cnt = 0;
    int mxcnt = 0;
    for(auto i : s)
    {
        if(i == 'R') cnt++;
        else cnt = 0;
        mxcnt = max(mxcnt, cnt);
    }
    cout<<mxcnt;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3604
# import numpy as np
# import queue
# import heapq


def main():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))

    f_loop = [1]
    passed = set(f_loop)

    next_idx = 1
    while True:
        next_town = As[next_idx-1]
        if next_town in passed:
            idx_head = f_loop.index(next_town)
            n_loop = len(f_loop) - idx_head
            break

        passed.add(next_town)
        f_loop.append(next_town)
        next_idx = next_town

    if idx_head + n_loop <= K:
        target = idx_head + (K - idx_head - n_loop) % n_loop
    else:
        target = K

    print(f_loop[target])


if __name__ == "__main__":
    main()


Measured memory_bytes: 32668
import collections
from typing import Counter

if __name__ == "__main__":
    N = int(input())
    S = []
    for _ in range(N):
        S.append(input())
    counter = dict(collections.Counter(S))
    try:
        print(f"AC x {counter['AC']}")
    except:
        print(f"AC x {0}")
    try:
        print(f"WA x {counter['WA']}")
    except:
        print(f"WA x {0}")

    try:
        print(f"TLE x {counter['TLE']}")
    except:
        print(f"TLE x {0}")

    try:
        print(f"RE x {counter['RE']}")
    except:
        print(f"RE x {0}")


Measured memory_bytes: 85488
def bubbleSort(l, n):
    for i in range(n):
        for j in range(n-1-i):
            if l[j][0] > l[j+1][0]:
                l[j], l[j+1] = l[j+1], l[j]
    return l[:]

def selectionSort(l, n):
    for i in range(n):
        minj = i
        for j in range(i+1, n):
            if l[j][0] < l[minj][0]:
                minj = j
        l[i], l[minj] = l[minj], l[i]
    return l[:]

n = int(input())
l = []
for c in input().split():
    l.append((int(c[1]), c[0]))
    
bl = ' '.join([k + str(n) for n, k in bubbleSort(l[:], n)])
sl = ' '.join([k + str(n) for n, k in selectionSort(l[:], n)])
print(bl)
print('Stable')
print(sl)
print('Stable' if sl == bl else 'Not stable')

Measured memory_bytes: 6756
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) ((int)(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){clr(ch,0);if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 111
#define int ll
int n,a[N];
signed main(){
    in>>n;
    int s=0,ans=0;
    Fur(i,1,n)in>>a[i],s+=a[i];
    Fur(i,1,n)ans+=a[i]*(s-a[i]);
    ans>>=1;
    out<<ans<<ln;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
data = []
for i in range(N):
    city, value = input().strip().split(' ')
    data.append((city, int(value), i+1))
data.sort(key=lambda x: x[1], reverse=True)
data.sort(key=lambda x: x[0])
for i in range(N):
    print(data[i][2])


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

typedef long long ll;
typedef pair<int, int> P;

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const ll M = 998244353;
const string END = "\n";

ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n, a[100001], b[100001], c[100001];
	cin >> n;
	rep(i, n){
		cin >> a[i];
	}
	rep(i, n){
		if(i == 0){
			b[i] = a[i];
			c[n-1-i] = a[n-1-i];
		}else{
			b[i] = gcd(a[i], b[i-1]);
			c[n-1-i] = gcd(a[n-1-i], c[n-i]);
		}
	}
	ll ans = 0;
	ans = max(b[n-2], c[1]);
	frep(i, 1, n-1){
		ans = max(ans, gcd(b[i-1], c[i+1]));
	}
	cout << ans << END;

	return 0;
}


Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = 0;
        }
        for(int i = 0;i<q;i++){
            int point = sc.nextInt() - 1;
            a[point]++;
        }
        for(int i = 0;i<n;i++){
            if(0<(k-(q-a[i]))){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
        System.out.println();
        sc.close();
    }
}

Measured memory_bytes: 52224
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 1e4+5;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int N;
char S[MAXN];

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    cin >> S;
    int L = strlen(S);
    fori(i,L) S[i] = (S[i]-'A' + N)%26 + 'A';
    cout << S << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;

int main() {
	ll N, a, b;
	cin >> N;

	vector<pair<ll, ll>> VP(N);
	vector<ll> scr(2 * N);
	ll LS = 0, RS = 0;
	for (int i = 0;i < N;i++) {
		cin >> a >> b;
		LS += a;
		RS += b;
		VP[i] = { a,b };
		scr[i * 2] = a;
		scr[i * 2 + 1] = b;
	}
	sort(all(scr));

	ll C, CR = 0, CRR, ans = min(LS, RS);
	for (int i = 0;i < N;i++)CR += scr[i];
	CRR = CR;
	for (int i = 0;i < N;i++) {
		tie(a, b) = VP[i];
		if (a > b)swap(a, b);
		C = scr[N - 1];
		if (a < C) {
			if (b > C)CR += b - C;
		}
		else if (a == C) {
			C = scr[N - 2];
			if (b > C) {
				CR += b - C;
			}
		}
		else {
			CR += a - C;
			C = scr[N - 2];
			CR += b - C;
		}
		ans = min(ans, CR);
		CR = CRR;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
N = gets.chomp.to_i
an = gets.chomp.split.map(&:to_i)

res = 0
i = 1
for var in an do
  if i%2 == 1 then
    if var %2 == 1 then
      res = res+1
    end
  end
      i = i + 1
end

puts res


Measured memory_bytes: 14308
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 300001;

int n, a, b, fact[N], mod = 998244353;
ll k;

int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int C(int n, int r){
    return 1LL * fact[n] * powlog(1LL * fact[r] * fact[n - r] % mod, mod - 2) % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    for(int i = 1 ; i < N ; i++){
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }
    cin >> n >> a >> b >> k;
    int ans = 0;
    for(int i = 0 ; i <= n ; i++){
        ll g = 1LL * i * a;
        if(g > k || (k - g) % b) continue;
        ll j = (k - g) / b;
        if(j > n) continue;
        ans = (ans + 1LL * C(n, i) * C(n, j)) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

P = [0] * (N + 1)

for A in A:
    P[A] = 1

a = P[:X].count(1)
b = P[X - N:].count(1)

# print(P[:X])
# print(P[X - N:])
print(min(a, b))


Measured memory_bytes: 9188
#include<stdio.h>

main(){
  int num,i,line,flg=0;
  char str[101],*res[2]={"Yes","No"};
  scanf("%d",&num);
  scanf("%s",str);
  if(num%2==0){
    line = num/2;
    for(i=0;i<line;i++)
      if(str[i]!=str[line+i])flg=1;
  }else flg=1;
  
  printf("%s",res[flg]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>

pii h[1000010];

int n,tt;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();
	if (n&1)
	{
		tt=0;
		for (int i=1;i<n;i++) h[++tt]=pii(n,i);
		for (int i=1;i<n;i++) for (int j=i+1;j<n;j++) if (i+j!=n) h[++tt]=pii(i,j);
		printf("%d\n",tt);
		for (int i=1;i<=tt;i++) printf("%d %d\n",h[i].first,h[i].second);
		return 0;
	}
	for (int i=1;i<n;i++) for (int j=i+1;j<=n;j++) if (i+j!=n+1) h[++tt]=pii(i,j);
	printf("%d\n",tt);
	for (int i=1;i<=tt;i++) printf("%d %d\n",h[i].first,h[i].second);
	return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

ll N,A,B,C,ans=1e10;
vector<ll> v;
vector<ll> ids;

void dfs(ll i) {
    if (i < N) {
        rep(id,-1,3){
            ids[i] = id;
            dfs(i+1);
        }
        return;
    }

    vector<vector<ll>> u(3); // u[id]: そのidに 属する index 一覧
    vector<ll> le(3); // len[id]: そのidの長さ
    rep(i,0,N){
        if (ids[i] == -1) continue;
        u[ids[i]].push_back(i);
        le[ids[i]] += v[i];
    }

    if (u[0].size() == 0 || u[1].size() == 0 || u[2].size() == 0)
        return;

    // cout<<"0 :"; for (auto i: u[0]) cout<<i<<","; cout<<endl;
    // cout<<"1 :"; for (auto i: u[1]) cout<<i<<","; cout<<endl;
    // cout<<"2 :"; for (auto i: u[2]) cout<<i<<","; cout<<endl;
    // cout<<endl;

    ll t = 0;
    t += max((int)u[0].size()-1,0) * 10;
    t += max((int)u[1].size()-1,0) * 10;
    t += max((int)u[2].size()-1,0) * 10;
    t += abs(le[0] - A);
    t += abs(le[1] - B);
    t += abs(le[2] - C);

    ans = min(ans, t);
}

signed main() {
    cin>>N>>A>>B>>C;
    v.resize(N, 0);
    rep(i,0,N)
        cin>>v[i];
    ids.resize(N, 0);
    dfs(0);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
data = int(input())
array = [int(i) for i in input().split()]
div2 = 0
div4 = 0
for i in array:
  if i%4==0:
    div4 += 1
  elif i%2==0:
    div2 += 1
if data-max(div2-1,0) <= div4*2+1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define inf 0x7f7f7f7f
#define maxn 55
int n, m;
int x[maxn], y[maxn], p[maxn], z[maxn];
int main()
{
    int a, b;

    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &x[i], &y[i]);
        z[i] = 0;
        p[i] = inf;
    }
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &a, &b);
        for (int j = 0; j < n; j++) {
            if (abs(x[j] - a) + abs(y[j] - b) < p[j]) {
                p[j] = abs(x[j] - a) + abs(y[j] - b);
                z[j] = i + 1;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        printf("%d\n", z[i]);
    }
}


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

typedef long long ll;
const int N = 3e3 + 9, M = 9e2 + 9, OO = 0x3f3f3f3f;
const double EPS = 0.00000000001;

int n, maxt;
pair<int, int> data[N];
int mem[N][N];

ll solve(int i = 0, int t = 0){
	if(i == n) return 0;
	if(t >= maxt) return 0;
	int& ret = mem[i][t];
	if(~ret) return ret;
	return ret = max(solve(i+1, t), solve(i+1, t+data[i].first)+data[i].second);
}


int main(){
	//freopen ("i.in","r",stdin);
	//freopen ("no.out","w",stdout);

	memset(mem, -1, sizeof mem);
	scanf("%d%d", &n, &maxt);
	for(int i = 0 ; i < n ; ++i) scanf("%d%d", &data[i].first, &data[i].second);
	sort(data, data+n);
	printf("%lld\n", solve());


	return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = (int)2e5 + 10;
const ll MOD = (ll)1e9 + 7LL;

ll mod_pow(ll a, ll n){
	ll x = a;
	ll res = 1LL;
	while(n > 0LL){
		if (n & 1LL){
			res = (res * x) % MOD;
		} // end if
		x = (x * x) % MOD;
		n >>= 1LL;
	} // end while
	return res % MOD;
}

ll f[MAX_N];

ll mod_comb(int n, int r){
	if (n < r) return 0LL;
	if (r > n / 2){
			r = n - r;
	} // end if
	ll res = 0LL;
	res = (f[n] * mod_pow(f[n-r], MOD - 2LL)) % MOD;
	res = (res * mod_pow(f[r], MOD - 2LL)) % MOD;

	return res;
} 

int main()
{
	memset(f, 0LL, sizeof(f));
	f[0] = 1LL;
	f[1] = 1LL;
	for (int i = 2; i < MAX_N; ++i){
		f[i] = ((ll)i * f[i - 1]) % MOD;
	} // end for

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M; cin >> N >> M;

	map<int,int> cnt; cnt.clear();
	int origM = M;
	for (int i = 2; i * i <= origM; ++i){
		while (M % i == 0){
			++cnt[i];
			M /= i;
		} // end while 
	} // end for

	if (M != 1){
		++cnt[M];
	} // end if
	
	ll res = 1LL;
	map<int,int>::iterator it = cnt.begin();
	for (; it != cnt.end(); ++it){
		int p = (*it).first;
		int r = (*it).second;
		res = (res * mod_comb(N + r - 1, r)) % MOD;
	} // end for

	cout << res << endl; 

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
main(){
    int i=0,A,B,C,K,ans=0;
    cin >> A >> B >> C >> K;
    if(A>=K){
        cout << K << endl;;
    }
    if(A+B>=K&&A<K){
        cout << A << endl; 
    }
    if(A+B<K){
        K=K-(A+B);
        cout << A-K << endl;
    }


    
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
	Scanner sc = new Scanner(System.in);
	int a,b;
	
	void bc(){
		a=sc.nextInt();
		b=sc.nextInt();
		
		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else if(a==b){
			System.out.println("a == b");
		}
		
	}
	
	public static void main(String[] args){     
		new Main().bc();     
		} 
	}

Measured memory_bytes: 17184
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int P[10010] = {};
	for (int n; cin >> n&&n;) {
		memset(P, 0, sizeof(P));
		rep(i, 0, n) {
			int p, d1, d2; cin >> p >> d1 >> d2;
			P[p] = d1 + d2;
		}
		cout << max_element(P, P + 10010) - P << " " << *max_element(P, P + 10010) << endl;
	}
	return 0;
}

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

int main(){
  int N, K; cin >> N >> K;
  vector<long long> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  long long ans = 1e18;
  for(int i = 0; i <1<<(N - 1); i++){
    int cnt = 0;
    for(int j=0;j < N-1;j++){
      cnt += (i>>j)&1;
    }
    if(cnt != K-1)continue;
    long long tmp = 0;
    long long now = a[0];
    for(int j = 0; j < N - 1; j++){
      if(i>>j &1){
        if(now >= a[j + 1]){
          tmp += now - a[j + 1] + 1;
        }
        now = max(now + 1, a[j + 1]);
      }
      now = max(now, a[j + 1]);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

const int mod = 1e9 + 7;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
#define ll long long
#define vi vector < int >
#define si set <int>
#define mii map <int, int>
#define vll vector < ll >
#define pii pair < int , int >
#define ff first
#define tc \
    int ttt; cin >> ttt;\
    while(ttt --)
#define ss second
#define f(i,a,b) for(int i=a;i<b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define nl '\n'
#define all(x) x.begin() , x.end()
#define mne min_element
#define mxe max_element
ll gcd(ll x, ll y) {return y == 0 ? x : gcd(y, x % y);}
int logg(ll x , ll y) {if (x == 0) return -1; return logg(x / y, y) + 1;}
ll poww(ll a, ll b, ll m) {
	if (b == 0) return 1;
	ll ans = 1;
	ans = poww(a, b >> 1, m);
	ans = (ans * ans) % m;
	if (b & 1) ans = (ans * a) % m;
	return ans;
}
// Start of code

int dp[3005][3005];
string s1, s2;

string solve() {
	int n = s1.size();
	int m = s2.size();
	f(i, 0, n + 1) dp[0][i] = 0;
	f(i, 0, m + 1) dp[i][0] = 0;

	f(i, 1, n + 1) {
		string tmp = "";
		f(j, 1, m + 1) {
			int q = 0;
			if (s1[i - 1] == s2[j - 1]) q = 1 + dp[i - 1][j - 1], tmp += s1[i - 1];
			else q = max(dp[i][j - 1], dp[i - 1][j]), tmp = s1[i];
			dp[i][j] = q;
		}
	}
	string ans;
	int i = n, j = m;
	while (i > 0 && j > 0) {
		if (s1[i - 1] == s2[j - 1]) ans = s1[i - 1] + ans, i--, j--;
		else if (dp[i - 1][j] > dp[i][j - 1]) i--;
		else j--;
	}
	return ans;
}

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast;

	cin >> s1 >> s2;
	cout << solve() << nl;
}

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

const int inf = (1LL<<31) -1;
const ll MAXN = 200000;
const ll MAXD = 1000000;

string S;
ll N, M, ans=0, tmp=0;

struct segmentTree{
	vector<int> node;
	int n;
	
	segmentTree(vector<int> &v){
		int s = v.size();
		n = 2;
		while(n < s) n *= 2;
		node = vector<int>(2*n -1, inf);
		for(int i=0; i<s; i++){
			node[i +n-1] = v[i];
		}
		for(int i=n-2; i>=0; i--){
			node[i] = min(node[2*i +1], node[2*i +2]);
		}
	}
	
	void Set(int val, int pos){
		int idx = n-1 + pos;
		node[idx] = val;
		do{
			idx = (idx -1)/2;
			node[idx] = min(node[2*idx +1], node[2*idx +2]);
		}while(idx != 0);
	}
	int Get(int l, int r){
		return _get(l, r, 0, 0, n);
	}
	int _get(int l, int r, int k, int cl, int cr){
		if(l <= cl && cr <= r){
			return node[k];
		}
		if(r <= cl || cr <= l){
			return inf;
		}
		int m = (cl +cr)/2;
		return min(_get(l, r, 2*k+1, cl, m), _get(l, r, 2*k+2, m, cr));
	}
};

void DPinit() {
    vector<ll> A, DP(N+1, MAXD), Pre(N+1, 0);
    DP[0]=0;
    segmentTree segtree(DP);
    for(int i=1;i<=N;i++) {
        if(S[i]=='0') {
            ll a;
            if(i<M) a=segtree.Get(0, i);
            else a=segtree.Get(i-M, i);
            segtree.Set(a+1, i);
        }
    }
    
    ll c = segtree.Get(N, N+1);
    if(c>=MAXD) {
        cout << -1 << endl;
        return;
    }

    ll id=N;
    while(id!=0) {
        for(int i=M;i>=1;i--) {
            if(id-i>=0) {
                ll e = segtree.Get(id-i, id-i+1);
                ll f = segtree.Get(id, id+1);
                if(e==f-1) {
                    A.push_back(i);
                    id = id-i;
                    break;
                }
            }
        }
    }

    for(int i=A.size()-1;i>=0;i--) {
        cout << A[i] << endl;
    }
}

signed main(){
    cin >> N >> M >> S;
    DPinit();
    return 0;
}

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

int main(void) {
  int N, M, cnt=0;
  cin >> N >> M;
  
  for(int i=0; i<N; i++) cnt+=i;
  for(int i=0; i<M; i++) cnt+=i;
  
  cout << cnt << endl;
  
  return 0;
}

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

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

    ll count = 0;
    for(int a = 1; a< n; a++){
        if(n % a == 0){
            count += n/a-1;
        }
        else count += n/a;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3616