akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
bool modBigNumber(string num, ll m)
{
    // Store the modulus of big number
    vector<int> vec;
    ll mod = 0;

    // Do step by step division
    for (int i = 0; i < num.size(); i++)
    {

        int digit = num[i] - '0';

        // Update modulo by concatenating
        // current digit.
        mod = mod * 10 + digit;

        // Update quotient
        int quo = mod / m;
        vec.push_back(quo);

        // Update mod for next iteration.
        mod = mod % m;
    }
    if (mod == 0)
        return true;
    return false;
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
int main()
{
    fastio();
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            count++;
        }
    }
    int ans = 0;
    for (int i = 0; i < count; i++)
    {
        if (s[i] == 'W')
        {
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int Q;
	cin>>Q;
	vector<ll> X(Q),Y(Q);
	rep(q,Q){
		ll x,y;
		cin>>x>>y;
		X[q] = x+y;
		Y[q] = x-y;
	}
	rep(q,Q){
		if((X[0]+X[q])%2 != 0){
			puts("-1");
			return 0;
		}
	}
	bool xinc = false;
	if(X[0]%2 == 0){
		rep(q,Q) X[q]++,Y[q]++;
		xinc = true;
	}
	int N = 32;
	if(xinc){
		cout<<N+1<<endl;
		cout<<1<<" ";
	}else{
		cout<<N<<endl;
	}
	rep(i,N) cout<<(1LL<<i)<<" ";
	puts("");
	rep(q,Q){
		vector<int> v(N);
		rep(t,2){
			ll inc = ((t==0 ? X[q] : Y[q]) + ((1LL<<N)-1)) / 2;
			rep(i,N) if((inc>>i)&1) v[i] |= 1<<t;
		}
		if(xinc) cout<<"L";
		rep(i,N) cout<<"LUDR"[v[i]];
		puts("");
	}
}

Measured memory_bytes: 256
n,W = map(int,input().split())
w = [0]*n
v = [0]*n
for i in range(n): w[i],v[i] = map(int,input().split())
x = w[0]
for i in range(n): w[i] -= x
dp = [[[0]*(4*n+1) for _ in range(n+1)] for _ in range(n+1)]

for i in range(n):
    for j in range(i+1):
        for k in range(4*n+1):
            if (j+1)*x+k <= W and k-w[i] >= 0:
                dp[i+1][j+1][k] = max(dp[i+1][j+1][k],dp[i][j][k-w[i]]+v[i])
            dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k])

"""
for i in range(n+1):
    print(i,"///////////////////////////////////////////////")
    for j in range(n+1):
        print(dp[i][j])
"""
print(max(max(dp[n][j]) for j in range(n+1)))

Measured memory_bytes: 75740
unittest
{
	assert( [ "3 3 3", "1 2 3", "1 2 1", "2 3 1", "3 1 4" ].parse.expand.solve == 2 );
	assert( [ "3 3 2", "1 3", "2 3 2", "1 3 6", "1 2 2" ].parse.expand.solve == 4 );
	assert( [ "4 6 3", "2 3 4", "1 2 4", "2 3 3", "4 3 1", "1 4 1", "4 2 2", "3 1 6" ].parse.expand.solve == 3 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmr = input.front.split.to!( long[] );
	input.popFront;
	auto rs = input.front.split.to!( long[] );
	auto abcs = new long[][]( nmr[ 1 ], 3 );
	foreach( ref abc; abcs )
	{
		input.popFront;
		abc = input.front.split.to!( long[] );
	}
	return tuple( nmr[ 0 ], rs, abcs );
}

auto solve( long n, long[] rs, long[][] abcs )
{
	// ワーシャルフロイド法で最短距離を計算
	auto dss = new long[][]( n, n );
	foreach( i, ref ds; dss )
	{
		ds[] = long.max / 2;
		ds[ i ] = 0L;
	}
	foreach( ref abc; abcs )
	{
		abc[ 0 ]--;
		abc[ 1 ]--;
		dss[ abc[ 0 ] ][ abc[ 1 ] ] = abc[ 2 ];
		dss[ abc[ 1 ] ][ abc[ 0 ] ] = abc[ 2 ];
	}
	foreach( p; 0 .. n )
	{
		foreach( f; 0L .. n )
		{
			foreach( t; 0 .. n )
			{
				dss[ f ][ t ] = min( dss[ f ][ t ], dss[ f ][ p ] + dss[ p ][ t ] );
			}
		}
	}
	
	// rsの順序を変えつつ最短距離を計算
	auto ans = long.max;
	rs[] -= 1;
	foreach( ps; rs.permutations )
	{
		auto dt = 0L;
		for( auto i = 0L; i + 1 < ps.length; i++ )
		{
			dt += dss[ ps[ i ] ][ ps[ i + 1 ] ];
		}
		ans = min( ans, dt );
	}
	return ans;
}


Measured memory_bytes: 8956
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll a,b,c;

int main(){
	cin>>a>>b>>c;
	ll t=min(a,c);
	a-=t,c-=t;
	t=min(b,c);
	b-=t;
	cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
long long a[1005],b,c,d,n;
int main()
{
	cin>>n;
	a[0]=2;
	for(long long i=1;i<=n;i++)
	{
		a[i]=a[i-1]*2+2;
	}
	cout<<a[n]<<endl;
}

Measured memory_bytes: 256
n,m=gets.chomp.split(" ").map(&:to_i)

s = Array.new(m)
c = Array.new(m)

m.times do |i|
  s[i],c[i] = gets.chomp.split(" ").map(&:to_i)
end

ans = Array.new(n,-1)

m.times do |i|
  if ans[s[i]-1] == -1
    ans[s[i]-1] = c[i]
  elsif ans[s[i]-1] != c[i]
    puts "-1"
    exit
  end
end


if n > 1
  if ans[0] == 0
    puts -1
    exit
  elsif ans[0] == -1
    print 1
  else
    print ans[0]
  end
  ans[1..n-1].each do |x|
    if x == -1
      print 0
    else
      print x
    end
  end
else
  if ans[0] == -1
    puts 0
  else
    print ans[0]
  end
end

Measured memory_bytes: 1788
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if x in a and y in a or x in b and y in b or x in c and y in c :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main() {
	// #ifndef ONLINE_JUDGE
	// 	// for getting input from input.txt
	// 	freopen("input.txt", "r", stdin);
	// 	// for writing output to output.txt
	// 	freopen("output.txt", "w", stdout);
	// #endif

		int n,sum=0;
		cin>>n;
		vector<int> v(n,0);

		for (int i = 0; i < n; ++i)
		{
			cin>>v[i];
		}
		sort(v.begin(),v.end(), greater<int>());
		
		for (int i = 0; i < n; i++)
		{
			if(i%2==0){
				sum = sum + v[i];
			}
			else{
				sum = sum -v[i];
			}
		}

		cout<<sum<<"\n";
		return 0;
	}	

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n=sc.nextInt();
      int d=sc.nextInt();

      int ans=0;
      int left=n;

      for(int i=0;i<n;i++){
        left = left - (1 + 2*d);
        ans++;
        if(left<=0){
          break;
        }
      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 9007199254740997;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const int w=11;
const int k=500;
const int n=26;
int ww;
int d;

VI c(n);
VVI s(365,VI(n));

struct st{
	VI a;
	ll score;
	bool operator<(const st &another) const {return score < another.score;};
};

vector<st> f(st p){
	VI a=p.a; ll score=p.score;
	int now=a.size()+1;
	VI last(n,0);
	REP(i,a.size())
		last[a[i]]=i+1;
	VI down(n); ll downsum=0;
	REP(i,n){
		down[i]=c[i]*(now-last[i]);
		downsum+=down[i];
	}
	a.push_back(-1);
	vector<st> tmp;
	REP(i,n){
		a[now-1]=i;
		tmp.push_back({a,score-downsum+down[i]+s[now-1][i]});
	}
	sort(ALL(tmp));
	vector<st> ret;
	REP(i,ww)
		ret.push_back(tmp[n-1-i]);
	return ret;
}

int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	priority_queue<st> q;
	VI a(0);
	q.push({a,0});
	REP(i,d){
		priority_queue<st> next;
		ww=w;
		REP(j,k){
			if(j%50==0)
			ww--;
			if(q.empty())
				break;
			for(auto nx:f(q.top()))
				next.push(nx);
			q.pop();
		}
		q=next;
	}
	REP(i,d)
		cout << q.top().a[i]+1 << endl;
	return 0;
}

Measured memory_bytes: 22936
h,w=map(int,input().split())
s=[[0]*(w+2) for i in range(h+2)]
for i in range(h):
    s[i+1]=[0]+list(input())+[0]
    
yn=""
for i in range(1,h+2):
    for j in range(1,w+2):
        if s[i][j]=="#":
            if s[i-1][j]=="#":
                continue
            elif s[i+1][j]=="#":
                continue
            elif s[i][j-1]=="#":
                continue
            elif s[i][j+1]=="#":
                continue
            else:
                yn="No"
                break
    if yn=="No":
         break
     
if yn=="No":
    print("No")
else:
    print("Yes")        


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

int n, k, l[50];

int main(void){
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  int s = 0;
  sort(l, l + n, greater<int>());
  for(int i = 0; i < k ; i++){
    s += l[i];
  }
  cout << s << endl;
}


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

using ll = long long;

int main()
{
  set<string> st;
  int N;
  cin >> N;
  for(int i =0; i<N; i++){
    string buf;
    cin >> buf;
    st.insert(buf);
  }
  cout << st.size() << endl;


}

Measured memory_bytes: 19204
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

    cout << 1LL * A * B / __gcd(A, B) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  int N;
  std::cin >> N;
  std::vector<unsigned long long> A(N);
  for(auto& val: A)
    std::cin >> val;
  std::sort(A.begin(), A.end());
  unsigned long long ans = A[0];
  bool flag = false;
  for(int i = 1; i < A.size(); ++i)
  {
    if(ans > 1000000000000000000 / A[i])
    {
      flag = true;
      break;
    }
    ans *= A[i];
  }
  std::cout << (flag || ans > 1000000000000000000 ? -1 : (long long)ans) << std::endl;

  return 0;
}



Measured memory_bytes: 3972
#include <stdio.h>

int BSearch( int A[], int N, int key ){
    int mid, left, right;
    left = 0;
    right = N;

    while (left<right){
        mid = (left+right)/2;
        if ( A[mid] == key ) return key;
        else if ( key < A[mid] ) right = mid;
        else left = mid + 1;
    }
   return 0;
}

int main()
{
   int n,q,i;
   int ans = 0;
   scanf("%d",&n);
   int s[n];
   for(i=0; i<n; i++){
     scanf("%d", &s[i]);
   }
   scanf("%d", &q);
   int t[q];
   for(i=0; i<q; i++){
     scanf("%d", &t[i]);
   }

   for(i=0; i<q; i++){
       int result = BSearch(s, n, t[i]);
       if(t[i]==result){
         ans = ans+1;
       }
   }
   printf("%d\n", ans);
   return 0;
}

Measured memory_bytes: 1184
n=int(input())
s=list(input())
s.append(s[0])
f=0
l=['S','S']
for j in range(4):
  for i in range(1,n+1):
    if l[i]=='S':
      if l[i-1]=='S':
        if s[i]=='o':
          l.append('S')
        else:
          l.append('W')
      else:
        if s[i]=='o':
          l.append('W')
        else:
          l.append('S')
    else:
      if l[i-1]=='S':
        if s[i]=='o':
          l.append('W')
        else:
          l.append('S')
      else:
        if s[i]=='o':
          l.append('S')
        else:
          l.append('W')
  if l[n+1]==l[1] and l[n]==l[0]:
    f=1
    break
  else:
    if j==0:
      l=['S','W']
    elif j==1:
      l=['W','S']
    elif j==2:
      l=['W','W']
    else:
      break
if f==0:
  print(-1)
else:
  l.pop()
  l.pop()
  print(''.join(l))

Measured memory_bytes: 4892
#include<bits/stdc++.h>
#define rint register int 
#define ll long long
using namespace std;
struct node{
	ll pos,w;
}A[1010010];
int n;
ll S,ans;
inline bool operator < (node p,node q){return p.pos<q.pos;}
int main(){
	cin>>n>>S;
	for(rint i=1;i<=n;++i) {
		cin>>A[i].pos>>A[i].w;
	}
	sort(A+1,A+n+1);
	int cur1=1,cur2=n,fl=0;
	while(A[cur1].pos<S&&A[cur2].pos>S){
		if(A[cur1].w>=A[cur2].w) {
			if(fl!=1) {
				ans+=abs(A[cur2].pos-A[cur1].pos);	
			}
			A[cur1].w+=A[cur2].w;
			cur2--;
			fl=1;
		}
		else {
			if(fl!=2) {
				ans+=abs(A[cur2].pos-A[cur1].pos);	
			}
			A[cur2].w+=A[cur1].w;
			cur1++;
			fl=2;
		}
	}
	if(A[cur1].pos<S) ans+=abs(S-A[cur1].pos);
	else  ans+=abs(S-A[cur2].pos);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int f[4];

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int i=0;i<n;i++) {
        string s; cin >> s;
        if (s[0]=='A') f[0]++;
        if (s[0]=='W') f[1]++;
        if (s[0]=='T') f[2]++;
        if (s[0]=='R') f[3]++;
    }
    cout << "AC x " << f[0] << endl;
    cout << "WA x " << f[1] << endl;
    cout << "TLE x " << f[2] << endl;
    cout << "RE x " << f[3] << endl;
}


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

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

    int x;
    cin >> x;

    long long int y;
    for(long long int i=-120;i<120;i++){
        for(long long int j=-120;j<120;j++){
            y = pow(i,5) - pow(j,5);
            if(y == x){
                cout << i << " " << j << "\n";
                break;
            }
        }
        if(y==x)break;
    }
}

Measured memory_bytes: 4048
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c) 
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll n,m;
    str s[MAX_N],t[MAX_N];
    msl cnt;
    ll answer = 0;
    
    in1(n);
    rin1(i,n,s);
    in1(m);
    rin1(i,m,t);

    rep(i,n) cnt[s[i]] = 0;
    rep(i,m) cnt[t[i]] = 0;
    rep(i,n) cnt[s[i]] ++;
    rep(i,m) cnt[t[i]] --;
    items(kv,cnt) answer = max(kv.e2, answer);
 
    prl(answer);
 
    return 0;
}

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

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp
#define pb push_back

#define fi
#define se

#define each

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int f(int n, int m, vi a){
	vi t(n+1,INF);
	t[0] = 0;
	rep(i,m){
		REP(j,a[i],n+1){
			t[j] = min(t[j],t[j-a[i]]+1);
		}
	}
	return t[n];
}

int main(){
	vi a;
	vi ao;
	REP(i,1,200){
		a.pb(i*(i+1)*(i+2)/6);
	}
	rep(i,a.size()){
		if(a[i]%2==1) ao.pb(a[i]);
	}

	// rep(i,a.size()) cout<<a[i]<<endl;
	// cout<<"=--"<<endl;
	// rep(i,ao.size()) cout<<ao[i]<<endl;

	while(1){
		int n; cin>>n;
		if(n==0) break;
		cout<<f(n,a.size(),a)<<" "<<f(n,ao.size(),ao)<<endl;
	}
	return 0;
}

Measured memory_bytes: 7956
<?php
    function judge($x, $k, $d){
        $y = $x;
        while($y > 0){
            $z = $y % 10;
            for($i = 0; $i < $k; $i++){
                if($z == $d[$i])return 0;
            }
            $y = floor($y / 10);
        }
        return 1;
    }
    $n;
    $k;
    fscanf(STDIN, "%d %d", $n, $k);
    $input = fgets(STDIN);
    $d = explode(" ", $input);
    
    for($i = $n; $i < 100000; $i++){
        if(judge($i, $k, $d) == 1){
            echo "$i\n";
            break;
        }
    }
?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[200010];
    cin >> N;
    rep(i,0,N) cin >> A[i];
    ll sum[200010] = {};
    rep(i,0,N) sum[i+1] = sum[i] + A[i];
    ll ans = 0;
    map<ll,ll> mp;
    rep(i,0,N+1) mp[sum[i]]++;
    for(auto &e: mp){
        ans += e.second * (e.second-1) / 2;
    }
    print(ans);
    
}

Measured memory_bytes: 15872
/*
 *  Author : Jun_SH
 *  Solution for ABC 096 C
 */
#include<bits/stdc++.h>
using namespace std;
char s[60][60];
int nu[60][60];
bool v[60][60];
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int n,m;
int flag=0;
int dfs(int x,int y){
    v[x][y]=true;
    int sum=0;
    for(int i=0;i<4;++i){
        int xx=x+dir[i][0];
        int yy=y+dir[i][1];
        if(xx<1||xx>n||yy<1||yy>m||v[xx][yy]||s[xx][yy]!='#')continue;
        sum+=dfs(xx,yy);
    }
    return sum+1;
}
int main(){
    memset(v,false,sizeof(v));
    cin>>n>>m;
    for(int i=1;i<=n;++i)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(v[i][j])continue;
            if(s[i][j]=='.')continue;
            int tmp=dfs(i,j);
            if(tmp<2){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <vector>
#include <set>
#include <queue>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <map>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace gnu_pbds;

#define F first
#define S second
#define ll long long
#define pb push_back
#define ppb pop_back
#define pii pair<int, int>
#define piii pair<int, pii>
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
#define int long long
// #define ld long double


const int N = 1e5 + 20, mod = 1e9 + 7, inf = 2e9 + 9;
const ll INF = 1e18 + 20;

int n, s, dp[N], w[101], v[101];

signed main() { __
    // freopen("a.in", "r", stdin);
    // freopen("a.out", "w", stdout);
    cin>>n>>s;
    for(int i = 1; i <= n; i++) {
        cin>>w[i]>>v[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = s; j >= w[i]; j--) {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);

        }
    }
    cout<<dp[s];
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	ll a;
	cin>>a;
	int out=0;
	while(a){
		out++;
		a/=2;
	}
	cout<<out<<endl;
}

Measured memory_bytes: 3072
package main

import "fmt"

func main() {
        var a, b int
        fmt.Scanf("%d %d\n", &a, &b)

        const row, col = 40, 100
        grid := make([][]byte, row)
        for i := range grid {
                grid[i] = make([]byte, col)
        }

        for i := 0; i < row/2; i++ {
                for j := range grid[i] {
                        grid[i][j] = '#'
                }
        }
        for i := row / 2; i < len(grid); i++ {
                for j := range grid[i] {
                        grid[i][j] = '.'
                }
        }
        a--
        b--

        i, j := 0, 0
        for ; a > 0; a-- {
                grid[i][j] = '.'
                j += 2
                if j >= col {
                        i += 2
                        j = 0
                }
        }
        i, j = row/2+1, 0
        for ; b > 0; b-- {
                grid[i][j] = '#'
                j += 2
                if j >= col {
                        i += 2
                        j = 0
                }
        }

        fmt.Printf("%d %d\n", row, col)
        for i := range grid {
                fmt.Println(string(grid[i]))
        }
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void){

	int a, b, n, m;

	while (1) {
		scanf("%d %d", &a, &b);
		if ((a == 0) && (b == 0))
		{
			break;
		}
		else
		{
			for (m = 1; m <= a; m++)
			{
				for (n = 1; n <= b; n++)
				{
					if ((m == 1) || (m == a))
					{
						printf("#");
					}
					else
					{
						if ((n == 1) || (n == b))
						{
							printf("#");
						}
						else
						{
							printf(".");
						}
					}
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 1756
//
// Created by sueta on 18/06/16.
//
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    unsigned long a[10000];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    unsigned cnt = 0;
    for (int i = 0; i < N; ++i) {
        if(!(a[i] & 1)){
            cnt++;
            a[i] = a[i] >> 1;
            i--;
            continue;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
    double a,b,c,d,e,f;
    double x,y;
    while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF) {
        y = (c * d - a * f) / (b * d - e * a);
        x = (c - (b * y)) / a;
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}
int main() {
    i64 m = 1e9+7;
    i64 N, K;
    cin >> N >> K;
    i64 ans = 0;
    ans += (K * (K - 1) * (2 * K - 1)) / 6;
    ans -= (N * (N + 1) * (2 * N + 1)) / 6;
    ans += ((N + 1) * N * (N + 1)) / 2;
    ans -= ((N + 1) * K * (K - 1)) / 2;
    ans += N - K + 2;
    cout << (ans % m) << endl;
    return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t H1,M1,H2,M2,K; cin>>H1>>M1>>H2>>M2>>K;

    int64_t dur=(H2-H1)*60+M2-M1;
    cout<<dur-K<<endl;
}

Measured memory_bytes: 3640
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N, C, K;
    scan(N, C, K);
    auto T = new long[](N);
    foreach (i; 0 .. N)
        scan(T[i]);
    sort(T);
    long remain;
    long time;
    long ans;
    foreach (i; 0 .. N)
    {
        if (remain == 0)
        {
            ans++;
            remain = C - 1;
            time = T[i] + K;
        }
        else if (T[i] <= time)
        {
            remain--;
        }
        else
        {
            ans++;
            remain = C - 1;
            time = T[i] + K;
        }
    }
    writeln(ans);
}


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

int main(){
    int n, m;
    cin >> n >> m;
    char s[n];
    for(int i = 0; i < n; i++){
        if(i == 0 && n != 1) s[i] = '1';
        else s[i] = '0';
    }
    bool f[n + 10];
    for(int i = 0; i < n + 10; i++) f[i] = true;
    for(int i = 0; i < m; i++){
        int p, q;
        cin >> p >> q;
        if(f[p - 1] == true || s[p - 1] == '0' + q){
            if(p == 1 && q == 0 && n != 1){
                cout << "-1" << endl;
                return 0;
            }
            s[p - 1] = '0' + q;
            f[p - 1] = false;
            //for(int j = 0; j < n; j++) cout << s[j];
            //cout << endl;
        }
        else{
            cout << "-1" << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++) cout << s[i];
    cout << endl;
    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    llint ans = 0, a, max;
    cin >> max;
    for(int in=1;in<n;++in) {
        cin >> a;
        if(max>a) ans += max - a;
        chmax(max, a);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

long long Fac[maxn],Inv[maxn],inv[maxn];
void init()
{
    Fac[0]=Inv[0]=Fac[1]=Inv[1]=inv[1]=1;
    for(int i=2;i<maxn;i++)
    {
        Fac[i]=Fac[i-1]*i%Mod;
        inv[i]=inv[Mod%i]*(Mod-Mod/i)%Mod;
        Inv[i]=Inv[i-1]*inv[i]%Mod;
    }
}
long long c(int n,int m)
{
    if(n<m||m<0) return 0;
    return Fac[n]*Inv[m]%Mod*Inv[n-m]%Mod;
}
long long C(int n,int m)
{
    int ans=1;
    while(n||m) ans=ans*c(n%Mod,m%Mod)%Mod,n/=Mod,m/=Mod;
    return ans;
}

vector<int> pos[maxn];
int a[maxn];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n;
    scanf("%d", &n);
    init();
    for (int i = 1; i <= n + 1; i++) {
        scanf("%d", &a[i]);
        pos[a[i]].pb(i);
    }
    int id = 0;
    for (int i = 1; i <= n; i++) {
        if (pos[i].size() == 2) {
            id = i;
            break;
        }
    }
    int m1 = pos[id][0] - 1;
    int m2 = n + 1 - pos[id][1];
    for (int i = 1; i <= n + 1; i++) {
        ll res = c(n + 1, i) - c(m1 + m2, i - 1);
        res += Mod;
        res %= Mod;
        printf("%lld\n", res);
    }


    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 9472
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int m, f, r;
	while (1) {
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1) break;
		else if (m == -1 || f == -1) cout << "F\n";
		else if ((m + f) >= 80) cout << "A\n";
		else if ((m + f) >= 65) cout << "B\n";
		else if ((m + f) >= 50) cout << "C\n";
		else if ((m + f) >= 30) {
			if (r >= 50) cout << "C\n";
			else     	 cout << "D\n";
		}
		else  cout << "F\n";
	}
	return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <bitset>
#include <cassert>
#include <queue>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 1e5 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 127;
const int inf = 2e9;

int n, k;

void read() {
    cin >> n >> k;
}

void solve() {
    cout << min(n % k, k - n % k);
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  rep(i, H) { cin >> a[i]; }

  vector<int> H_use;
  rep(i, H) {
    if (a[i].find("#") != a[i].npos) {
      H_use.pb(i);
    }
  }

  vector<int> W_use;
  rep(j, W) {
    bool all_dot = true;
    rep(i, H) {
      if (a[i][j] == '#') all_dot = false;
    }
    if (all_dot == false) {
      W_use.pb(j);
    }
  }

  rep(i, H_use.size()) {
    rep(j, W_use.size()) { cout << a[H_use[i]][W_use[j]]; }
    cout << endl;
  }
}

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


int main(){
    string s;
    cin>>s;

    int p,m;
    p = count(s.begin(),s.end(),'+');
    m = count(s.begin(),s.end(),'-');

    cout<<p-m<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MIN / 2 + 1;
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vector<vector<ll>> dp(t + 1, vector<ll>(2, inf));
    dp[0][0] = 0;
    rep(i, n) {
        rrep(j, t) {
            ll nt = j + a[i];
            if (nt <= t) {
                chmax(dp[nt][0], dp[j][0] + b[i]);
                chmax(dp[nt][1], dp[j][1] + b[i]);
            }
            chmax(dp[j + 1][1], dp[j][0] + b[i]);
        }
    }
    ll ans = 0;
    rep(i, t + 1) rep(j, 2) chmax(ans, dp[i][j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n+x-1)/x*t;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

signed main() {
	int n, ans = 0;
	cin >> n;
	vector<P>vec[16];
	rep(i, n) {
		int x;
		cin >> x;
		rep(j, x) {
			int a, b;
			cin >> a >> b;
			vec[i].push_back({ a - 1,b });
		}
	}
	rep(i, 1 << n) {
		int bit[16];
		int cnt = 0;
		rep(j, n) {
			bit[j] = i / (1 << j) % 2;
			if (bit[j]) cnt++;
		}
		bool bou = true;
		rep(j, n) {
			if (bit[j]) {
				rep(k, vec[j].size()) {
					if (vec[j][k].second != bit[vec[j][k].first]) {
						bou = false;
						break;
					}
				}
			}
			if (!bou) break;
		}
		if (bou) ans = max(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys 
input = sys.stdin.readline
MOD = 10**9 +7
INF = 10**9

def main():
    a,b = map(int,input().split())
    if b%a == 0:
        print(a + b)
    else:
        print(b - a)

if __name__=='__main__':
    main()

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[125252];
int n;

int main(){
  scanf("%s",s);
  n = strlen(s);
  // double
  REP(i,n-1){
    if(s[i]==s[i+1]){
      printf("%d %d\n",i+1,i+2);
      return 0;
    }
  }
  // triple
  REP(i,n-2){
    if(s[i]==s[i+2]){
      printf("%d %d\n",i+1,i+3);
      return 0;
    }
  }
  puts("-1 -1");
  return 0;
}


Measured memory_bytes: 384
dp = [[0 for n in range(1001)] for m in range(11)]
length, goal = map(int, input().split(" "))
problems = []
for l in range(length):
    a, b = map(int, input().split(" "))
    problems.append([a, b])

for i in range(length):
    max_problems = problems[i][0]
            
    for k in range(1000):
        if dp[i][k]:
            for l in range(max_problems):
                dp[i + 1][k + 1 + l] = max(dp[i + 1][k + 1 + l], dp[i][k] + (i + 1) * 100 * (l + 1) + (problems[i][1] * int(l + 1 == max_problems)) )
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][k])
    for l in range(max_problems):
        dp[i + 1][1 + l] = max(dp[i + 1][1 + l], (i + 1) * 100 * (l + 1) + (problems[i][1] * int(l + 1 == max_problems)) )
        # print(dp[i + 1][1])
answer = float("inf")
for i in range(11):
    for j in range(1001):
        if dp[i][j] >= goal:
            answer = min(answer, j)
print(answer)

Measured memory_bytes: 3316
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		new Main().start();
	}

	void start() {
		final int MARU = 1;
		final int KAKU = 2;
		Scanner stdin = new Scanner(System.in);
		while (true) {
			String sentence = stdin.nextLine();

			if (!(sentence.length() == 1 && sentence.charAt(0) == '.')) {
				int maru = 0;
				int kaku = 0;
				int kind = 0;
				boolean isOk = true;

				Stack<Integer> stack = new Stack<Integer>();
				for (int i = 0; i < sentence.length(); i++) {
					if (sentence.charAt(i) == '(') {
						maru++;
						kind = MARU;
						stack.push(kind);
					} else if (sentence.charAt(i) == ')') {
						maru--;
						if(maru < 0){
							isOk = false;
							break;
						}
						int a = stack.pop();
						if(a != MARU){
							isOk = false;
							break;
						}
					} else if (sentence.charAt(i) == '[') {
						kaku++;
						kind = KAKU;
						stack.push(kind);

					} else if (sentence.charAt(i) == ']') {
						kaku--;
						if(kaku < 0){
							isOk = false;
							break;
						}
						int a = stack.pop();
						if( a != KAKU){
							isOk = false;
							break;
						}
					}
//					if (maru < 0 || kaku < 0) {
//						isOk = false;
//						break;
//					}
				}



				if (!stack.isEmpty()) {
					isOk = false;
				}
				if (isOk) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}else{
				break;
			}
		}
	}
}

Measured memory_bytes: 45892
#include <stdio.h>
int main(void)
{
	int a, b ,c ,d ,ans;
	scanf("%d%d%d" ,&a ,&b ,&d);
	for(c = a;c <= b;c++)
	{
		if(d%c == 0)ans++;
	}
	printf("%d\n" ,ans);
return 0;
}


Measured memory_bytes: 2104
accum = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]
youbi = ["Wednesday", "Thursday", "Friday", "Saturday",
         "Sunday", "Monday", "Tuesday", ]


def getYoubi(month, day):
    total = accum[month - 1] + day
    return youbi[total % 7]


month = 13
day = 32

while True:
    month, day = map(int, input().split())
    if month == 0:
        break
    print(getYoubi(month, day))



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

int main(){
  int N, A;
  
  cin >> N >> A;
  
  if(!(A==0)){
    if(N%500>A)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
  else{
    if(!(N%500==0))
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

char s[51][51];

int vx[] = { 0,  1, 1, 1, 0, -1, -1, -1};
int vy[] = {-1, -1, 0, 1, 1,  1,  0, -1};

int checkMine(int h, int w, int x, int y) {
    int cnt = 0;

    for (int i = 0; i < 8; i++) {
        if (((x + vx[i] < w && x + vx[i] >= 0) || (y + vy[i] < h && y + vy[i] >= 0)) && (s[x + vx[i]][y + vy[i]] == '#')) cnt++;
    }

    return cnt;

}
int main()
{
    int h, w; cin >> h >> w;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') s[i][j] += 2 + checkMine(h, w, i, j);
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j != w - 1) cout << s[i][j];
            else cout << s[i][j] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256