akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    
    b = abs(b - a);
    
    ll period = c+d;
    ll w = (d-c) * (n-1);
    
    ll up=d*(n-1);
    if (b > up) {
        cout << "NO" << endl;
        return 0;
    }
    
    if (w >= period) {
        cout << "YES" << endl;
        return 0;
    }
    
    ll base;
    if (n%2==0) {
        base = (period-w)/2;
    } else {
        base = period - w/2;
    }
    
    if ((b - base + period) % period <= w) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());

        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = s.nextInt();
        }


        int answer = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (h[j] > h[i]) {
                    break;
                }

                if (j == i - 1) {
                    answer++;
                }
            }
        }

        System.out.println(answer);
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<vector<int>> a(n,vector<int>(m));
	rep(i,n) rep(j,m) scanf("%d",&a[i][j]), a[i][j]--;

	int ans=n;
	while(!a[0].empty()){
		int cnt[300]={};
		rep(i,n) cnt[a[i][0]]++;

		int mx=*max_element(cnt,cnt+m);
		ans=min(ans,mx);

		rep(i,n){
			rep(j,a[i].size()) if(cnt[a[i][j]]==mx) {
				a[i].erase(a[i].begin()+j);
				j--;
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if(b>=100){
    if((int)sqrt((a*1000+b))*(int)sqrt((a*1000+b))==(a*1000+b)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if (b>=10){
    if((int)sqrt((a*100+b))*(int)sqrt((a*100+b))==(a*100+b)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else {
    if((int)sqrt((a*10+b))*(int)sqrt((a*10+b))==(a*10+b)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll    long long int
#define   sz    200010

using namespace std;


ll num[sz];

int main()
{


   ll n,a,b,c,mn=10000000000000,i,j,d;

   ll k;


   cin>>n>>k;

   for(i=1;i<=n;i++)
   {
       cin>>num[i];
   }


   sort(num+1,num+n+1);

   for(i=1;i<=(n-k+1);i++)
   {
       a=i;
       b=i+k-1;

       d=num[b]-num[a];
       mn=min(mn,d);
   }


   cout<<mn<<endl;



    return 0;

}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            c = (3 * a) + b;

            d = c / 2;

            Console.WriteLine(d);

            Console.ReadKey();





        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K; cin >> N >> K; 
	long long P = 1000000007;
	long long dp[52][52][2700] = {}; // dp[iまで見て][j個保留中で][確定済の和がk]
	dp[0][0][0] = 1; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= i; j++){
			for(int k = 0; k <= (N-1) * N; k+= 2){
				if(j){
					dp[i+1][j-1][k+2*j-2] += dp[i][j][k]*j*j; 
					dp[i+1][j-1][k+2*j-2] %= P; 
				}
				dp[i+1][j][k+2*j] += dp[i][j][k]*(2*j+1); 
				dp[i+1][j][k+2*j] %= P; 
				dp[i+1][j+1][k+2*j+2] += dp[i][j][k]; 
				dp[i+1][j+1][k+2*j+2] %= P; 
			}
		}	
	}
	cout << dp[N][0][K] << endl; 
}

Measured memory_bytes: 57344
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    p = list(map(int, input().rstrip('\n').split()))
    q = sorted(p)
    cnt = 0
    for i in range(n):
        if q[i] != p[i]:
            cnt += 1
    print("YES" if cnt <= 2 else "NO")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

result = 0
max = 0
for A in combinations_with_replacement(range(1, m+1), n):
    for i in range(q):
        a, b, c, d = abcd[i]
        if A[b-1] - A[a-1] == c:
            result += d
    if result > max:
        max = result
        reslut = 0
    result = 0

print(max)



Measured memory_bytes: 9204
#include <stdio.h>  

int main() 
{     
	int h,w;     
	int i,j;    
	while(1)
	{         
		scanf("%d %d", &h, &w);         
		if(h==0&&w==0)
		{            
			break;        
		}         
		for(i=0; i<h; i++)
		{             
			for(j=0; j<w; j++)
			{                 
				printf("#");             
			}           
			printf("\n");        
		}         
		printf("\n");    
	}    
	return 0; 
}

Measured memory_bytes: 572
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;

long n, m;

void main() {
    scan(n, m);

    auto cmb = new long[][](n + 1, n + 1);
    auto dp = new long[][](n + 1, n + 1);
    foreach (i ; 0 .. n + 1) {
        cmb[i][0] = cmb[i][i] = 1;
        dp[i][0] = dp[i][i] = 1;
    }
    foreach (i ; 0 .. n + 1) {
        foreach (j ; 1 .. i) {
            cmb[i][j] = (cmb[i-1][j] + cmb[i-1][j-1]);
            if (cmb[i][j] >= m) cmb[i][j] -= m;
            dp[i][j] = (dp[i-1][j-1] + (j + 1) * dp[i-1][j] % m);
            if (dp[i][j] >= m) dp[i][j] -= m;
        }
    }

    debug {
        //writeln(cmb);
        //writeln(dp);
    }

    auto tpm = new long[](n*n + 1);
    auto tpm1 = new long[](n*n + 1);
    tpm[0] = tpm1[0] = 1;
    foreach (i ; 1 .. n*n + 1) {
        tpm[i] = tpm[i-1] * 2 % m;
        tpm1[i] = tpm1[i-1] * 2 % (m-1);
    }

    long f(int k) {
        long res;

        foreach (x ; 0 .. k + 1) {
            //res += powmod(2, powmod(2, n - k, m - 1), m) * dp[k][x] % m * powmod(2, (n - k) * x, m) % m;
            res += powmod(2, tpm1[n - k], m) * dp[k][x] % m * tpm[(n-k)*x] % m;
            if (res >= m) res -= m;
        }

        return res;
    }

    long ans;

    foreach (int k ; 0 .. n.to!int + 1) {
        if (k & 1) {
            ans -= cmb[n][k] * f(k) % m;
            if (ans < 0) ans += m;
        }
        else {
            ans += cmb[n][k] * f(k) % m;
            if (ans >= m) ans -= m;
        }
    }

    writeln(ans);
}



// x^y % mod
long powmod(long x, long y, long mod) {
    return y > 0 ? powmod(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1L;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 289916
#include<stdio.h>
int main(void)
{
    int a,b;

    scanf("%d %d",&a,&b);

    if(a<b){
        printf("a < b\n");
    }
    else if (a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;
struct node
{
    int pre, to;
} edge[5010];
int head[2010], tot;
int n, x, y;
int cnt[2010], dis[2010];
bool vis[2010];
priority_queue<pii> q;
void dijkstra(int s)
{
    memset(vis, 0, sizeof(vis));
    memset(dis, 0x3f, sizeof(dis));
    dis[s] = 0;
    q.push(make_pair(0, s));
    while (!q.empty())
    {
        int u = q.top().second;
        q.pop();
        if (vis[u])
            continue;
        vis[u] = true;
        for (int i = head[u]; i; i = edge[i].pre)
        {
            int v = edge[i].to;
            if (dis[v] > dis[u] + 1)
            {
                dis[v] = dis[u] + 1;
                q.push(make_pair(-dis[v], v));
            }
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        if (i != s && dis[i] < inf)
            cnt[dis[i]]++;
    }
}
void add(int u, int v)
{
    edge[++tot] = node{head[u], v};
    head[u] = tot;
    edge[++tot] = node{head[v], u};
    head[v] = tot;
}
int main()
{
    scanf("%d%d%d", &n, &x, &y);
    //cin >> n >> x >> y;
    for (int i = 1; i < n; ++i)
    {
        add(i, i + 1);
        //add(i + 1, i);
    }
    add(x, y);
    //add(y, x);
    for (int i = 1; i <= n; ++i)
        dijkstra(i);
    for (int i = 1; i < n; ++i)
        printf("%d\n", cnt[i] / 2);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int h = saori.saori_hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		int num = 0;
		for(int i = 0;i < n;i++){
			a[i] = saori.saori_hayami();
			num += a[i];
		}
		if(num >= h){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23764
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n,b,a;
void solve()
{
    cin>>a>>b;
    for(ll i=1;i<=1000;i++)
    {
        if(floor(i*.08)==a&&floor(i*.1)==b)
            {ans=i;break;}
    }
    if(ans==0)
        ans=-1;
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int arr[3][101], n;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=2;i++) {
        for(int j=1;j<=n;j++) {
            int a;
            scanf("%d", &a);
            arr[i][j]=(arr[i-1][j]>arr[i][j-1])? (arr[i-1][j]+a):(arr[i][j-1]+a);
        }
    }
    printf("%d", arr[2][n]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n;
	ll a[100001];
	ll c[100001]={};
	ll d[100001]={};
	ll o=0,o2=0;
	ll total=0;

	cin>>n;

	for(int i=0; i<n; ++i){
		cin>>a[i];
	}
	sort(a, a + n, greater<ll>());

	if(n%2==0){
		for(int j=0; j<n/2; ++j){
			o+=a[j]*2;
		}
		for(int k=n/2; k<n; ++k){
			o-=a[k]*2;
		}
		o=o-a[n/2-1]+a[n/2];
	}
	if(n%2>0){
		for(int j=0; j<n/2; ++j){
			o+=a[j]*2;
		}
		for(int k=n/2; k<n; ++k){
			o-=a[k]*2;
		}
		o=o+a[n/2]+a[n/2+1];
		for(int j=0; j<n/2+1; ++j){
			o2+=a[j]*2;
		}
		for(int k=n/2+1; k<n; ++k){
			o2-=a[k]*2;
		}
		o2=o2-a[n/2-1]-a[n/2];
		o=max(o,o2);
	}
	cout<<o<<endl;

	return 0;

}


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

int main()
{
  int H, N, A[110000], sum=0;
  cin >> H >> N;
  for(int i=0; i<N; ++i)
  {
    cin >> A[i];
    sum += A[i];
  }
  if(sum >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int A;
 int B;
 cin>>A;
 cin>>B;
  for (int i=1; i<1010; i++){
    if ((int)(0.08*i)==A && (int)(0.1*i)==B){
     cout<<i;
     exit(0);
    }
  }
 cout<<-1;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef vector<int> vi;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int A,B,C,X,Y;
vi a,b,c;
priority_queue<int,vector<int>,greater<int> > pq;
int buf;
int main(){
	ios::sync_with_stdio(false);
	cin>>X>>Y>>A>>B>>C;
	REP(i,A){
		cin>>buf;a.pb(buf);
	}
	REP(i,B){
		cin>>buf;b.pb(buf);
	}
	REP(i,C){
		cin>>buf;c.pb(buf);
	}
	c.pb(0);
	sort(all(a));sort(all(b));sort(all(c));
	reverse(all(a));reverse(all(b));
	rep(i,X) pq.push(a[i]);
	rep(i,Y) pq.push(b[i]);
	while(c.back()>pq.top()){
		pq.pop();pq.push(c.back());c.pop_back();
	}
	ll ans=0;
	while(!pq.empty()){
		ans+=pq.top();pq.pop();
	}
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 2552
#include <stdio.h>

int main(void){
  long long n,k,a[200005],x=1000000000,c=0,count=0,max=0;
  scanf("%lld %lld",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
    if(max<a[i]) max=a[i];
  }
  long long d=max+10;
  while(d-c>1){
    x=(d+c)/2;
    for(int i=0;i<n;i++){
      count+=(a[i]-0.001)/x;
        }
    if(count>k) c=x;
    else d=x;
    count=0;
  }
  printf("%lld",d);
  return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <list>
using namespace std;


int main() {
    int q ,x;
    char com[20];
    list <int> v;
    scanf("%d", &q);
    for(int i=0; i<q; i++) {
        scanf("%s", com);
        if(com[0]== 'i') {
            scanf("%d", &x);
            v.push_front(x);
        } else if(com[6] == 'L') {
            v.pop_back();
        } else if(com[6] == 'F') {
            v.pop_front();
        } else if(com[0] == 'd') {
            scanf("%d", &x);
            for( list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if(*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for( list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if(i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 34436
#include <stdio.h>

int chmax(int a,int b){
  //b -> max
  if(a > b){b = a;}
  return b;
}

int main(){
  int n;
  scanf("%d",&n);
  int a[n][3],dp[n+1][3];
  for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
      scanf("%d",&a[i][j]);
      dp[0][j] = 0;
      dp[i+1][j] = 0;
    }
  }
  
  for(int i=1; i<=n; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(j != k){
          dp[i][j] = chmax(dp[i][j], dp[i-1][k] + a[i-1][j]);
        }
      }
    }
  }
  
  printf("%d",chmax(dp[n][0],chmax(dp[n][1],dp[n][2])));
  
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		int[] t = new int[n+1];
		int i;
		t[0]=0;
		for(i=1; i<n; i++) {
			t[i] = t[i-1] + ((s.charAt(i-1) == 'A' && s.charAt(i) == 'C')?1:0); 
		}
		t[i] = t[i-1];
		int l,r;
		for(i=0; i<q; i++) {
			l=sc.nextInt();
			r=sc.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}
	}
}


Measured memory_bytes: 69508
N=int(input())

sum=0
for i in range(1,N+1):
    sum+=i
    if sum==N:
        for i in range(1,i+1):
            print(i)
        exit()
    elif sum>N:
        for j in range(1,i+1):
            if not j==(i*(i+1)//2)-N:
                print(j)
        exit()




Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b;
  cin >> a >> b;
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
h = [int(x) for x in input().split(" ")]
INF = 10**9
dp = [INF] * n
dp[0] = 0

for i in range(1,n):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if (i > 1):
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

Measured memory_bytes: 13924
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
	int K, X;
	scanf("%d %d", &K, &X);

	int Y = 500*K;
	if( Y>=X ) {printf("Yes\n");}
	else{ printf("No\n");}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N), B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    reverse(all(A)), reverse(all(B));

    ll ans = 0;
    rep(i,N){
        ll a = A[i], b = B[i];
        a += ans;
        ans += (b - (a % b)) % b;
    }
    cout << ans << endl;
}

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

int main(){
	long long a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(c-a-b<0){
		printf("No\n");return 0;
	}
	if(4*a*b<(c-a-b)*(c-a-b)){
		printf("Yes\n");
	}else printf("No\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#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 fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
    ll x;
    cin >> x;
    ll p=100;
    for(int i=1;i<=4000;i++) {
        ll ans = (ll)(1.0*p*powl(1.01,1.0)); 
        if(ans>=x){
            cout << i <<nl;
            return;
        }
        else{
            p = ans;
        }
    }
    
}

signed main() {
    boost;
    solve();
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
string S;

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

	cin >> S;
	N = S.size();
	string T = S;
	reverse(ALL(T));

	FOR(i,0,N){
		if(T [i] == 'b'){
			T [i] = 'd';
		}
		else if(T [i] == 'd'){
			T [i] = 'b';
		}
		else if(T [i] == 'p'){
			T [i] = 'q';
		}
		else if(T [i] == 'q'){
			T [i] = 'p';
		}
	}

	cout << (S == T ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, n;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			n = a + b;
			if (a - b > n)
				n = a - b;
			if (a * b > n)
				n = a * b;
				Console.WriteLine(n);

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 13140
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

#define int long long
const int N = (int) 1e6 + 6, mod = (int) 0;
vector<int> ver, adj[N];
int col[N], mark[N];
int dfs(int v, int c = 1) {
	if (mark[v]) {
		if (col[v] != c) return 0;
		return 1;
	}
	ver.push_back(v);
	mark[v] = 1;
	col[v] = c;
	int res = 1;
	for (int u : adj[v]) {
		res &= dfs(u, 3 - c);	
	}
	return res;
}
int32_t main() {
	ios_base::sync_with_stdio(0);
	int n, m, all = 0;
	cin >> n >> m;
	for (int j = 0; j < m; ++j) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int v = 0; v < n; ++v) if (!mark[v]) {
		ver.clear();
		int bi = dfs(v);
		if (bi) {
			int p0 = 0, p1 = 0;
			for (int x : ver) if (col[x] == 1) ++p0;
			for (int x : ver) if (col[x] == 2) ++p1;
			all += p0 * p1;
		} else {
			int cnt = 0;
			for (int x : ver) ++cnt;
			all += cnt * (cnt - 1) / 2;
		}
	}
	cout << all - m << endl;
}






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

int main(void){
  int N;
  int D[101];
  ll dp[101][21];
  for(int i=0; i < 101; i++){
    for(int j=0; j < 21; j++){
      dp[i][j] = 0;
    }
  }
  cin >> N;
  for(int i=0; i < N; i++){
    cin >> D[i];
  }
  dp[0][D[0]] = 1;
  for(int i=0; i < N-1; i++){
    for(int j=0; j < 21; j++){
      if(dp[i][j] == 0) continue;
      if(j+D[i+1] >= 0 && j+D[i+1] <= 20) dp[i+1][j+D[i+1]] += dp[i][j];
      if(j-D[i+1] >= 0 && j-D[i+1] <= 20) dp[i+1][j-D[i+1]] += dp[i][j];
    }
  }
  cout << dp[N-2][D[N-1]] << endl;

  return 0;
}

Measured memory_bytes: 1172
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    h, w = MI()
    s = [input() for _ in range(h)]
    table = [[0]*(w+2) for _ in range(h+2)]
    for i in range(1, h+1):
        for j in range(1, w+1):
            table[i][j] = s[i-1][j-1]
    for i in range(1, h+1):
        for j in range(1, w+1):
            if table[i][j] == '#':
                print('#', end='')
                continue
            cnt = 0
            for k in range(i-1, i+2):
                for l in range(j-1, j+2):
                    if table[k][l] == '#':
                        cnt += 1
            print(cnt, end='')
        print()

if __name__ == '__main__':
    main()

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

int main(int argc, char const *argv[])
{
	int	a,b,c;
	cin>>a>>b>>c;
	if (a+b>=c)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> PII;
typedef pair<ll,ll> Pll;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef pair<ll,ll>P;
#define N  1000000+10
#define M  4000000+10
#define INF 1e9
#define fi first
#define se second
#define MP make_pair
#define pb push_back
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define per(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define lowbit(x) x&(-x)
#define Rand (rand()*(1<<16)+rand())
#define id(x) ((x)<=B?(x):m-n/(x)+1)
#define ls p<<1
#define rs p<<1|1
#define fors(i) for(auto i:e[x]) if(i!=p)

const int MOD=1e9+7,inv2=(MOD+1)/2;
int dx[4]= {-1,1,0,0};
int dy[4]= {0,0,-1,1};



int read()
{
  int v=0,f=1;
  char c=getchar();
  while(c<48||57<c)
  {
    if(c=='-') f=-1;
    c=getchar();
  }
  while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
  return v*f;
}

ll readll()
{
  ll v=0,f=1;
  char c=getchar();
  while(c<48||57<c)
  {
    if(c=='-') f=-1;
    c=getchar();
  }
  while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
  return v*f;
}

int main()
{

char a;
cin>>a;
printf("%c",a+1);

}


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

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int cnt = 0;
        int plugs = 1;
        while (plugs < b) {
            cnt++;
            plugs += a - 1;
        }
        System.out.println(cnt);
    }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int n;
string s;
int cnt1[222222];
int cnt2[222222];

signed main() {
  cin >> n >> s;

  rep (i, n) {
    if (s[i] == '#') {
      cnt1[i] = 1;
    }
  }
  repp (i, 1, n) {
    cnt1[i] += cnt1[i-1];
  }

  for (int i = n-1; i >= 0; i--) {
    if (s[i] == '.') {
      cnt2[i] = 1;
    }
  }
   for (int i = n-2; i >= 0; i--) {
     cnt2[i] += cnt2[i+1];
  }

  int ans = 1e18;
  rep (i, n) {
    chmin(ans, cnt1[i] + cnt2[i]);
  }

  cout << ans-1 << endl;

  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(c>(a+b)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n,m;
    cin >> n >> m;
    int a[m];

    rep(i,m) cin >> a[i];

    ll sum = 0;

    for(int i=0;i<m;i++){
        sum+=a[i];
    }

    if(sum>n){
        cout << -1 << endl;
    }else{
        cout << n-sum << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> vs;
#define REP(i,n) for (int i=0; i<n; i++)
string A2Z="abcdefghijklmnopqrstuvwxyz";
struct affine_key{
	int a;
	int b;
};

string decode(string &L1, string &L2, string &msg){
	int n=msg.size();
	string s="";
	REP(i,n){
		char c=msg[i];
		if (c>='a' && c<='z'){
			string::size_type index=L1.find(c);
			s += L2[index];
		}else
			s += c;
	}
	return s;
}

string affine(string &msg, affine_key &key){
	string s="", s2;
	REP(i,26){
		int it=(i*key.a+key.b+26)%26;
		s += A2Z[it];
	}
	return decode(A2Z, s, msg);
}

string rot(string &msg, int a){
	if (a==0) return msg;
	while (a<0)
		a+= 26;
	a %= 26;
	string s = A2Z.substr(a)+A2Z.substr(0,a);
	return decode(A2Z, s, msg);
}

affine_key find(string &msg){
	char c0='t';
	affine_key key;
	for (int i=1; i<26; i+=2){
			key.a=i;
			key.b=0;
		string x=affine(msg, key);
		int a = c0-x[0];
		if (a<0) a += 26;
		x = rot(x,a);
		if (x=="this" || x=="that"){
			key.b=a;
			return key;
		}
	}
	key.a=-1;
	key.b=-1;
	return key;
}

vs split(const string &text, char delim=' '){
    int p1 = 0, p2 = 0;
    vs tokens;
 
    for (int i=0; i<(int)text.size(); i++)
        if (text[i] == delim){
            p2 = i;
            tokens.push_back(text.substr(p1, p2 - p1));
            p1 = p2 + 1;
        }
    tokens.push_back(text.substr(p1));
    return tokens;
}

int main(void){
	int n;
	string msg;
	cin>>n;
	getline(cin, msg);
	REP(i,n){
		getline(cin, msg);
		vs word = split(msg);
		affine_key key;
		REP(i, word.size())
			if (word[i].size()==4){
				key = find(word[i]);
				if (key.a != -1) break;
			}
			cout<<affine(msg, key)<<endl;
	}
}

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



int main() {
  int n;
  cin >> n;
  vector<int> b(n-1);
  for (int i = 0; i < n-1; i++) {
    cin >> b.at(i);
  }

  vector<int> a(n);
  a.at(0) = b.at(0);
  if (n > 2) {
    for (int i = 1; i < n-1; i++) {
      a.at(i) = min(b.at(i-1), b.at(i));
    }
  }
  a.at(n-1) = b.at(n-2);

  int ans = 0;
  for (int x: a) {
    ans += x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, W = map(int, input().split())

import numpy as np
MAX = 10**5 + 1
dp = [np.full(MAX, 10**13) for i in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    w, v = map(int, input().split())
    dp[i][:v] = dp[i-1][:v]
    dp[i][v:] = np.minimum(dp[i-1][v:], dp[i-1][:-v] + w)

ans = np.where(dp[N] <= W)[0].max()

print(ans)


Measured memory_bytes: 93268
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a;
  int b = 0;
  for(a=0;a<s.size()/2;a++){
    if(s.at(a)!=s.at(s.size()-1-a)){
      b++;
    }
  }
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	l := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(l)))

	ret := 0
	for i := 0; i < k; i++ {
		ret += l[i]
	}

	fmt.Println(ret)

}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>

int main(void){
	 double x1, y1, x2, y2, x3, y3;
	 double px, py;
	 double s, ps1, ps2, ps3;
	 double ep = 0.0001;

	 while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &px, &py) != EOF){
		 s = fabs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2.0;
		 ps1 = fabs(x1*(y2-py)+x2*(py-y1)+px*(y1-y2))/2.0;
		 ps2 = fabs(px*(y2-y3)+x2*(y3-py)+x3*(py-y2))/2.0;
		 ps3 = fabs(x1*(py-y3)+px*(y3-y1)+x3*(y1-py))/2.0;

		 
		 if(fabs((s-(ps1+ps2+ps3)))<ep){
			 printf("YES\n");
		 }else{
			 printf("NO\n");
		 }
	 }

	 return 0;
}

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

int main(){
    int a ;
    cin >> a ;
    cout << a*a*a + a*a + a << endl ;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vi C;
    int ctemp = 0, ctemp2;
    rep(i, N)
    {
        ctemp2 = ctemp;
        scanf("%d", &ctemp);
        if(ctemp2 != ctemp)
            C.push_back(ctemp);
    }
    int L = C.size();
    vll mp(200001, 0);
    ll anstemp = 0;
    ll ans = 0;
    rep(i, L)
    {
        if (i >= 2)
        {
            anstemp = (ans + mp.at(C.at(i))) % MOD;
            ans = anstemp;
            mp.at(C.at(i)) = anstemp;
        }
        else
        {
            ans = 1;
            mp.at(C.at(i)) = 1;
        }
    }
    std::cout << ans << endl;
}

Measured memory_bytes: 2676
n, m = map(int, input().split())

a = []
b = []

for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(m):
    b.append(int(input()))

for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)



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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;


template< class T >
std::vector< int > slideMaximum(const std::vector< T > &a, int k)
{
  int n = a.size();
  std::deque< int > deq;
  std::vector< int > res;
  for(int i = 0; i < n; i++) {
    while(deq.size() && a[deq.back()] <= a[i]) deq.pop_back();
    deq.push_back(i);
    res.push_back(deq.front());
    if(i - k + 1 >= 0) {
      if(deq.front() == i - k + 1) deq.pop_front();
    }
  }
  return res;
}


int main()
{
  int64 N, M, K, A[100000];

  cin >> N >> M >> K;
  for(int i = 0; i < N; i++) cin >> A[i];
  // dp[k][idx] := dp[k-1][j(idx-j<M)]+A_idx*k

  vector< int64 > dp1(N, 0);
  for(int i = 0; i < N; i++) dp1[i] = A[i];

  for(int i = 2; i <= K; i++) {
    vector< int64 > dp2(N, 0);
    auto dp = slideMaximum(dp1, M);
    for(int j = i - 1; j < N; j++) {
      dp2[j] = max(dp2[j], dp1[dp[j - 1]] + i * A[j]);
    }
    dp1.swap(dp2);
  }
  cout << *max_element(begin(dp1), end(dp1)) << endl;
}

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

vector < int > v[55];

int main(){

  int n, m, a, b;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  int cnt = 0;
  for(int j=0;j<10;j++){
    for(int i=1;i<=n;i++){
      //cout << i << " " << v[i].size() << endl;
      if(v[i].size() == 1){
	v[v[i][0]].erase(remove(v[v[i][0]].begin(), v[v[i][0]].end(), i), v[v[i][0]].end());
	v[i].erase(v[i].begin(), v[i].end());
	cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<deque>
#include<array>


#define REP(i,a,b) for(int i = (a); i < b; ++i)
#define inf 1e9+10
#define MOD 1000000007

using ll = long long;
using ull = unsigned long long;
using namespace std;

inline ll modpow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

inline ll mod(ll val, ll m) {
	ll res = val % m;
	if (res < 0) res += m;
	return res;
}


int main() {
	string s;

	cin >> s;

	if (s[s.size() - 1] == 's') {
		cout << s << "es";
	}
	else {
		cout << s << "s";
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int A, B;
	cin >> A >> B;

	int H = 100;
	int W = 100;

	vector<string> board(H, string(W, '.'));

	board[0] = string(W, '#');
	board[H - 1] = string(W, '.');
	string str = "";
	rep(x, W) str += x % 2 ? '.' : '#';
	REP(y, 1, H - 2) board[y] = str;

	int px = 1;
	int py = 2;

	A--;
	while (A) {
		A--;
		board[py][px] = '#';
		py += 2;
		if (py >= H - 1) {
			py = 2;
			px += 2;
		}
	}

	px = W - 2;
	py = H - 3;

	B--;
	while (B) {
		B--;
		board[py][px] = '.';
		py -= 2;
		if (py <= 0) {
			py = H - 3;
			px -= 2;
		}
	}

	cout << "100 100" << endl;
	rep(y, H) cout << board[y] << endl;


    return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b && b!=c){
        cout << "Yes" <<endl;
    }
    else if(b==c && a!=c){
        cout << "Yes" << endl;
    }
    else if(a==c && a!=b){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[100100],y[100100],h[100100],g[100100];
ll aa[110][110];
string s,str;
int main(){
  cin>>n;
  for(int i=-180;i<180;i++){
    for(int j=-180;j<180;j++){
      a=pow(i,5);
      b=pow(j,5);
      if(a-b==n){
        cout<<i<<" "<<j;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4104
s = input()
if(s == s[::-1] and s[:len(s) // 2] == s[:len(s) // 2][::-1] and s[(len(s) // 2) + 1:] == s[(len(s) // 2) + 1 : ][::-1]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y;
  cin>>x>>y;
  cout<<x+y/2<<endl;

  return 0;

}


Measured memory_bytes: 256
str = input()
ipt = list(map(lambda x: int(x), str.split()))
ipt.sort()
if ipt[0]==ipt[1] and ipt[1]==ipt[2]:
  print('No')
elif ipt[0]==ipt[1] or ipt[1]==ipt[2]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38256
a, b, c, x, y = map(int, input().split())
ans = a*x + b*y

if x < y:
    ans = min(ans, 2*c*x + b*(y - x))
else:
    ans = min(ans, 2*c*y + a*(x - y))

ans = min(ans, 2*c*max(x, y))

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>

int main(){
    int n,max = 0,count = 1;
    scanf("%d",&n);
    int a[n];
    for(int i = 0;i < n;i++){
        scanf("%d",&a[i]);
    }
    max = a[0];
    for(int i = 1;i < n;i++){
        if(max <= a[i]){
            count++;
            max = a[i];
        }
    }
    printf("%d\n",count);
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll X;
  cin>>X;
  ll now=100;
  for(int i=0;i<4000;i++){
    if(now>=X){
      cout<<i<<endl;
      return 0;
    }
    now+=now*0.01;
  }
  return 0;
}


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

int n, m, Q, X[509][509], C[509][509];

int main() {
	cin >> n >> m >> Q;
	rep(i, m) {
		int l, r;
		cin >> l >> r; 
        X[l][r]++;
	}

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
            C[i][j] = C[i][j-1] + X[i][j];
        }
	}

	rep(roop, Q) {
		int p, q; 
        cin >> p >> q;

		int ans = 0;
		for(int i = p; i <= q; i++) { 
            ans += C[i][q] - C[i][p-1];
        }

		cout << ans << endl;
	}

	return 0;
}

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

int main(){
	int n,f[10],flag;
	while (cin >> n){
		flag = 0;
		for (int i = 0; i < 10; i++) f[i] = 0;
		for (int i = 0; n; i++){
			f[i] = n % 2;
			n /= 2;
		}
		for (int i = 0; i < 10; i++){
			if (f[i]) {
				if(!flag){
					cout << (int)pow(2.0, i);
					flag = 1;
				}
				else cout << " " << (int)pow(2.0, i);
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
using namespace std;
 
#define LL long long 
#define ULL unsigned long long 
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	double t[n];
	for(int i=0; i<n; i++)
		cin>>t[i];
	sort(t, t+n);
	double w = (t[0]+t[1]) / (double) 2;
	for(int i=2; i<n; i++) {
		w = (w + t[i]) / (double) 2;
	}
	printf("%.10f", w);	
}


Measured memory_bytes: 256
//abc092_a.cpp
//Sun Mar 25 20:59:52 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	int a;
	int b;
	int c;
	int d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	int train = 0;
	int bus = 0;
	if(a<b){
		train = a;
	}else{
		train = b;
	}
	if(c<d){
		bus = c;
	}else{
		bus = d;
	}
	cout << train+bus<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,i,a1,b1;
    scanf("%d%d",&a,&b);
    for(i=2;i<1010;i++){
        a1=i*8/100;
        b1=i*10/100;
        if(a1==a && b1==b){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}

Measured memory_bytes: 128