akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define int long long
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

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

    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()) cout << "GREATER";
    else if(a.size() < b.size()) cout << "LESS";
    else {
        int x = 0;
        while(x < a.size()){
            if((int)(a[x]-'0') > (int)(b[x]-'0')) {cout << "GREATER"; return 0;}
            else if ((int)(a[x]-'0') < (int)(b[x]-'0')) {cout << "LESS"; return 0;}
            else x ++;
        }
        cout << "EQUAL";
    }
    return 0;
}









Measured memory_bytes: 3548
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());

    ll ans = -1;
    ll sum = 0;
    for (ll i = 0; i < N - 1; i++)
    {
        sum += A[i];
        if (sum * 2 < A[i + 1]) {
            ans = i;
        }
    }
    cout << (N - ans - 1) << endl;
}

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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

int main ()
{
    int a, b; cin >> a >> b;
    if (a <= 5)
        cout << 0 << endl;
    else if (a >= 13)
        cout << b << endl;
    else
        cout << b/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

using namespace std;

int N;
int main() {
    cin >> N;
    int ans = 0;
    for(int i=1;i<N+1;i++){
        int cnt = 0;
        int tmp = i;
        while(tmp) {
            tmp /= 10;
            cnt++;
        }
        if(cnt%2) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	int tmp = N;
	int num = 0;
	while (tmp>0) {
		num += tmp % 10;
		tmp /= 10;
	}
	if (N%num == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(a+b>=c)
    {
        puts("No");
        return 0;
    }
    long long q=4*a*b;
    long long h =a*a + b*b + c*c + 2*a*b - 2*a*c - 2*b*c;
    if(q<h)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 384
use whiteread::parse_line;

fn main() {
    let (n, m): (usize, usize) = parse_line().unwrap();
    let mut like = vec![true; m];

    for _ in 0..n {
        let (_k, a): (usize, Vec<usize>) = parse_line().unwrap();
        for i in 0..m {
            if !a.contains(&(i + 1)) {
                like[i] = false;
            }
        }
    }
    println!("{}", like.iter().filter(|&&x| x).count());
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
#define MAXN 10009
int main(){
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    int num[MAXN];
    int k=0;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        for(int j=k;j<=k+a;j++){
            num[j]=i;
        }
        k=k+a;
    }
    // for(int i=0;i<h*w;i++){
    //     cout<<num[i]<<' ';
    // }
    int m=0;
    int grid[103][103];
    int mode = 0;
    for(int i=0;i<h;i++){
        if(mode==0){
            for(int j=0;j<w;j++){
                grid[i][j]=num[m];
                m+=1;
            }
            mode=1;
        }else if(mode==1){
            for(int j=w-1;j>=0;j--){
                grid[i][j]=num[m];
                m+=1;
            }
            mode=0;
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<grid[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	string str;
	cin>>str;
    int n = (int)str.size();
	bool flag = true;
	for(int i=0;i<n;i++)
	{
		if(str[i] != str[n-i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	string str1 = str.substr(0,(n-1)/2);
    //debug1(str1)
	string str2 = str.substr((n+3)/2-1,n-(n+3)/2+1);
    //debug1(str2)
	for(int i=0;str1[i];i++)
	{
		if(str1[i]!=str1[(int)str1.size()-i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	for(int i=0;str2[i];i++)
	{
		if(str2[i]!=str2[(int)str2.size()-i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <vector>
using namespace std;

typedef vector <vector <int> > vvi;

const int MAXN = 4005;

int ans[MAXN];

int query(int a, int b) {
	printf("? %d %d\n", a, b);
	fflush(stdout);
	char ans;
	scanf(" %c", &ans);
	return ans == 'Y';
}

int equiv(int a, int b) {
	return query(a, b) && query(b, a);
}

vector <int> merge(vector <int> a, vector <int> b) {
	a.insert(a.end(), b.begin(), b.end());
	return a;
}

void set(vector <int> v, int val) {
	for (auto it : v)
		ans[it] = val;
}

void ask(int who, vector <int> v) {
	set(v, query(who, v[0]));
}

int main() {
	int A, B;
	scanf("%d%d", &A, &B);
	
	if (A <= B) {
		puts("Impossible");
		fflush(stdout);
		return 0;
	}
	
	int N = A + B;
	vvi groups;
	for (int i = 0; i < N; i++) 
		groups.push_back({i});
	
	vvi rest, large;
	while (!groups.empty()) {
		if (groups.size() % 2) {
			rest.push_back(groups.back());
			groups.pop_back();
		}
		vvi nxt;
		for (int i = 0; i < groups.size(); i += 2)
			if (equiv(groups[i][0], groups[i + 1][0]))
				nxt.push_back(merge(groups[i], groups[i + 1]));
			else {
				large.push_back(groups[i]);
				large.push_back(groups[i + 1]);
			}
		groups = nxt;
	}
	
	assert(!rest.empty());
	
	int honest = rest.back()[0];
	for (int i = 0; i < (int)rest.size() - 1; i++)
		ask(honest, rest[i]);
	
	for (auto it : large)
		ask(honest, it);
	
	set(rest.back(), 1);
	
	printf("! ");
	for (int i = 0; i < N; i++)
		printf("%d", ans[i]);
	puts("");
	fflush(stdout);
	
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>

int main()
{
    int x[100],y[100],i=0,j=0,k,imax;
    
    
    for (;;)
    {
        std::cin >> x[i] >> y[i];

        if ((x[i] == 0) && (y[i] == 0)) break;

        i++;
    }
    imax = i;


        for (i = 0; i < imax; i++)
        {
            for (j = 0; j < x[i]; j++)
            {
                for (k = 0; k < y[i]; k++)
                {
                    if ((k == 0) || (k == y[i] - 1)||(j==0)||(j==x[i]-1)) {
                        std::cout << "#";
                    }
                    else {
                        std::cout << ".";
                    }
                    
                }
                std::cout << std::endl;
            }
            std::cout << std::endl;


        }
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
}

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

int main (){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int saki,ato;
  saki=a*60+b;
  ato=c*60+d;
  int aaa;
  aaa=ato-saki-e;
  if(aaa<0) cout<<0;
  else cout<<aaa;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,w;
	cin>>n>>w;
	vector<vector<ll> > dp(n+1,vector<ll>(w+1,0));
	for(int i=1;i<=n;i++)
	{
		ll weight,value;
		cin>>weight>>value;
		for(int j=1;j<=w;j++)
		{
			dp[i][j] = max(dp[i-1][j],(j-weight>=0)?dp[i-1][j-weight]+value:0);
		}
	}
	cout<<dp[n][w]<<endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> cnt(N, 0);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    cnt[a - 1]++;
    cnt[b - 1]++;
  }
  rep(i, N) cout << cnt[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long double A[200005];
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
 
    int n, k;
    cin >> n >> k;
 
    for (int i=1; i<=n; i++)
    {
        int x;
        cin >> x;
 
        A[i] = log2(x) + A[i-1];
    }
 
    long double prev = A[k];
 
    for (int i=k+1; i<=n; i++)
    {
        if (abs(A[i] - A[i-k] - prev) > 1e-9 && A[i] - A[i-k] > prev)
            cout << "Yes\n";
        else
            cout << "No\n";
        
        prev = A[i] - A[i-k];
    }
 
    return 0;
}

Measured memory_bytes: 6884
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, M, X; scanf("%d%d%d", &N, &M, &X);
    vector<int> C(N);
    vector< vector<int> > A(N, vector<int>(M));
    for(int i=0; i<N; i++) {
        cin >> C[i];
        for(int j=0; j<M; j++) cin >> A[i][j];
    }

    int ans = INF;
    for(int bit=0; bit<(1<<N); bit++) {
        vector<int> algo(M);
        int mon = 0;
        for(int i=0; i<N; i++) {
            if(!(bit >> i & 1)) continue;
            mon += C[i];
            for(int j=0; j<M; j++) algo[j] += A[i][j];
        }

        bool ok = true;
        for(int i=0; i<M; i++) ok &= (algo[i] >= X);
        if(ok) chmin(ans, mon);
    }
    cout << (ans == INF ? -1 :  ans) << endl;
    return 0;
}


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

int main(){
  int H,W;
  cin>>H>>W;
  
  vector<vector<char>> date(H,vector<char>(W));
   
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>date.at(i).at(j);
  }
  }
 
  vector<bool> h(H, false);
  vector<bool> w(W, false);
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(date.at(i).at(j)=='#'){
        h.at(i)=true;
        w.at(j)=true;
      }
    }
  }
    
    for(int i=0;i<H;i++){
      if(h.at(i)){
      for(int j=0;j<W;j++){
if(w.at(j)){
  cout<<date.at(i).at(j);
}
      }
      cout<<endl;
    }
  }
  
  }
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,a[1000001];
cin>>n;
for (int i = 1;i <= n;i++){
  a[i] = i;
}
int64_t sum=0;
for (int i = 1;i <= n;i++){
if (a[i]%15==0)
  continue;
else if (a[i]%3==0)
  continue;
else if (a[i]%5==0)
  continue;
else{
  sum += a[i];
}


}
cout<<sum<<endl;




}

Measured memory_bytes: 7496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main()
{
    cin>>n>>x;
    cout<<3*(n-gcd(n,x))<<endl;
    return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int N,M;
    cin >> N >> M;
    vector<int> vp(M);
    if (N >= M ) {
        cout << 0 << endl;
        return;
    }
    REP(i,M) {
        int x;
        cin >> x;
        vp[i] = x;
    }
    sort(ALL(vp));
    vector<int> vl(M-1);
    REP(i,M-1) vl[i] = vp[i+ 1] - vp[i];
    sort(ALL(vl));
    reverse(ALL(vl));
    ll sm = 0;
    FOR(i,N-1,M-1) sm += vl[i];
    cout << sm << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4016
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            var filePath = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                $"{Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location)}.in");
            Console.SetIn(new StreamReader(filePath));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Enumerable.Range(0, N).Select(elem => Console.ReadLine()).GroupBy(elem => elem).Select(elem => new { Result = elem.Key, Count = elem.Count() }).ToDictionary(elem => elem.Result, elem => elem.Count);
            int value;
            Console.WriteLine($"AC x {(S.TryGetValue("AC", out value) ? value : 0)}");
            Console.WriteLine($"WA x {(S.TryGetValue("WA", out value) ? value : 0)}");
            Console.WriteLine($"TLE x {(S.TryGetValue("TLE", out value) ? value : 0)}");
            Console.WriteLine($"RE x {(S.TryGetValue("RE", out value) ? value : 0)}");
        }
    }
}


Measured memory_bytes: 24960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        while(n-->0) {
            Integer[] list = Arrays.stream(br.readLine().split(" ")).map(Integer::parseInt).toArray(Integer[]::new);
            Deque<Integer> stack1=new ArrayDeque<>();
            Deque<Integer> stack2=new ArrayDeque<>();
            stack1.push(list[0]);
            for(int i=1;i<list.length;i++) {
                if(stack1.peek()<list[i]) {
                    stack1.push(list[i]);
                }else if(stack2.isEmpty()) {
                    stack2.push(list[i]);
                }else if(stack2.peek()<list[i]) {
                    stack2.push(list[i]);
                }else {
                    System.out.println("NO");
                    break;
                }
            }
            if(stack1.size()+stack2.size()==list.length) {
                System.out.println("YES");
            }
        }
    }
}


Measured memory_bytes: 30724
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
ll a[3010],b[3010];
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=3000;i++) b[i]=a[i]+b[i-1];
	ll ans=0;
	for(int i=1;i<=1000;i++){
        ans+=a[i]*(a[i]-1)*(a[i]-2)/6;
	}
	for(int i=1000;i>=1;i--){
		for(int j=1;j<=1000;j++){
		    if(i==j) continue;
			if(i+i>j) ans+=a[i]*(a[i]-1)/2*a[j];
		}
	}
	for(int i=1;i<=1000;i++){
		for(int j=i+1;j<=1000;j++){
			int r=i+j-1;
			//if(a[i]==0||a[j]==0||b[r]-b[j]==0) continue;
			//cout<<i<<" "<<j<<" "<<r<<" "<<1ll*(b[r]-b[j])*a[i]*a[j]<<endl;
			ans+=1ll*(b[r]-b[j])*a[i]*a[j];
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if( a >= b && a >= c ){
		cout << a*10 + b + c << endl;
	} else if ( b >= a && b >= c ){
		cout << b*10 + a + c << endl;
	} else {
		cout << c*10 + a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split(' ').map(&:to_i).sort
bs = []

MOD = (10 ** 9 + 7)

# 理想の数列を作成できなければ、0を返す
if n.even?
  # 1から開始、終点はn-1まで、2刻み（1,1,3,3...n-1,n-1の数列）
  1.step(n-1, 2) { |i| bs.push(i,i) }
else
  bs.push(0)
  2.step(n-1, 2) { |i| bs.push(i,i) }
end

puts as == bs ? (2**(n/2)%MOD) : 0

Measured memory_bytes: 22792
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    rep0(i, s.size()){
        s[i] += n;
        if(s[i] > 90)s[i] -= 26;
    }
    cout << s << endl;
    return 0;
}


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

void solve()
{
    int n, t; cin >> n >> t;
    int m, M; 
    m = 1 << 30;
    M = 0;
    int indexm = 0;
    map<int, int> mp;
    for(int i = 0; i < n; ++i){
        int a; cin >> a;
        if(m > a) {
            m = a;
        }
        if(a-m > M) M = a-m;
        if(i && a-m >0) {
            mp[a-m]++;
        }
    }
    cout << mp[M] << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 8292
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

A = sorted(A)
B = sorted(B)
C = sorted(C)
ans = 0
midnum = []
index = 0

for i in B:
    while True:
        if index == N or A[index] >= i:
            midnum.append(index)
            break
        else:
            index += 1

index = 0
midCnum = []
tmp = 0
for i in midnum:
    tmp += i
    midCnum.append(tmp)

for i in C:
    while True:
        if index == N:
            ans += midCnum[index-1]
            break
        elif i <= B[index]:
            if index != 0:
                ans += midCnum[index-1]
            break
        else:
            index += 1

print(ans)

Measured memory_bytes: 24116
<?php
fscanf(STDIN, '%d %d', $N, $M);
$store = [];
for ($i=0; $i < $N; $i++) { 
    fscanf(STDIN, '%d %d', $A, $B);
    $store[] = ['price' => $A, 'max' => $B];
}
array_multisort(array_column($store, 'price'), SORT_ASC, array_column($store, 'max'), SORT_DESC, $store);
$ans = 0;
$now = 0;
foreach ($store as $key => $value) {
    if ($now >= $M) {
        break;
    }
    for ($i=0; $i < $value['max']; $i++) { 
        if ($now >= $M) {
            break 2;
        }
        $ans += $value['price'];
        $now++;
    }
}
echo $ans."\n";

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

using namespace std;

int N, K, mod, c[709][709], dp[310][310], partialSum[310][310];

void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}
int add (int x, int y) {int z = x + y; if (z >= mod) z -= mod; return z;}
int mul (int x, int y) {return 1LL * x * y % mod;}
int subtract (int x, int y) {int z = x - y; if (z < 0) z += mod; return z;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &N, &K, &mod);
c[0][0] = 1;
for (int i=1; i<=2 * N; i++)
{
    c[i][0] = 1;
    for (int j=1; j<=i; j++)
        c[i][j] = add (c[i - 1][j - 1], c[i - 1][j]);
}
for (int j=0; j<=K; j++)
    dp[1][j] = 1, partialSum[1][j] = j + 1;
for (int i=2; i<=N + 1; i++)
{
    for (int j=0; j<=K; j++)
        for (int sz=1; sz<i; sz++)
        {
            int curr = mul (dp[i - sz][j], subtract (partialSum[sz][K], partialSum[sz][j]));
            adto (dp[i][j], mul (curr, c[i - 2][sz - 1]));
        }
    partialSum[i][0] = dp[i][0];
    for (int j=1; j<=K; j++)
        partialSum[i][j] = add (partialSum[i][j - 1], dp[i][j]);
}
printf ("%d\n", dp[N + 1][0]);
return 0;
}


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

int main() {
    int h, w; cin>>h>>w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a.at(i);
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a.at(i).at(j) == '#') {
				row.at(i) = true;
				col.at(j) = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
/**
 * @author      : omgursocute
 * @created     : 19/01/2020
 * @task        : C
 */

// ==== CODE STARTS AT LINE 53 ==== //

// ===== TEMPLATE STARTS HERE ===== //

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define FORa(i, a, b) for(ll i = (a); i <= (b); ++i)
#define FORb(i, a, b, c) for(ll i = (a); i <= (b); i += (c))
#define FORn(i, n) for(ll i = 0; i < (n); ++i)
#define FORra(i, a, b) for(ll i = (a); i >= (b); --i)
#define FORrb(i, a, b, c) for(ll i = (a); i >= (b); i -= (c))
#define FORrn(i, n) for(ll i = ((n)-1); i >= 0; --i)
#define NUMARGC(_1, _2, _3, _4, NAME, ...) NAME
#define FOR(...) NUMARGC(__VA_ARGS__, FORb, FORa, FORn)(__VA_ARGS__)
#define RFOR(...) NUMARGC(__VA_ARGS__, FORrb, FORra, FORrn)(__VA_ARGS__)

#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair

#define sqr(x) 1ll*(x)*(x)
#define debug(x) cerr << '[' << #x << ']' << " = " << x << '\n';

namespace io {
	void openIn(string s) {freopen(s.c_str(), "r", stdin);}
	void openOut(string s) {freopen(s.c_str(), "w", stdout);}
	void setIO(string s = "") {
		ios::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
		if(s.size()) {openIn(s + ".inp"); openOut(s + ".out");}
	}
}

// ======= TEMPLATE ENDS HERE ======= //

int main() {
	io::setIO("");

	int n, m;
	cin >> n >> m;
	vi submit_ct(n+1);
	bool AC[n+1] = {0};

	int penalties = 0;
	int ct = 0;

	while(m--) {
		int task;
		string verdict;
		cin >> task >> verdict;
		if(verdict == "AC" && !AC[task]) {
			penalties += submit_ct[task];
			AC[task] = 1;
			++ct;
		}
		if(verdict == "WA") {
			++submit_ct[task];
		}
	}

	cout << ct << ' ' << penalties;

	return 0;
}



Measured memory_bytes: 768
#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;
typedef long long int ll;
 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
 
const ll N = 102;
const ll mod = 1000000007;
const long long int inf = 2*(1e16);
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
 
 
 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


const ll u = 100001;
ll dp[N][100001];
ll ans[N];

int main()
{
    ll n,w;
    cin>>n>>w;
    ll a[n+1][2];
    rep1(i,n+1) cin>>a[i][0]>>a[i][1];
    dp[0][0] = w;
    rep1(i,u) dp[0][i] = -1;
    rep1(i,N) dp[i][0] = w;
    // cout<<dp[3][0]<<endl;
    for(ll i = 1;i<=n;i++){
       // cout<<i<<endl;
       //cout<<dp[i][0]<<endl;
        for(ll j = 1;j<=u;j++){
           //  cout<<"i = "<<i<<"j = "<<j<<endl;
              //  cout<<dp[4][0]<<endl;
            dp[i][j] = dp[i-1][j];
            if(j-a[i][1]<0){
               // cout<<"i = "<<i<<"j = "<<j<<endl;
              //  cout<<dp[4][0]<<endl;
                dp[i][j] = dp[i-1][j];
                 continue;
            }
            if(dp[i-1][j-a[i][1]]>=a[i][0]){
              //  cout<<"i = "<<i<<"j = "<<j<<endl;
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-a[i][1]]-a[i][0]);
            }
            
        }
       // cout<<dp[i][0]<<endl;
    }
    ll ans = 0;
    rrep(i,u){
        if(dp[n][i]>=0){
            ans = i;
            break;
        }
    }
   
    // rep(i,n+1){
    //     rep(j,20) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<ans<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

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

int main() {
    int n, m, c;
    int b[25] = {0}, a[25][25] = {0};
    cin >> n >> m >> c;
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int ans = 0;
        for (int j = 0; j < m; j++) {
            ans += a[i][j] * b[j];
        }
        ans += c;
        if (ans > 0) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    vector<int> ss(26,0),tt(26,0);
    for(char c:s){
        ss[c-'a']++;
    }
    for(char c:t){
        tt[c-'a']++;
    }
    sort(ss.begin(),ss.end());
    sort(tt.begin(),tt.end());
    if(ss==tt){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    // ！！！これ嘘解法です！！！
}


Measured memory_bytes: 916
// https://atcoder.jp/contests/abc152/tasks/abc152_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int res = 0;
    vector<vector<int>> num(10, vector<int>(10));
    for (int n = 1; n <= N; ++n) {
        vector<int> d;
        int nn = n;
        while (nn) {
            d.push_back(nn % 10);
            nn /= 10;
        }
        int a = d.front();
        int b = d.back();
        if (a > 0 && b > 0) {
            num[a][b]++;
        }
    }
    for (int a = 1; a < 10; ++a) {
        for (int b = 1; b < 10; ++b) {
            res += num[a][b] * num[b][a];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate
N = int(input())
A = list(map(int,input().split()))

inf = 10**10

S = [0] + sorted(list(set(A)))
dic = {s:inf for s in S}
cnt = {s:0 for s in S}
sm = {s:0 for s in S}
ml = [0]
for i, a in enumerate(A):
    if ml[-1] < a:
        ml.append(a)
    dic[a] = min(i,dic[a])
    cnt[a] += 1
    sm[a] += a

for ps, s in zip(S[:-1][::-1],S[::-1]):
    cnt[ps] += cnt[s]
    sm[ps] += sm[s]

ans = [0]*N
temp = {s:sm[s] - s*cnt[s] for s in S}

for ps, s in zip(ml[:-1][::-1],ml[::-1]):
    ans[dic[s]] = temp[ps] - temp[s]

[print(a) for a in ans]


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

int main(){
    int a,b;
    cin >> a >> b ;
    string J;
    
    if (a>0) J="Positive";
    else if (a==0 || b==0) J="Zero";
    else if (a<0 && b>0) J="Zero";
    else if ((a-b)%2 != 0) J="Positive";
    else if ((a-b)%2 == 0) J="Negative";
 
    cout << J << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    int num_point,dim;
    int **coodinate;

    scanf("%d %d",&num_point,&dim);
    coodinate=(int **)malloc(sizeof(int *)*num_point);

    int i,j,k;

    for(i=0;i<num_point;i++){
        coodinate[i]=(int *)malloc(sizeof(int)*dim);
    }

    for(i=0;i<num_point;i++){
        for(j=0;j<dim;j++){
            scanf("%d",&coodinate[i][j]);
        }
    }

    int count=0;
    int contents=0;
    int a;

    for(i=0;i<num_point-1;i++){
        for(j=i+1;j<num_point;j++){
            contents=0;
           for(k=0;k<dim;k++){
               contents+=(coodinate[i][k]-coodinate[j][k])*(coodinate[i][k]-coodinate[j][k]);
           }
           a=sqrt(contents);
           if(a==sqrt(contents)){
               count++;
           }
        }
    }
    printf("%d",count);
    return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <float.h>

char str[8];
int n;
double x;
double sum;

int main()
{
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%lf %s", &x, str);

		if (strcmp(str, "JPY") == 0) {
			sum = sum + x;
		} else {
			sum = sum + x * 380000;
		}
	}

	printf("%lf\n", sum);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){

	long n, max=0;
	long *a;
	long sum;

	do{
		max = -1000000;
		//cout << endl;
		cin >> n;

		if (n == 0) break;

		a = new long[n + 1];

		sum = 0;

		for (int i = 0; i < n; i++){

			sum = 0;

			cin >> a[i];

			for (int j = i; j >= 0; j--){

				sum += a[j];
				if (max < sum) max = sum;
			}
		}

		cout << max << endl;
	} while (1);
}

Measured memory_bytes: 1216
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

#include <bits/stdc++.h>
using namespace std;

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=200010;

int n,h[maxn],a[maxn];
int64 dp[maxn],bit[maxn],ans;

inline int64 query(int i)
{
	i--;

	int64 res=0;
	while(i>0)
	{
		res=max(res,bit[i]);
		i-=i&-i;
	}

	return res;
}

inline void modify(int i,int64 x)
{
	while(i<=n)
	{
		bit[i]=max(bit[i],x);
		i+=i&-i;
	}
}

int main()
{
	SF("%d",&n);
	for(int i=1;i<=n;i++) SF("%d",&h[i]);
	for(int i=1;i<=n;i++) SF("%d",&a[i]);

	for(int i=1;i<=n;i++)
	{
		dp[i]=query(h[i])+a[i];
		modify(h[i],dp[i]);

		ans=max(ans,dp[i]);
	}

	PF("%lld",ans);

	return 0;
}

Measured memory_bytes: 8396
#include <bits/stdc++.h>
using namespace std;
char mp[2009][2009];
int main()
{
    int n,m,sum=0,maxx=0;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%s",mp[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(mp[i][j]=='.')
            {
                sum=0;
                for(int h=i-1;h>=0;h--)
                {
                    if(mp[h][j]=='#') break;
                    sum++;
                }
                for(int h=i+1;h<n;h++)
                {
                    if(mp[h][j]=='#') break;
                    sum++;
                }
                for(int w=j-1;w>=0;w--)
                {
                    if(mp[i][w]=='#') break;
                    sum++;
                }
                for(int w=j+1;w<m;w++)
                {
                    if(mp[i][w]=='#') break;
                    sum++;
                }
                maxx=max(maxx,sum);
            }
            if(maxx==m+n-2) break;
        }
        if(maxx==m+n-2) break;
    }
    printf("%d\n",maxx+1);
    return 0;
}


Measured memory_bytes: 4224
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

from itertools import permutations

def match(lt):
    if m == 1:
        rng = [(0, 0)]
    else:
        rng = permutations(range(m), 2)
    for b_x, b_y in rng:
        a_x = lt[0] + b_x
        a_y = lt[1] + b_y
        if a[a_y][a_x] != b[b_y][b_x]:
            return False

    return True

cnt = 0
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if match((i, j)):
            print("Yes")
            exit()

print("No")


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            long i = long.Parse(Console.ReadLine()) ;
            long i2 = (i / 11) * 2;
            long i3 = i % 11;
            if (i3 == 0)
            {

            }
            else if (i3 <= 6)
            {
                i2 += 1;
            }
            else
            {
                i2 += 2;
            }


            Console.WriteLine(i2);
            Console.ReadLine();
        }
    }
}


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

int main()
{
    int n, four, two;
    cin >> n;
    four = two = 0;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        if(tmp%4 == 0){
            four++;
        }else if(tmp%2 == 0){
            two++;
        }
    }
    if(n <= 2*four +1 || n <= 2*four + two){
        cout << "Yes" << endl;
    }else{
        cout <<"No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a[11],j;main(N,i){for(;scanf("%d",&N),j=N;memset(a,0,sizeof(a))){
    for(getchar(),i=0;(j=getchar())!='\n';i++)if(j=='M')a[i%N]++;else if(j-'L')a[N]+=a[i%N]+1,a[i%N]=0;else a[i%N]+=a[N]+1,a[N]=0;
    for(i=0;i<=N;printf(i<N?"%d ":"%d\n",a[i]),i++)for(j=N-1;j>i;j--)if(a[j]<a[j-1])a[j-1]^=a[j],a[j]^=a[j-1],a[j-1]^=a[j];
}}

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

int N;
int a[101];

int solve(double ave){
	int index = 0;
	for(int i=0;i<N;i++){
		if(abs(a[i]-ave) < abs(a[index]-ave)){
			index = i;
		}
	}
	cout << index << endl;
	return 0;
}

int main(){
	cin >> N;
	double ave=0;
	for(int i=0;i<N;i++){
		cin >> a[i];
		ave += a[i];
	}
	ave /= N;
	solve(ave);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;

int dp[1050][10050] = {0};

int main()
{
    int h, n;
    cin >> h >> n;
    vector<P> a;
    rep(i, n){ int tmp1, tmp2; cin >> tmp1 >> tmp2; a.push_back(P(tmp1, tmp2));}

    rep(i, n+1)rep(j, h+1){
        dp[i][j] = INF;
    }

    dp[0][0] = 0;
    rep(i, n)rep(j, h+1){
        if(j == 0){
            dp[i+1][j] = 0;
        } else {
            dp[i+1][j] = min(dp[i][j], dp[i+1][max(0, j-a[i].first)] + a[i].second); 
        }
    }

    cout << dp[n][h] << endl; 
}



Measured memory_bytes: 41216
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> > darr({{-1,0},{1,0},{0,-1},{0,1}});
int n,dp[505][505];
bool del[505][505];
void dfs(int x,int y)
{
	int tmp=dp[x][y];
	for (auto p:darr)
	{
		int nx=x+p.first,ny=y+p.second;
		tmp=min(tmp,dp[nx][ny]+!del[x][y]);
	}
	if (tmp<dp[x][y])
	{
		dp[x][y]=tmp;
		for (auto p:darr)
		{
			int nx=x+p.first,ny=y+p.second;
			if (nx>0 && nx<=n && ny>0 && ny<=n)
			dfs(nx,ny);
		}
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		dp[i][j]=min(min(i,n-i+1),min(j,n-j+1));
	}
	int ans=0;
	for (int i=1;i<=n*n;i++)
	{
		int a;
		scanf("%d",&a);
		a--;
		int x=a/n+1,y=a%n+1;
		del[x][y]=1;
		dfs(x,y);
		ans+=dp[x][y];
	}
	printf("%d",ans);
}

Measured memory_bytes: 16320
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;cin>>test;while(test--)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;

int main(){
    map<int,ll> map;
    set<int> set;
    int n;
    cin>>n;
    int x;
    rep(i,n){
        cin>>x;
        if(map.count(x)){
            map[x]++;
        }else{
            set.insert(x);
            map[x]=1;
        }
    }
    ll ans=0;
    for(auto value:set){
        if(map[value]>=value){
            ans+=map[value]-value;
        }else{
            ans+=map[value];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 14004
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll l, r;
	cin >> l >> r;
	ll ans = 2018;
	chmin(r, l+2019);
	for(ll i = l; i < r; ++i){
		for(ll j = i+1; j <= r; ++j){
			chmin(ans, (i*j)%2019);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
vector<int>v1,v0;
const int maxn=100010;
int sum1[maxn],sum2[maxn];
int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        v0.clear();
        v1.clear();
        string s;
        cin>>s;
        int ans=0;
        if(k>=n) ans=n;
        else
        {
            if(s[0]=='0') v1.push_back(0);
            for(int i=0;i<s.size();i++)
            {
                int cnt=0;
                if(s[i]=='0')
                {
                    while(s[i]=='0')
                    {
                        cnt++;
                        i++;
                    }
                    i--;

                    v0.push_back(cnt);
                    cnt=0;
                }
                if(s[i]=='1')
                {
                    while(s[i]=='1')
                    {
                        cnt++;
                        i++;
                    }

                    i--;
                    v1.push_back(cnt);
                    cnt=0;
                }
            }
            memset(sum1,0,sizeof(sum1));
            memset(sum2,0,sizeof(sum2));
            for(int i=1;i<maxn;i++)
            {
                v0.push_back(0);
                v1.push_back(0);
            }
            for(int i=1;i<maxn;i++)
            {
                sum1[i]+=sum1[i-1]+v1[i-1];
                sum2[i]+=sum2[i-1]+v0[i-1];
            }
            for(int i=1;i<maxn;i++)
            {
                int l=i,r=l+k;
                if(r>=n) break;
                int temp=sum1[r]-sum1[l-1];
                temp+=sum2[r-1]-sum2[l-1];
                ans=max(ans,temp);
            }
        }
        cout<<ans<<endl;
    }
}


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

int main(){
    int H, W;  cin >> H >> W;
    vector<vector<int>> cost;
    cost = vector<vector<int>>(10, vector<int>(10,0));
    for(int i=0; i<=9; i++) for(int j=0; j<=9; j++) cin >> cost[i][j];

    for(int k=0; k<=9; k++){
        for(int i=0; i<=9; i++) for(int j=0; j<=9; j++){
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]); 
        }
    }

    int ans = 0;
    for(int i=0; i<H*W; i++){
        int a; cin >> a;
        if(a==-1) continue;
        ans += cost[a][1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
string s;cin>>s;
cout<<("ABC"+s);
 return 0;
}

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

ans = ""
if n % 10 == 3:
    ans = "bon"
elif n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 ==8:
    ans = "pon"
else:
    ans = "hon"

print(ans)

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

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

char win(char c){
    return (c=='r')?('p'):((c=='p')?('s'):('r'));
}

int main(){
    ll n, k;
    int r, s, p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    
    ll score = 0;
    loop(n){
        if(t[i]=='r'){
            if(i<k || t[i-k]!='R'){t[i] = 'R'; score += p;}
        }
        else if(t[i]=='p'){
            if(i<k || t[i-k]!='P'){t[i] = 'P'; score += s;}
        }
        else{
            if(i<k || t[i-k]!='S'){t[i] = 'S'; score += r;}
        }
    }

    cout<<score;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int arr[n+1];
  vector<int>v;
  for(int i=1;i<=n;i++){
    cin>>arr[i];
    if(arr[i]!=i)v.push_back(i);
  }
  if(v.size()>2)cout<<"NO"<<endl;
  else if(v.size()==0)cout<<"YES"<<endl;
  else cout<<"YES"<<endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  int a;
  int i;
  double s = 0;
  for(i=0;i<n;i++){
    scanf("%d", &a);
    s = s + (1.0 / a);
  }
  printf("%lf\n", 1.0 / s);
  return 0;
}


Measured memory_bytes: 128