akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int l, r;
	std::cin >> l >> r;
	int result = 2019;
	int temp;


	for ( int i = l; i < r; i++) {
		for (long int j = i + 1; j <= r; j++) {
			temp = i * j % 2019;
			if (temp == 0) {
				std::cout << 0 << std::endl;
				return 0;
			}
			else if (result > temp) {
				result = temp;
			}
		}
	}

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n, m, l;
		n = scan.nextInt();
		m = scan.nextInt();
		l = scan.nextInt();
		int[][] matA = new int[n][m];
		int[][] matB = new int[m][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				matA[i][j] = scan.nextInt();
			}
		}
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < l; k++) {
				matB[j][k] = scan.nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			for (int k = 0; k < l; k++) {
				long c = 0;
				for (int j = 0; j < m; j++) {
					c += matA[i][j] * matB[j][k];
				}
				if (k != l - 1) {
					sb.append(c).append(" ");
				} else {
					sb.append(c).append("\n");
				}
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 49964
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n), b(n); rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	int sum = 0;
	int sum2 = 0;
	rep(i, n) {
		if (a[i] < b[i]) {
			sum += b[i] - a[i];
		}
		else {
			sum2 += a[i] - b[i];
		}
	}
	if (sum > sum2) {
		cout << -1 << endl; return 0;
	}
	int ans = sum;
	vector<int>tmp;
	int now = 0;
	rep(i, n) {
		if (a[i] >= b[i]) {
			tmp.push_back(a[i] - b[i]);
		}
		else {
			now++;
		}
	}
	sort(ALLR(tmp));
	int cnt = 0;
	rep(i, tmp.size()) {
		if (ans <= 0)break;
		else {
			ans -= tmp[i]; cnt++;
		}
	}
	cout << now + cnt << endl;
	return 0;
}

Measured memory_bytes: 2936
def isPrime(n):
    if n == 0 or n == 1:
        return 0
    for i in range(2, n):
        if i * i > n:
            return 1
        if n % i == 0:
            return 0
    return 1
        
N = 100010
cnt = [0] * N

for x in range(1, N):
    cnt[x] = cnt[x-1] + (isPrime(x) and isPrime((x + 1) // 2))

Q = int(input())
for i in range(Q):
    l, r = list(map(int, input().split()))
    ans = cnt[r] - cnt[l-1]
    print(ans)



Measured memory_bytes: 6408
program cake_123
  implicit none
  integer :: x, y, z, k, p, q, r, i
  integer(8) :: a(1000), b(1000), c(1000), d(106307)
  integer :: u, v, w
  a = 0_8
  b = 0_8
  c = 0_8
  d = 0_8
  read(*,*) x, y, z, k
  read(*,*) a(1:x)
  read(*,*) b(1:y)
  read(*,*) c(1:z)
  call merge_sort(x,a(1:x))
  call merge_sort(y,b(1:y))
  call merge_sort(z,c(1:z))
  i = 1
  do p = 1, x
    if (p.gt.k) exit
    do q = 1, y
      if (p*q.gt.k) exit
      do r = 1, z
        if (p*q*r.gt.k) exit
        d(i) = a(p)+b(q)+c(r)
        i = i + 1
      end do
    end do
  end do
  call merge_sort(106307,d)
  do i = 1, k
    write(*,'(i0)') d(i)
  end do
contains
  subroutine merge_sort(n,c)
    implicit none
    integer, intent(in)       :: n
    integer(8), intent(inout) :: c(n)
    integer                   :: num, gth, i, ubnd
    num = n
    gth = 1
    do while (num.gt.1)
      do i = 1, num/2
        ubnd = min(2*i*gth,n)
        call merge(c(2*(i-1)*gth+1:(2*i-1)*gth),c((2*i-1)*gth+1:ubnd))
      end do
      gth = 2*gth
      num = (num+1)/2
    end do
    return
  end subroutine merge_sort
  subroutine merge(c1,c2)
    implicit none
    integer(8), intent(inout) :: c1(:), c2(:)
    integer(8)                :: c(size(c1)+size(c2))
    integer                   :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1)
    n2 = size(c2)
    do while (i1.le.n1.and.i2.le.n2)
      if (c1(i1).ge.c2(i2)) then
        c(i1+i2-1) = c1(i1)
        i1 = i1+1
      else
        c(i1+i2-1) = c2(i2)
        i2 = i2+1
      end if
    end do
    if (i1.le.n1) then
      c(i1+i2-1:n1+n2) = c1(i1:n1)
    else if (i2.le.n2) then
      c(i1+i2-1:n1+n2) = c2(i2:n2)
    end if
    c1 = c(1:n1)
    c2 = c(n1+1:n1+n2)
    return
  end subroutine merge
end program cake_123

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n,m,a[N],tot,head[N],nex[N<<1],to[N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)
    {
        int u,v;scanf("%d%d",&u,&v);add(u,v);add(v,u);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        bool flag=true;
        for(int j=head[i];j;j=nex[j])
        {
            if(a[to[j]]>=a[i]) flag=false;
        }
        ans+=flag;
    }
    printf("%d\n",ans);
}


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

int main() {
    int x;
    std::cin >> x;

    int ans = 0;
    long long sum = 0;
    while (1) {
        if(x <= sum) {
            break;
        }

        ans++;
        sum += ans;
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int a,b,c;
cin>>a>>b>>c;
int i=0;
int k;
cin>>k;

while(b<=a)
{
	b=b*2;
	k--;
}
while(c<=b)
{
	c*=2;
	k--;
}
if(k>=0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 3600
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int x = (int)(n/1.08);
    if((x*1.08-n)==0){
      System.out.println(x);
    }
    else if(((x+1)*1.08-n)<1){
      System.out.println(++x);
    }
    else{
      System.out.println(":(");
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    if(s=="AAA"||s=="BBB") cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
tbl = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]



n = int(input())
for i in range(n):
	b,f,r,v =map(int,input().split())
	tbl[b-1][f-1][r-1]+=v



for k in range(4):
	for j in range(3):
		for i in range(10):
			print(f' {tbl[k][j][i]}',end="")
		print()
	if k<3:	
		print("#"*20)





Measured memory_bytes: 5636
#include<iostream>
using namespace std;
int main()
{
	int s;
	cin>>s;
	for(int i=1;i<=3;i++)
	{
		if(s%10==s/10%10)
		{
			cout<<"Bad";
			return 0;
		}
		s=s/10;
	}
	cout<<"Good";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n;
vector< vector<int> > comps;
vector< pair<int, int> > edges;

int main() { 

  cin >> n;

  if (n & 1) {
    comps.push_back({n});
    n--;
  }
  for (int i = 1; i <= n / 2; i++) {
    comps.push_back({i, n - i + 1});
  }

  for (int i = 0; i < sz(comps); i++) {
    for (int v : comps[i]) {
      for (int j = i + 1; j < sz(comps); j++) {
        if (i == j) {
          continue;
        }
        for (int to : comps[j]) {
          edges.push_back({v, to});
        }
      }
    }
  }

  printf("%d\n", sz(edges));
  for (auto edge : edges) {
    printf("%d %d\n", edge.first, edge.second);
  }

  return 0;
}


Measured memory_bytes: 384
#2問目
AC = 0
WA = 0
TLE = 0
RE = 0
N = int(input())
for i in range(N):
    s = input()
    if s == "AC":
        AC += 1
    elif s == "WA":
        WA +=1 
    elif s == "TLE":
        TLE += 1
    else:
        RE += 1
print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)

Measured memory_bytes: 69780
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
int main()
{
	
	ll n;
	cin>>n;
	ll a[n+2];
	ll h[n+1];
	f(n+1)
	{
		cin>>a[i];
	}
	f(n)
	{
		cin>>h[i];
	}
	ll c=0;
	f(n)
	{
		if(a[i]>=h[i])
		{
			c=c+h[i];
		}
		else if(a[i]<h[i])
		{
			if(a[i+1]>=(h[i]-a[i]))
			{
				a[i+1]=a[i+1]-(h[i]-a[i]);
				c=c+h[i];
			}
			else if(a[i+1]<(h[i]-a[i]))
			{
				
				c+=a[i+1]+a[i];
				a[i+1]=0;
			}
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 1792
import math

n, d = map(int, input().split())
x = [[0] * d for _ in range(n)]
for i in range(n):
    line = input().split()
    for li in enumerate(line):
        x[i][li[0]] = int(line[li[0]])

ans = 0

for i in range(0, n):
    for j in range(i, n):
        dis = 0
        for k in range(d):
            dis += (x[i][k] - x[j][k]) ** 2
        if not dis == 0:
            if math.sqrt(dis).is_integer():
                ans += 1
        #print(i, j, dis, ans)
print(ans)

Measured memory_bytes: 3064
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7000
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) cout << a * b << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int x;
  cin >> x;
  int a[1520] = {0};
 
  a[1] = 1;
  rep(i,2,34){
    for(int j = i*i;j <= 1010;j = j*i){
      a[j] = 1;
      
    }
  }
  
  for(int i = x;i >= 1;i--){
    if(a[i] == 1){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){


int W,H,x,y,r;


scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);


if(H>=y+r&&W>=x+r&&x-r>=0&&y-r>=0){


printf("Yes\n");


}


else{


printf("No\n");


}


return 0;


}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <array>
using namespace std;
typedef long long ll;

int main(int argc,char const* argv[])
{
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;

  for(int i=sy;i<ty;i++)
    {
      cout << 'U';
    }
  for(int i=sx;i<tx;i++)
    {
      cout << 'R';
    }
  for(int i=sy;i<ty;i++)
    {
      cout << 'D';
    }
  for(int i=sx;i<tx+1;i++)
    {
      cout << 'L';
    }
  for(int i=sy;i<ty+1;i++)
    {
      cout << 'U';
    }
  for(int i=sx-1;i<tx;i++)
    {
      cout << 'R';
    }
  cout << 'D';
  cout << 'R';
  for(int i=sy;i<ty+1;i++)
    {
      cout << 'D';
    }
  for(int i=sx;i<tx+1;i++)
    {
      cout << 'L';
    }
  cout <<'U' << endl;
  return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> resultList = new List<string>();
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n;i++)
            {
                string[] array = Console.ReadLine().Split(' ');
                if (double.Parse(array[2]) - double.Parse(array[0]) == 0)
                {
                    if (double.Parse(array[6]) - double.Parse(array[4]) == 0)
                    {
                        resultList.Add("YES");
                    }
                    else
                    {
                        resultList.Add("NO");
                    }
                }
                else if (double.Parse(array[6]) - double.Parse(array[4]) == 0)
                {
                    resultList.Add("NO");
                }
                else
                {
                    double ab = (double.Parse(array[3]) - double.Parse(array[1])) / (double.Parse(array[2]) - double.Parse(array[0]));
                    double cd = (double.Parse(array[7]) - double.Parse(array[5])) / (double.Parse(array[6]) - double.Parse(array[4]));
                    if (ab == cd)
                    {
                        resultList.Add("YES");
                    }
                    else
                    {
                        resultList.Add("NO");
                    }
                }
            }

            foreach(string s in resultList){
                Console.WriteLine(s);
            }

        }


    }
}

Measured memory_bytes: 5684
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    rep(i, N) cin >> v[i] >> w[i];
    vector<vector<int>> dp(105, vector<int>(10010, 0));
    rep(i, N) rep(j, W + 1) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        if(j + w[i] > W) continue;
        dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i][j] + v[i]);
    }
    int ans = 0;
    rep(i, N) rep(j, W + 1) ans = max(ans, dp[i][j]);
    cout << ans << endl;
}



Measured memory_bytes: 11068
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

class UnionFind{
  public: 
    vector<int> par;
    
    UnionFind(int N):par(N){
      for(int i=0;i<N;i++) par[i]=i;
    }

    int root(int x){
      return par[x]==x?x:par[x]=root(par[x]);
    }

    void unite(int x,int y){
      int rx=root(x);
      int ry=root(y);
      if(rx!=ry) par[rx]=ry;
    }

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

int main(){
  int N,M; cin>>N>>M;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    int temp; cin>>temp;
    p[i]=temp-1;
  }

  UnionFind tree(N);
  for(int i=0;i<M;i++){
    int x,y; cin>>x>>y;
    tree.unite(x-1,y-1);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(tree.same(i,p[i])) ans++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,s;

signed main(){
    cin>>n>>s;
    for(int i=2;i*i<=n;i++){
        int tmp=n,sum=0;
        while(tmp){
            sum+=tmp%i;
            tmp/=i;
        }
        if(sum==s){
            cout<<i<<endl;
            return 0;
        }
    }
    // n/b + n%b = s
    // n = n/b*b + n%b
    // n - s = n/b*(b-1)
    // let n/b = i
    for(int i=(int)sqrt(n);i>0;i--){
        if(i*i>=n)continue;
        if((n-s)%i==0){
            int b=(n-s)/i+1;
            if(b>1&&n/b==i){
                cout<<b<<endl;
                return 0;
            }
        }
    }
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

int main()
{
    ins(N);ins(W);
    VI v(N),w(N);
    rep(i,N){
        in(v.at(i));in(w.at(i));
    }

    int dp[101][10001];

    rep(i,100){
        rep(j,10000){
            dp[i][j]=0;
        }
    }

    rep(i,N){
        rep(j,W+1){
            if (j>=w[i]){
                dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    print(dp[N][W]);
    return 0;
}



Measured memory_bytes: 7040
if __name__ == "__main__":
    n, a, b = list(map(int, input().split()))

    ans = 0

    if b >= a and n > 2:
        ans = (n - 2) * b - (n - 2) * a + 1
    elif n == 1 and a == b:
        ans = 1
    elif n == 2 and b >= a:
        ans = 1

    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

typedef struct Edge {
    ll to, cost;
    Edge(){}
    Edge(ll to, ll cost):to(to),cost(cost){}
} Edge;

int main(int argc, char const *argv[]) {
    ll n,m,l; cin>>n>>m>>l;
    vector<vector<Edge>> g(n);
    rep(i,m) {
        ll a,b,c; cin>>a>>b>>c;
        if (c>l) continue;
        --a,--b;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }

    vector<vector<P>> ans(n);

    auto dijkstra = [&](int s) {
        vector<bool> vi(n,false);
        // P(cost, fuel)
        vector<P> dp(n,P(INF,l));
        dp[s] = P(0,0);
        rep(i,n) {
            P mini = P(INF,l);
            int node = 0;
            rep(j,n) {
                if (vi[j]) continue;
                if (mini > dp[j]) {
                    mini = dp[j];
                    node = j;
                }
            }
            vi[node] = true;
            for (auto &&nxt: g[node]) {
                P cost;
                if (nxt.cost+dp[node].second > l) {
                    cost.first = dp[node].first+1;
                    cost.second = nxt.cost;
                }
                else {
                    cost.first = dp[node].first;
                    cost.second = dp[node].second+nxt.cost;
                }
                if (dp[nxt.to] > cost) {
                    dp[nxt.to] = cost;
                }
            }
        }
        ans[s] = dp;
        return;
    };

    rep(i,n) {
        dijkstra(i);
    }

    int q; cin>>q;
    rep(i,q) {
        int s,t; cin>>s>>t;
        --s,--t;
        if (ans[s][t].first == INF) cout << -1 << '\n';
        else cout << ans[s][t].first << '\n';
    }

    return 0;
}

Measured memory_bytes: 4352
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var w = int.Parse(Console.ReadLine().Trim());
            if (w == -1) break;
            var ret = 1150;
            if (w > 30) ret += (w - 30) * 160 + 2650;
            else if (w > 20) ret += (w - 20) * 140 + 1250;
            else if (w > 10) ret += (w - 10) * 125;
            Console.WriteLine(4280 - ret);
        }
    }
}


Measured memory_bytes: 9164
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, d: "List[int]"):

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += d[i]*d[j]
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)


if __name__ == '__main__':
    main()


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

a = 1
b = 1

i = 2

for j in range(m):
  ind = int(input())
  if ind == 1:
    b = 0
    continue
  while i < ind:
    a, b = b, a+b
    i += 1
  else:
    a, b = b, 0
    i += 1
    
while i < n+1:
  a, b = b, a+b
  i += 1
  
  
print(b%1000000007)

Measured memory_bytes: 45016
import java.awt.*;
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {
    int mod  = (int) 1e9+7;
    //int n = (int) 1e6+5;
    //long[][] memo = new long[n][27];
    void solve(String s1, String s2) {
        char[] cs1 = s1.toCharArray();
        char[] cs2 = s2.toCharArray();
        int n = s1.length();
        int cnt = 0;
        for(int i=0;i<n;i++){
            if(cs1[i]!=cs2[i])cnt++;
        }
        System.out.println(cnt);
    } 
    //0 1 2 3 4 5 6 7
    //1 7 3 4 7 6 2 9
    //1 7 4 3 7 6 2 9;
    //1 2 1 2 1
    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        //String[]  s = br.readLine().split(" ");
        Main test = new Main();

        String s = br.readLine();
        String s2 = br.readLine();
        test.solve(s,s2);
    }
}


Measured memory_bytes: 37688
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

#define MAX(a, b)	(((a) < (b)) ? (b) : (a))

struct Seito {
	int no;
	int	num;
};

bool comp(const Seito &a, const Seito &b)
{
	return a.num < b.num;
}

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

	vector<Seito> A(N);
	for (int i = 0; i < N; i++) {
		A[i].no = i;
		cin >> A[i].num;
	}

	sort(A.begin(), A.end(), comp);
	
	for (int i = 0; i < N; i++) {
		cout << A[i].no + 1 << '\n';
	}

	return 0;

}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
#define PARENT(x)   pred((succ(x)/2))
#define LEFT(x)     pred((succ(x)*2))
#define RIGHT(x)    pred((succ(x)*2+1))
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long i,n,*ary; char buffer[20];

    fgets(buffer, sizeof(buffer)-1, file);
    sscanf(buffer, "%ld", &n);
    ary=malloc(n*sizeof(long));
    for (i=0; i<n; i++){
        fscanf(file, "%ld", &ary[i]);
    }
    for (i=0; i<n; i++){
        printf("node %ld: key = %ld, ", succ(i), ary[i]);
        if (i)
            printf("parent key = %ld, ", ary[PARENT(i)]);
        if (LEFT(i)<n)
            printf("left key = %ld, ", ary[LEFT(i)]);
        if (RIGHT(i)<n)
            printf("right key = %ld, ", ary[RIGHT(i)]);
        printf("\n");
    }
    free(ary);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

Measured memory_bytes: 612
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node  {
    int key;
    Node *next, *previous;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while ( cur != nil && cur->key != key ) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->previous = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (1) {
        if ( cur == nil ) break;
        if ( isf++ > 0 ) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if ( t == nil ) return;
    t->previous->next = t->next;
    t->next->previous = t->previous;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->previous);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}


void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->previous = x;
    nil->next = x;
    x->previous = nil;
}


int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for ( i = 0; i < n; i++ ) {
        scanf("%s%d", com, &key);
        if ( com[0] == 'i' ) { insert(key); np++; size++; }
        else if ( com[0] == 'd' ) {
            if ( strlen(com) > 6 ) {
                if ( com[6] == 'F' ) deleteFirst();
                else if ( com[6] == 'L' ) deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }

    printList();

    return 0;
}


Measured memory_bytes: 33960
#include<iostream>

using namespace std;

int main(void){

	int y,m,d;

	while(cin>>y>>m>>d){
		if(y>=1989&&m>=1&&d>=8||y>=1989&&m>1||y>1989) cout<<"heisei "<<y-1989+1<<" "<<m<<" "<<d<<endl;
		else if(y>=1926&&m>=12&&d>=25||y>=1926&&m>12||y>1926) cout<<"showa "<<y-1926+1<<" "<<m<<" "<<d<<endl;
		else if(y>=1912&&m>=7&&d>=30||y>=1912&&m>7||y>1912) cout<<"taisho "<<y-1912+1<<" "<<m<<" "<<d<<endl;
		else if(y>=1868&&m>=9&&d>=8||y>=1868&&m>9||y>1868) cout<<"meiji "<<y-1868+1<<" "<<m<<" "<<d<<endl;
		else cout<<"pre-meiji"<<endl;
	}

}

Measured memory_bytes: 1164
#include <stdio.h>
#include <stdlib.h>
#define N_MAX 123456

int main(void){
	int n;
	int prime[N_MAX * 2 + 1] = {};  /* 素数フラグ (0:非素数, 1:素数) */
	int length = 0;
	int num;
	int i, j;

	while(scanf("%d", &n) == 1){
		if (n == 0){
			break;
		}

		/* 2n 以下の未判定の正の整数について、素数か否か判定する */
		for (i = length; i <= n * 2; i++){
			for (j = 2; j * j <= i; j++){
				/* sqrt(i) 以下の素数で割り切れるか調べる */
				if (prime[j] == 0){
					continue;
				}else if(i % j == 0){
					break;  /* 素数でない */
				}
			}

			if (!(j * j <= i) && i >= 2){
				/* 素数 */
				prime[i] = 1;
			}
		}
		if (length < n * 2 + 1){
			length = n * 2 + 1;  /* 判定済み整数の数を更新 */
		}

		/* 指定された範囲にある素数の個数を数える */
		num = 0;
		for (i = n + 1; i <= n * 2; i++){
			num += prime[i];
		}

		/* 出力 */
		printf("%d\n", num);
	}

    return 0;
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    pair<int, int> sc[M];

    int s, c;
    for (int i = 0; i < M; i++){
        cin >> s >> c;
        sc[i] = pair<int, int>(s, c);
    }
    int small = pow(10, N - 1);
    if (N == 1){
        small = 0;
    }

    for( int i = small; i < pow(10, N); i++){
        bool success = true;
        string s = to_string(i);
        for (pair<int, int> p : sc){
            if (stoi(""s + s.at(p.first - 1)) != p.second) {
                success = false;
                break;
            }
        }
        if (success){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;

    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int D; cin >> D;
  if(D==25){
    cout<<"Christmas";
  }
  else if(D==24){
    cout<<"Christmas Eve";
  }
  else if(D==23){
    cout<<"Christmas Eve Eve";
  }
  else if(D==22){
    cout<<"Christmas Eve Eve Eve";
  }
  cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define alphabet 26
#define ascii 96
typedef long long ll;
using namespace std;

int main() {
	int N, i, j;
	ll ans;
	cin >> N;
	if (N % 2)
	{
		ans = (N * (N - 2) + 1) / 2;
		cout << ans << endl;
		for (i = 1; i <= N; i++)
		{
			for (j = i + 1; j <= N; j++)
			{
				if ((i != j) && (i + j != N))
				{
					cout << i << " " << j << endl;
				}
			}
		}
	}
	else
	{
		ans = N * (N - 2) / 2;
		cout << ans << endl;
		for (i = 1; i <= N; i++)
		{
			for (j = i + 1; j <= N; j++)
			{
				if ((i != j) && (i + j != N + 1))
				{
					cout << i << " " << j << endl;
				}
			}
		}
	}
}

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

mod=10**9+7

if s1[0]==s2[0]:
  bef=0
  inx=1
  ans=3
else:
  bef=1
  inx=2
  ans=6

while inx<n:
  if s1[inx]==s2[inx]:
    if bef==0:
      ans*=2
      ans%=mod
    bef=0
    inx+=1
  else:
    if bef==1:
      ans*=3
    else:
      ans*=2
    ans%=mod
    bef=1
    inx+=2

print(ans)

Measured memory_bytes: 9208
@L=1..<>+2;@B=1e9;$z-=!--$B[$-=/ /&&$L[$A[$`-1]]++],$z+=!$B[$-=--$L[/ /?$A[$`-1]=$':$_]]++,/ /&&print@A-$z,$/for(@A=glob<>),<>

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

int main(){
    ll d, n, x, y, cnt=0;

    cin >> n >> d;
    d*=d;
    while(n--){
        cin >> x >> y;
        cnt += ((x*x+y*y)<=d);
    }

    cout << cnt <<'\n';
    
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> 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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N,M;
    cin>>N>>M;
    vector<int> a(N);
    cin>>a;
    vector<vector<int>> g(N);
    REP(i,M) {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    vector<heap<int>> hpv;
    vector<bool> vis(N,false);
    int idx=0;
    REP(i,N) {
        if(!vis[i]) {
            hpv.emplace_back();
            function<void(int)> dfs=[&](int v) {
                vis[v]=1;
                hpv[idx].push(a[v]);
                FORE(w,g[v]) {
                    if(vis[w]) continue;
                    dfs(w);
                }
            };
            dfs(i);
            idx++;
        }
    }
    if(M==N-1) {
        cout<<0<<endl;
        return 0;
    }
    
    int ans=0;
    heap<int> hpall;
    REP(i,SZ(hpv)) {
        ans+=hpv[i].top(); hpv[i].pop();
        while(!hpv[i].empty()) {
            int tmp=hpv[i].top(); hpv[i].pop();
            hpall.emplace(tmp);
        }
    }
    if(SZ(hpall)+idx<2*(N-1-M)) {
        cout<<"Impossible"<<endl;
        return 0;
    }
    REP(i,2*(N-1-M)-idx) {
        ans+=hpall.top(); hpall.pop();
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string p = "ABC";
    int ans = 0;
    for(int i = 0; i < n; i++){ 
        bool take = 1;
        for(int j = 0; j < 3; j++){ 
            if(i + j > n) {
                take = 0;
                break;
            }
            take &= (s[i + j] == p[j]);
        }
        ans += take;
    }
    cout << ans << endl;

    return 0;
}



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


int main() {
int a;
cin >> a;
int A = a/100,B = a%100;//Aは上二桁Bは下二桁

if(A>=1&&A<=12){
  if(B>=1&&B<=12){
    cout << "AMBIGUOUS" <<endl;
  }
  else{
    cout << "MMYY" <<endl;
  }
}
else{
  if(B>=1&&B<=12){
    cout << "YYMM" <<endl;
  }
  else{
    cout << "NA" <<endl;
  }
}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int num[4][100005],dp[4][100005];
int main() {
	cin>>n;
	for (int i=1;i<=n;++i) cin>>num[1][i]>>num[2][i]>>num[3][i];
	for (int i=1;i<=n;++i) {
		dp[1][i]=num[1][i];
		dp[2][i]=num[2][i];
		dp[3][i]=num[3][i];
	}
	for (int i=2;i<=n;++i) {
		dp[1][i]=max(dp[2][i-1],dp[3][i-1])+num[1][i];
		dp[2][i]=max(dp[1][i-1],dp[3][i-1])+num[2][i];
		dp[3][i]=max(dp[1][i-1],dp[2][i-1])+num[3][i];
	}
	int ans=max({dp[1][n],dp[2][n],dp[3][n]});
	cout<<ans<<endl;
	return 0;
}

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

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

  int sum = 1;

  for (int i = 0; i < n; i++) {
    if (sum > k) {
      sum += k;
    } else {
      sum *= 2;
    }
  }
  cout << sum << endl;
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n; cin >> n;

    vector<string> w(n);
    set<string> se;
    for (int i = 0; i < n; ++i){
        cin >> w[i];
        se.insert(w[i]);
    }

    if(se.size() != n){
        cout << "No" << endl;
        return 0;
    }

    char before = w[0][w[0].size() - 1];
    for (int i = 1; i < n; ++i){
        char now = w[i][0];
        if(before != now){
            cout << "No" << endl;
            return 0;
        }
        before = w[i][w[i].size() - 1];
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n],b[n];
    rep(i,n){
        cin >> a[i];
        b[i] = a[i];
    }
    intl ma = 0;
    rep(i,n)ma = max(ma,a[i]);
    rep(i,n)if(b[i] > (ma / 2))b[i] = ma - b[i];
    intl r = 0;
    rep(i,n)r = max(r,b[i]);
    bool f = false;
    rep(i,n)if(a[i] == r)f = true;
    if(!f)r = ma - r;
    cout << ma << " " << r << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll INF = 1e15;

vector<vector<ll>> WF_init(int v) {
    vector<vector<ll>> ret;
    for (int i = 0; i < v; i++) {
        vector<ll> tmp;
        for (int j = 0; j < v; j++) tmp.push_back(INF * (i != j));
        ret.push_back(tmp);
    }
    return ret;
}

vector<vector<ll>> warshall_floyd(vector<vector<ll>> G) {
    int v = G.size();
    for (int k = 0; k < v; k++) {
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < v; j++) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    return G;
}

int main() {
    int n, m, inf = 1e4;
    cin >> n >> m;
    vector<vector<ll>> G(n);
    for (int i = 0; i < n; i++) {
        vector<ll> H(n, inf);
        G[i] = H;
        G[i][i] = 0;
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a][b] = c;
        G[b][a] = c;
    }

    vector<vector<ll>> X = warshall_floyd(G);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans += (G[i][j] != inf && G[i][j] > X[i][j]);
        }
    }
    /*
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << G[i][j];
        }
        cout << endl;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << X[i][j];
        }
        cout << endl;
    }*/

    cout << ans / 2 << endl;
}


Measured memory_bytes: 384
import java.io.*;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] st = br.readLine().split(" ");
        int a = Integer.parseInt(st[0]);
        int b = Integer.parseInt(st[1]);
        int c = Integer.parseInt(st[2]);
        bw.append(a < b && b < c ? "Yes\n" : "No\n");
        bw.flush();
    }


}


Measured memory_bytes: 24500
# エラトステネスの篩
N = int(input())

sieve = [0] * (N + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, N + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i * i, N + 1, i):
        if sieve[j] == 0:
            sieve[j] = i


def f(K):
    t = []
    a = K
    while a != 1:
        if len(t) != 0 and t[-1][0] == sieve[a]:
            t[-1][1] += 1
        else:
            t.append([sieve[a], 1])
        a //= sieve[a]
    result = 1
    for _, n in t:
        result *= (n + 1)
    return result


result = 0
for K in range(1, N + 1):
    result += K * f(K)
print(result)


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

int main()
{
  int n;
  int64_t ans = 0;
  cin >> n;
  vector<int64_t> A(n);
  map<int64_t, int64_t> d;
  vector<int64_t> vec(n, 0);
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    A[i] = a;
    --a;
    ++vec[a];
  }

  for (int i = 0; i < n; ++i)
  {
    ans += vec[i] * (vec[i] - 1) / 2;
  }

  for (int i = 0; i < n; ++i)
  {
    int64_t val = vec[A[i] - 1];
    int64_t before = val * (val - 1) / 2;
    int64_t after = (val - 1) * (val - 2) / 2;
    cout << ans - before + after << "\n";
  }
}

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

int main() {
  int n,k; cin>>n>>k;
  vector<int> vec(n), dp(n+103,INT_MAX);
  for (int i = 0; i < n; i++) {
    cin>>vec.at(i);
  }
  dp[1] = abs(vec[1]-vec[0]);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int x = 0; x <= k; x++) {
      dp[i+x] = min(dp[i+x], dp[i]+abs(vec[i+x] - vec[i]));
    }
  }
  
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
import sys

def ans(num):
    ans = 0

    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a+b+c+d == num:
                        ans += 1

    return ans


def main():
    a = []

    for line in sys.stdin:
        a.append(int(line))

    for line in a:
        print(ans(line))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5596