akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
const int IMAX = 200010;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

int N;
const int VN = 200000;
int to[VN * 2 + 2], ne[VN * 2 + 2], he[VN + 1];
int n[VN + 1];
int dfs(int v, int prev) {
	int kazu = 1;
	ll ret = 1;
	for (int i = he[v]; i; i = ne[i]) {
		int t = to[i];
		if (t != prev) {
			ret = ret * dfs(t, v) % mod;
			kazu += n[t];
		}
	}
	n[v] = kazu;
	return ret * kazu % mod;
}
void dfs2(int v, int prev) {
	for (int i = he[v]; i; i = ne[i]) {
		int t = to[i];
		if (t != prev) {
			n[t] = ll(n[v]) * n[t] % mod * f.inv[N - n[t]] % mod;
			dfs2(t, v);
		}
	}
}

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

	
	cin >> N;
	int k = 2;
	rep1(i, N - 1) {
		int a, b;
		cin >> a >> b;

		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}
	ll tmp = dfs(1, -1);
	n[1] = modpow(tmp, mod - 2) * f.fac[N] % mod;
	for (int i = he[1]; i; i = ne[i]) {
		int t = to[i];
		n[t] = ll(n[1]) * n[t] % mod * f.inv[N - n[t]] % mod;
		dfs2(t, 1);
	}
	rep1(i, N) co(n[i]);

	Would you please return 0;
}

Measured memory_bytes: 6912
a, b, c, x, y = map(int, input().split())
n = [x, y, 0]
p = a * x + b * y
for i in range(max(x, y)):
    if n[0]:
        n[0] -= 1
    if n[1]:
        n[1] -= 1
    n[2] += 2
    p = min(p, a * n[0] + b * n[1] + c * n[2])
print(p)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
#define MAX 1e9
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
#define MOD 1000000007

int main(){
  ll N;
  cin>>N;
  vector<ll>A(N);
  rep(i,N){cin>>A[i];}
  ll sum=0ll;
  vector<ll>ans(N);
  rep(i,N){sum^=A[i];}
  rep(i,N){
    ll x=A[i];
    ans[i]=sum^x;
  }
  rep(i,N){cout<<ans[i]<<' ';}
}



Measured memory_bytes: 6316
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
//    cin.tie(false);
//    cout.tie(false);
    int s,w;
    cin>>s>>w;
    if(s>w) cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;
    return 0;
}

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

signed main(){
    string s,t;
    cin >> s >> t;

    ll ans = t.size();
    for(ll i=0; i<s.size()-t.size()+1; i++)
    {
        ll cnt = 0;
        for (ll j = 0; j < t.size() and i+j<s.size(); j++)
        {
            if(s[i+j] == t[j]) cnt++;
        }
        ans = min(ans,(ll)t.size()-cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main() {
  string k;
  int a;
  cin >> k;
  size_t size = k.length();
  for(int i=0;i<size;i++){
    if(k[i]=='o') a++;
  }
  if(a+15-size>=8) cout << "YES" << endl;
  else cout << "NO" <<endl;
}

Measured memory_bytes: 256
m=10**9+7
l,r=map(int,input().split())
dp=[[[[0 for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(61)]

dp[60][0][0][0]=1

for i in reversed(range(60)):
  lb=l>>i&1
  rb=r>>i&1
  for j in range(2):
    for k in range(2):
      for s in range(2):
        pre=dp[i+1][j][k][s]
        for x,y in [(0,0),(0,1),(1,1)]: # excpet for (1,0) (because of x<y)
          nj,nk,ns=j,k,s
          # s
          if (s==0 and x==0 and y==1): continue; # skip for not x==y==1
          if (s==0 and x&y): ns=1;
          # j
          if (j==0 and lb==1 and x==0): continue; # skip for x<l
          if (j==0 and lb==0 and x==1): nj=1;
          # k
          if (k==0 and rb==0 and y==1): continue; # skip for r<y
          if (k==0 and rb==1 and y==0): nk=1;           
            
          dp[i][nj][nk][ns]+=pre
          dp[i][nj][nk][ns]%=m    
                  
ans=0             
for j in range(2):
  for k in range(2):
    ans+=dp[0][j][k][1]
    ans%=m
print(ans)
                  
                  

Measured memory_bytes: 9236
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long llint;

const int MAXN = 100005;

int x, n, q;
int r[MAXN], d[MAXN];
int gore[MAXN], dolje[MAXN];
llint sum[MAXN];

int upit (int t, int val) {
    int ind=upper_bound(r, r+n+1, t)-r-1;
    //cout << "ind " << ind << endl;
    int a=dolje[ind]-sum[ind];
    int b=gore[ind]-sum[ind];
    //cout << "ababababab " << a << " " << b << endl;
    int curr, res;
    if (val<a) {
        curr=dolje[ind];
    } else if (val>b) {
        curr=gore[ind];
    } else {
        curr=val+sum[ind];
    }
    //cout << curr << endl;
    int dist=t-r[ind];
    if (ind&1) {
        res=min(x, curr+dist);
    } else {
        res=max(0, curr-dist);
    }
    return res;
}

int main () {
    cin >> x >> n;
    for (int i=1; i<=n; i++) {
        scanf("%d", &r[i]);
        d[i]=r[i]-r[i-1];
    }
    dolje[0]=0; gore[0]=x;
    for (int i=1; i<=n; i++) {
        if (i&1) {
            dolje[i]=max(0, dolje[i-1]-d[i]);
            gore[i]=max(0, gore[i-1]-d[i]);
            sum[i]=sum[i-1]-d[i];
        } else {
            dolje[i]=min(x, dolje[i-1]+d[i]);
            gore[i]=min(x, gore[i-1]+d[i]);
            sum[i]=sum[i-1]+d[i];
        }
        //cout << "sum " << sum[i] << " " << d[i] << endl;
    }
    cin >> q;
    for (int i=0; i<q; i++) {
        int tt, vv;
        scanf("%d%d", &tt, &vv);
        printf("%d\n", upit(tt, vv));
    }
    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>

#define M_MAX         10000
#define N_MAX         1000
#define r_MAX         1000
#define q_MAX         50
#define DATASET_MAX   10
#define TS_MIN        540
#define TE_MAX        1260
#define USETIME_MAX   TE_MAX-TS_MIN

struct LogInfo{
  int PCNum;
  int LogInTime;
  int LogOutTime;
};

int LogInCnt[M_MAX];
struct LogInfo LogInfoData[M_MAX][r_MAX];
int UsePCTime[DATASET_MAX];

void VarInit( void ){
  int i;
  int j;
  
  for( i=0; i<M_MAX; i++ ){
    LogInCnt[i] = 0;
    for( j=0; j<r_MAX; j++ ){
      LogInfoData[i][j].PCNum = 0;
      LogInfoData[i][j].LogInTime = 0;
      LogInfoData[i][j].LogOutTime = 0;
    }
  }
}


void RecLogInInfo( int t, int n, int m ){
  LogInfoData[m][LogInCnt[m]].PCNum = n;
  LogInfoData[m][LogInCnt[m]].LogInTime = t;
  LogInCnt[m]++;
}

void RecLogOutInfo( int t, int n, int m ){
  int i;
  
  for( i=0; i<LogInCnt[m]; i++ ){
    if( (LogInfoData[m][i].PCNum == n) && (LogInfoData[m][i].LogOutTime == 0)){
      LogInfoData[m][i].LogOutTime = t;
    }
  }
}

int CalcUsePCTime( int ts, int te, int m ){
  int i,j,t1,t2,Time;
  int Work[USETIME_MAX+1];
  Time = 0;
  
  for( i=0; i<USETIME_MAX+1; i++){
    Work[i] = 0;
  }
  
  for( i=0; i<LogInCnt[m]; i++ ){
    if( LogInfoData[m][i].LogInTime > ts ){
      t1 = LogInfoData[m][i].LogInTime;
    }else if((LogInfoData[m][i].LogInTime <= ts) && (LogInfoData[m][i].LogOutTime >= ts)){
      t1 = ts;
    }else{
      t1 = 0;
    }
    
    if( LogInfoData[m][i].LogOutTime < te ){
      t2 = LogInfoData[m][i].LogOutTime;
    }else if((LogInfoData[m][i].LogInTime <= te) && (LogInfoData[m][i].LogOutTime >= te)){
      t2 = te;
    }else{
      t2 = 0;
    }
    
    for( j=t1; j<t2; j++){
      Work[j-TS_MIN] = 1;
    }
  }
  
  for( i=ts; i<=te; i++){
    if(Work[i-TS_MIN] == 1){
      Time++;
    }
  }
  
  return Time;
}


int main( void ){
  int i,N,M,r,q,t,n,m,s,ts,te;
  int qNum;
  int UseTime;
  
  qNum = 0;
  for( i=0; i<DATASET_MAX; i++ ){
    UsePCTime[i] = 0;
  }
  while( 1 ){
    scanf( " %d %d", &N, &M );
    if( N == 0 ){
      break;
    }
    VarInit();
    scanf( " %d", &r );
    for( i=0; i<r; i++ ){
      scanf( " %d %d %d %d", &t, &n, &m, &s );
      if( s == 1 ){
         RecLogInInfo( t, n, m );
      }else{
        RecLogOutInfo( t, n, m );
      }
    }
    
    scanf( " %d", &q );
    for( i=0; i<q; i++ ){
      scanf( " %d %d %d", &ts, &te, &m );
      UseTime = CalcUsePCTime( ts, te, m );
      printf("%d\n",UseTime);
    }
  }
}




Measured memory_bytes: 119800
import java.util.*;

public class Main {
	public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        // 8%時の税抜価格
        double a = sc.nextDouble() / 0.08;

        // 10%時の税抜価格
        double b = sc.nextDouble() / 0.1;

        // 税抜き価格 最小値判別
        if ((b <= a) && (a <= b + 9)) {

            System.out.println((int)Math.ceil(a));
        } else if ((a <= b) && (b <= a + 12)) {

            System.out.println((int)Math.ceil(b));
        } else {

            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 26452
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a + N);
    int cnt[4] = {0};
    int tmp[4] = {0};
    int pos = 0;
    tmp[0] = a[0];
    cnt[pos]++;
    
    for(int i = 1; i < N && pos < 3; i++){
        if(a[i] != a[i-1]){
            pos++;
            tmp[pos] = a[i];
        }
        cnt[pos]++;
    }
    
    if(pos < 3 && cnt[0] == cnt[1] && cnt[1] == cnt[2] && (tmp[0] ^ tmp[1]) == tmp[2])
        cout << "Yes" << "\n";
    else if(pos < 2 && 2*cnt[0] == cnt[1] && tmp[0] == 0)
        cout << "Yes" << "\n";
    else if(pos < 1 && tmp[0] == 0)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S;
	cin>>S;
	if(S=="ARC")cout<<"ABC"<<endl;
	if(S=="ABC")cout<<"ARC"<<endl;
}

Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;
double a[105];
double ans;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%lf",a+i);
	}
	sort(a+1,a+1+N);
	for(int i=1;i<N;i++)
	{
		a[i+1]=(a[i]+a[i+1])/2.000;
	}
	printf("%lf",a[N]);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int max_n = 3e5 + 20;
int n, k;
long long a[max_n], b[max_n], c[max_n], ans, DP[200][max_n];
int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    DP[0][a[0]] = b[0];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            DP[i][j] = DP[i - 1][j];
            if (j >= a[i] && DP[i - 1][j - a[i]] || j - a[i] == 0)
                DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - a[i]] + b[i]);
        }
    }
    for (int i = 0; i <= k; i++)
        ans = max(ans, DP[n - 1][i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 237952
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

template< typename T>
struct edge { 
   int from, to; 
   T cost; 
   edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template< typename T>
using EDGE = vector< edge< T > >;

template< typename T>
vector< T > bellman_ford(EDGE< T > &es, int V, int s) {
   const auto INF = numeric_limits< T >::max();
   vector< T > dist(V, INF);
   dist[s] = 0;
   for (int i = 0; i < V - 1; i++) {
      for (auto &e : es) {
         if (dist[e.from] == INF) continue;
         dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
      }
   }
   for (auto & e : es) {
      if (dist[e.from] == INF) continue;
      if (dist[e.from] + e.cost < dist[e.to]) return vector< T >();
   }
   return dist;
}

const int MAXN = 2501;
bool used1[MAXN];
bool used2[MAXN];
vector<int> G1[MAXN], G2[MAXN];

void bfs1(int s) {
   used1[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G1[cur]) {
         if (used1[g]) continue;
         used1[g] = true;
         q.push(g);
      }
   }
}

void bfs2(int s) {
   used2[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G2[cur]) {
         if (used2[g]) continue;
         used2[g] = true;
         q.push(g);
      }
   }
}

int main() {
   int N, M, P;
   cin >> N >> M >> P;
   int A[M], B[M], C[M];
   for (int i = 0; i < M; i++) {
      cin >> A[i] >> B[i] >> C[i];
      A[i]--;
      B[i]--;
      C[i] = -1 * (C[i] - P);
      G1[A[i]].push_back(B[i]);
      G2[B[i]].push_back(A[i]);
   }
   memset(used1, false, sizeof(used1)); 
   memset(used2, false, sizeof(used2)); 

   bfs1(0);
   bfs2(N - 1);
   
   EDGE< int > edges;
   
   for (int i = 0; i < M; i++) {
      if (!used1[A[i]]) continue;
      if (!used1[B[i]]) continue;
      if (!used2[A[i]]) continue;
      if (!used2[B[i]]) continue;
      edges.emplace_back(A[i], B[i], C[i]);
   }
   
   auto res = bellman_ford(edges, N, 0);
   if (res.empty()) cout << "-1" << endl;
   else cout << max(0, -1 * res[N - 1]) << endl;
   return 0;
}


Measured memory_bytes: 768
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  char a, b;
  cin >> a >> b;

  if (a == 'H') {
    if (b == 'H') {
      cout << 'H' << endl;
    } else {
      cout << 'D' << endl;
    }
  } else {
    if (b == 'H') {
      cout << 'D' << endl;
    } else {
      cout << 'H' << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<pair<int,char>> vec(3*n);
  for (int c = 0; c < 3; ++c)
  {
    for (int i = 0; i < n; ++i)
    {
      cin>>vec[c*n+i].first;
      vec[c*n+i].second='z'-c;
    }
  }
  sort(vec.begin(), vec.end());
  vector<char> s;
  for(auto&& e: vec) {
    if(e.second=='x') e.second='c';
    else if(e.second=='y') e.second='b';
    else e.second='a';
    s.emplace_back(e.second);
  }
  std::vector<int64_t> point,ans;
  reverse(s.begin(), s.end());
  int64_t cnt=0;
  int64_t cnt_a=0;
  for(auto&& e: s) {
    if(e=='c') cnt++;
    else if(e=='b') {
      point.emplace_back(cnt);
      cnt_a+=cnt;
    }
    else ans.emplace_back(cnt_a);
  }
  cout<<accumulate(ans.begin(), ans.end(),0L);
}

Measured memory_bytes: 5364
r, c, a1, a2, b1, b2 = gets.chomp.split.map(&:to_i)
result = 1
if a1 == b1
    result = 2 if (a2 - b2).abs == c - (a2 - b2).abs
else
    if a2 == b2
        result = 2 if (a1 - b1).abs == r - (a1 - b1).abs
    else
        x1, x2 = [a2, b2].minmax
        y1, y2 = [a1, b1].minmax
        arr = [[x2 - x1, y2 - y1], [c + x1 - x2, y2 - y1], [x2 - x1, r + y1 - y2], [c + x1 - x2, r + y1 - y2]]
        min = nil
        arr.each{|x, y| min = x + y if min.nil? || min > x + y}
        result = 0
        arr.each{|x, y|
            next if x + y != min
            z = 1
            a, b = [x, y].minmax
            a.times{|i| z *= (a + b - i)}
            a.times{|i| z /= (i + 1)}
            result += z
        }
    end
end
puts result % 100_000_007



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

int gcd(int m, int n){
    if(m%n==0)
        return n;
    return gcd(n,m%n);
}

int main(){
    int x,y,ans=0;
    cin>>x>>y;
    if(x>y){
        ans=gcd(x,y);
    }else{
        ans=gcd(y,x);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,m;
    long long k;
    cin >> n >> m >> k;
    long long A[n + 1];
    long long B[m + 1];
    A[0] = 0;
    B[0] = 0;
    int mxA = 0,mxB = 0,mxC = 0;
    for(int i = 1;i < n + 1;i++){
        cin >> A[i];
        A[i] = A[i] + A[i - 1];
        if(A[i] <= k)
            mxA = i;
    }
    for(int i = 1;i < m + 1;i++){
        cin >> B[i];
        B[i] = B[i] + B[i - 1];
        if(B[i] <= k)
            mxB = i;
    }
    int index = mxB;
    for(int i = 0;i <= n;i++){
        while (index >= 1 && (B[index] + A[i]) > k){
            index --;
        }
        if((B[index] + A[i]) <= k)
        mxC = max(mxC,index + i);
    }
    cout << max(mxA,max(mxB,mxC)) << endl;
}


Measured memory_bytes: 6736
while line = gets
  (a, b) = line.split.map(&:to_i)
  if b < a
    big = a
    small = b
  else
    big = b
    small = a
  end

  tmp1 = big
  tmp2 = small

  while (tmp1 % small) != 0
    tmp1 += big
  end

  least_common_multiple = tmp1

  while true
    q = a / b;
    r = a % b;
    break if (r == 0)
    a = b;
    b = r;
  end
  printf("%d %d\n", b, least_common_multiple)
end

Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[] map = new int[3];
		map[0] = sc.nextInt();
		map[1] = sc.nextInt();
		map[2] = sc.nextInt();
		
		Arrays.sort(map);
		
		int sub = map[2] - map[0];
		sub += map[2] - map[1];
		
		if (sub % 2 == 0) {
			System.out.println(sub / 2);
		} else {
			System.out.println((sub + 1) / 2 + 1);
		}
	}
	
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int INF=1e6+5;
vector<int>edges[maxn];
int dis[maxn],in_degree[maxn];
int n,m;
void dfs(int s)
{
	for(auto& u : edges[s])
	{
		dis[u]=max(dis[u],dis[s]+1);
		--in_degree[u];
		if(in_degree[u]==0)dfs(u);
	}
}
// input : DAG
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y;cin>>x>>y;
		edges[x].push_back(y);
		++in_degree[y];	
	}
	for(int i=1;i<=n;i++)
	{
		edges[0].push_back(i);
		++in_degree[i];
	}
	fill(dis+1,dis+maxn,-INF);
	dfs(0);
	int ans=0;
	for(int i=0;i<=n;i++)ans=max(ans,dis[i]);
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 7928
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int D = sc.nextInt();
      int T = sc.nextInt();
      int S = sc.nextInt();
      
      // 判定
      String result = "No";
      if(T*S >= D){
        result = "Yes";
      }
      
      // 出力
      System.out.println(result);
    }
    
}

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

using namespace std;

typedef long long llint;

const int MAXN = 1e5 + 10;

int N;

llint C;
llint x[MAXN], v[MAXN];
llint prefL[MAXN], prefR[MAXN], L[MAXN], R[MAXN];

int main(void) {
  scanf("%d%lld", &N, &C);
  for (int i = 0; i < N; ++i)
    scanf("%lld%lld", &x[i + 1], &v[i + 1]);

  x[N + 1] = C;

  llint sol = 0;
  for (int i = 0; i < N; ++i) {
    R[i + 1] = R[i] + v[i + 1] - (x[i + 1] - x[i]);
    prefR[i + 1] = max(prefR[i], R[i + 1]);
    sol = max(sol, prefR[i + 1]);
  }

  for (int i = 0; i < N; ++i) {
    L[i + 1] = L[i] + v[N - i] - (x[N - i + 1] - x[N - i]);
    prefL[i + 1] = max(prefL[i], L[i + 1]);
    sol = max(sol, prefL[i + 1]);
  }

  //for (int i = 1; i <= N; ++i)
    //printf("%d ", R[i]);
  //printf("\n");

  //for (int i = 1; i <= N; ++i)
    //printf("%d ", L[i]);
  //printf("\n");


  for (int i = 1; i <= N; ++i) {
    sol = max(sol, R[i] - x[i] + prefL[N - i]);
    sol = max(sol, L[i] - (x[N + 1] - x[N - i + 1]) + prefR[N - i]);
  }

  printf("%lld\n", sol);

  return 0;
}


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

ll choose2(ll n){
	return n * (n - 1) / 2;
}

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  	rep(i, n) a[i]--;
  
  	vector<int> cnt(n);
  	rep(i, n) cnt[a[i]]++;
  
  	ll tot = 0;
  	rep(i, n){
    	tot += choose2(cnt[i]);
    }
  	rep(i, n){
    	ll ans = tot;
      	ans -= choose2(cnt[a[i]]);
        ans += choose2(cnt[a[i]] - 1);
      	cout << ans << endl;
    }
}

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

#define ll long long
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    fast();
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,x,gcd;
        cin>>n;
        for(ll i=0;i<n;i++)
        {
            cin>>x;
            if(i==0)
                gcd=x;
            gcd=__gcd(gcd,x);
        }
        cout<<gcd;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
typedef double db;
const int MX=100000;
const int mod=1000000007;
const ll inf=1e18;
ll dp[MX+5],n;

int main()
{
    FasterIO;
    ll i,j,k,W,x,y;
    cin>>n>>W;
    for(i=1;i<=MX;i++)dp[i]=inf;
    for(i=1; i<=n; i++)
    {
        cin>>x>>y;
        for(j=MX;j>=y;j--)
        {
            dp[j]=min(dp[j],dp[j-y]+x);
        }
    }
    ll res=0;
    for(i=1; i<=MX; i++)
    {
        if(dp[i]<=W)res=i;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
N, Y = map(int, input().split())
for n in range(N+1):
    for m in range(N+1-n):
        if 1000*n + 5000*m + 10000*(N-n-m) == Y:
            print(N-n-m, m, n)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int R = 0;
  rep(i,N) if(s[i] == 'R') R++;

  int ret = 0;
  rep(i,N){
    if(R == 0) continue;
    if(s[i] == 'W'){
      ret++;
    }
    R--;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 3752
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var strs = str.Split(' ');
            var H = int.Parse(strs[0]);
            var W = int.Parse(strs[1]);

            str = Console.ReadLine();
            strs = str.Split(' ');
            var h = int.Parse(strs[0]);
            var w = int.Parse(strs[1]);

            var white = H * W;
            white -= W * h;
            white -= (H - h) * w;

            Console.WriteLine(white);
        }
    }
}


Measured memory_bytes: 11092
n = gets.to_i
s = gets.split.map(&:to_i).sort
q = gets.to_i
t = gets.split.map(&:to_i)
sum = 0
for x in t do
  if s.bsearch{|si| x-si }
    sum += 1
  end
end
printf("%d\n",sum)


Measured memory_bytes: 15392
#include <iostream>
#include <algorithm>

int main(int argc, char const *argv[])
{
    int a[3] = {};

    std::cin >> a[0] >> a[1] >> a[2];

    std::sort(a, a+3);

    std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;

    return 0;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

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

string cmp(string, string);

int main(void){
    for(int w, h; cin >> w >> h, w;){
        vector<string> c(h);
        rep(y, h){
            cin >> c[y];
        }

        vector<vs> dp(h, vs(w));
        
        for(int y = h - 1; 0 <= y; y--){
            for(int x = w - 1; 0 <= x; x--){
                if('A' <= c[y][x] && c[y][x] <= 'Z') continue;

                string right, under;
                right = x + 1 < w ? dp[y][x + 1]:"";
                under = y + 1 < h ? dp[y + 1][x]:"";

                right.insert(0, 1, c[y][x]);
                under.insert(0, 1, c[y][x]);

                dp[y][x] = cmp(right, under);
            }
        }

        string res = "0";
        rep(y, h) rep(x, w) res = c[y][x] != '0' ? cmp(res, dp[y][x]):res;

        cout << res << endl;
    }

	return 0;
}

string cmp(string a, string b){
    if(a.size() > b.size()){
        return a;
    }
    else if(a.size() < b.size()){
        return b;
    }
    else{
        if(a > b){
            return a;
        }
        else return b;
    }
}

Measured memory_bytes: 1352
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
  a = x[N-i-1][0]
  b = x[N-i-1][1]
  c = b - (a % b)
  if a % b == 0:
    c = 0
  if ans <= c:
    ans = c
  elif (ans - c) % b != 0:
      n = (ans - c) // b
      ans = (n+1)*b + c
print(ans)

Measured memory_bytes: 27380
void main(){
	int r = _scan();
	if( r<1200 )writeln("ABC");
	else if( r<2800 )writeln("ARC");
	else writeln("AGC");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

using namespace std;
const int N = 1e6+100;
typedef long long ll;
int main(){
	string s;
	int n,k;
	cin>>n>>k>>s;
	s[k-1]=s[k-1]+('a'-'A');
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, K;
  cin >> N >> K;
  if (N % K == 0) {
    cout << '0' << endl;
  }
  else {
    cout << '1' << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    while(True):
        N, M = map(int, input().split())
        if(N == 0 and M == 0):
            return
        skc = []
        for i in range(M):
            skc.append(list(map(int, input().split())))
        point = [0 for i in range(N)]
        for i in range(M):
            for j in range(2, len(skc[i])):
                point[skc[i][j] - 1] += skc[i][0]
        point_fixed = [0 for i in range(N)]
        for i in range(M):
            if(skc[i][1] == 1):
                point_fixed[skc[i][2] - 1] += skc[i][0]
        maxPlayer = 0
        Max = 0
        for i in range(N):
            if(Max < point[i]):
                Max = point[i]
                maxPlayer = i + 1
        minPlayer = 0
        Min = 1e9
        for i in range(N):
            if(i + 1 == maxPlayer):
                continue
            if(Min > point_fixed[i]):
                Min = point_fixed[i]
                minPlayer = i + 1        
        print(point[maxPlayer - 1] - point_fixed[minPlayer - 1] + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9864
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    A = read_int_list()
    if sum(A) >= 22:
      print('bust')
    else:
      print('win')


main()


Measured memory_bytes: 3696
#include <stdio.h>

char map[9][9];

void kibaku(int,int);

main(){
  int i,j,k,n,x,y;

  scanf("%d", &n);
  getchar();

  for(i=0;i<n;i++){
    getchar();
    for(j=0;j<8;j++){
      for(k=0;k<8;k++){
	scanf("%c", &map[j][k]);
      }
      getchar();
    }


    scanf("%d%d", &x, &y);
    getchar();
    x--;
    y--;
    kibaku(y,x);

    printf("Data %d:\n", i+1);

    for(j=0;j<8;j++){
      for(k=0;k<8;k++){
	printf("%c", map[j][k]);
      }
      printf("\n");
    }
  }
  return 0;
}

void kibaku(int y, int x){
  int i, j, tx, ty;
  int dx[12]={0,0,0,1,2,3,0,0,0,-1,-2,-3};
  int dy[12]={-1,-2,-3,0,0,0,1,2,3,0,0,0};

  map[y][x]='0';
  for(i=0;i<12;i++){
    tx = x + dx[i];
    ty = y + dy[i];
    if(tx<0 || tx>7 || ty<0 || ty>7) continue;

    if(map[ty][tx]=='1'){
      kibaku(ty,tx);
    }
  }

  return;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll n; cin >> n;
   ll ans = (n*(n+1))/2;
   ans -= (((n/3)*((n/3)+1))/2)*3;
   ans -= (((n/5)*((n/5)+1))/2)*5;
   ans += (((n/15)*((n/15)+1))/2)*15;
   cout << ans << endl;
}

Measured memory_bytes: 3644
S = str(input())

odd_list = ['R', 'U', 'D']
even_list = ['L', 'U', 'D']
indic_list = []
newS = []

for j in S:
    newS.append(j)

for index, i in enumerate(newS):
    if (index+1) % 2 == 0:
        if i in even_list:
            indic_list.append(True)
        else:
            indic_list.append(False)
    else:
        if i in odd_list:
            indic_list.append(True)
        else:
            indic_list.append(False)

if all(indic_list):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
#define int ll
ll dp[20][20][2],bit[20];
ll dfs(int pos,ll pre,bool lim=1,bool lz=1){
	if(pos==-1)return 1;
	ll &x=dp[pos][pre][lz];
	if(!lim && x!=-1)return x;
	ll ans=0;
	int maxi=lim?bit[pos]:9;
	repeat(i,0,maxi+1){
		if(!lz && abs(i-pre)>1)continue;
		ans+=dfs(pos-1,i,
			lim && i==maxi,
			lz && i==0);
	}
	//cout<<pos<<' '<<pre<<' '<<lim<<' '<<lz<<' '<<ans<<endl;
	if(!lim)x=ans;
	return ans;
}
ll solve(ll n){
	int len=0;
	while(n)bit[len++]=n%10,n/=10;
	return dfs(len-1,0)-1;
}
signed main(){
	mst(dp,-1); //在很多时候dp值可以反复使用
	ll n; cin>>n;
	ll l=0,r=10000000000ll;
	while(l<=r){
		ll m=(l+r)/2;
		if(solve(m)>=n)r=m-1;
		else l=m+1;
	}
	//orz(solve(3234566667));
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int memo[3005][3005][2];
int n, S;
ll MOD = 998244353;
vi a;

ll solve(int i, int s, int flag){
    if (i == n || s < 0) return s == 0;
    if (memo[i][s][flag] != -1) return memo[i][s][flag];
    ll ans = 0;
    if (!flag){
        ans += solve(i, s, 1);
        ans += solve(i+1, s, 0);
        ans %= MOD;
    }else{
        if (!s) ans++;
        ans += solve(i+1, s - a[i], 1);
        ans += solve(i+1, s, 1);
        ans %= MOD;
    }
    return memo[i][s][flag] = ans%MOD;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> S;
    memset(memo, -1, sizeof(memo));
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cout << solve(0, S, 0) << "\n";
}

Measured memory_bytes: 71296
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

#define MAX_N 100005

const int mod = 1e9+7;
int fact[MAX_N] ,factinv[MAX_N];

int nCr(int n ,int r){
    if(r > n || r < 0) return 0;
    return 1LL*fact[n]*factinv[n-r]%mod*factinv[r]%mod;
}
int modinv(int a ,int p=mod-2){
    int x = 1;
    for( ; p; p>>=1){
        if(p&1)
            x = 1LL*x*a%mod;
        a = 1LL*a*a%mod;
    }
    return x;
}

int main()
{
    fact[0] = factinv[0] = 1;
    for(int i=1; i<MAX_N; i++){
        fact[i] = 1LL*i*fact[i-1]%mod;
        factinv[i] = modinv(fact[i]);
    }

    int n;
    scanf("%d",&n);
    int bd1 = -1 ,bd2 = -1;
    vector <int> a(n+1) ,pos(n+1 ,-1);
    for(int i=0; i<=n; i++){
        scanf("%d",&a[i]);
        if(~pos[a[i]])
            bd1 = pos[a[i]] ,bd2 = i;
        pos[a[i]] = i;
    }

    for(int k=1; k<=n+1; k++)
        printf("%d\n",(mod+nCr(n+1 ,k)-nCr(n-bd2+bd1 ,k-1))%mod);
}


Measured memory_bytes: 2816
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << (a.back() == b[0] && b.back() == c[0] ? "YES" : "NO") << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
typedef struct mobile {
  int ll;
  int lr;
  int il;
  int ir;
  int w;
} mb;
mb a[101];
int gcd(int a,int b)
{
  int r = a % b;
  if (r == 0) return b;
  return gcd(b,r);
}
int lcm(int a,int b)
{
  int g = a > b ? gcd(a,b) : gcd(b,a);
  return a / g * b;
}
int weight(int i)
{
  mb *p = &a[i];
  int lw,rw,g;
  if (i == 0) return 1;
  if (p->w != 0) return p->w;
  lw = weight(p->il);
  rw = weight(p->ir);
  lw /= (lw > p->lr) ? gcd(lw,p->lr) : gcd(p->lr,lw);
  rw /= (rw > p->ll) ? gcd(rw,p->ll) : gcd(p->ll,rw);
  p->w = (p->ll + p->lr) * lcm(lw,rw);
  return p->w;
}
int main()
{
  int n,i,j,w,mw;
  for(;;){
    scanf("%d",&n);
    if(n == 0) break;
    memset(a,0,sizeof(a));
    for(i=1;i<=n;i++){
      scanf("%d%d%d%d",&a[i].ll,&a[i].lr,&a[i].il,&a[i].ir);
      j = a[i].ll > a[i].lr ? gcd(a[i].ll,a[i].lr) : gcd(a[i].lr,a[i].ll);
      if(j != 0){
	a[i].ll /= j;
	a[i].lr /= j;
      }
    }
    mw = 0;
    for(i=1;i<=n;i++){
      w = weight(i);
      if(mw<w) mw = w;
    }
    printf("%d\n",mw);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int y,m,d;
		cin>>y>>m>>d;
		int miri=0,sum=0;
		for(int j=1;j<1000;j++){
			for(int k=1;k<=10;k++){
				if(j%3==0)miri+=20;
				else {
					if(k%2==1)miri+=20;
					else miri+=19;
				}
			}
		}
		for(int j=1;j<y;j++){
			for(int k=1;k<=10;k++){
				if(j%3==0)sum+=20;
				else {
					if(k%2==1)sum+=20;
					else sum+=19;
				}
			}
		}
		for(int j=1;j<m;j++){
			if((y)%3==0)sum+=20;
			else{
			if(j%2==1)sum+=20;
			else sum+=19;
			}
		}
		sum+=d;
		cout<<miri-sum+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<numeric>

using namespace std;

int main(){
  int n ; cin>> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  long long x = 0, y = 0;
  if(n % 2){
    for(int i = 0; i < (n-1)/2-1 ; i++){
      x += a[i] * 2;
    }
    for(int i = 0; i < (n-1)/2 ; i++){
      y += a[i] * 2;
    }
    x += a[(n-1)/2-1] + a[(n-1)/2];
    y -= a[(n-1)/2] + a[(n-1)/2+1];
    for(int i = (n-1)/2+1; i < n; i++){
      x -= a[i] * 2;
    }
    for(int i = (n-1)/2+2; i < n; i++){
      y -= a[i] * 2;
    }
    cout << max(x, y) << endl;
  }
  else{
    for(int i = 0; i < n/2-1; i++){
      x += a[i] * 2;
      y += a[i] * 2;
    }
    x += a[n/2-1] - a[n/2];
    y += a[n/2] - a[n/2-1];
    for(int i = n/2+1; i < n; i++){
      x -= a[i] * 2;
      y -= a[i] * 2;
    }
    cout << max(x, y) << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{
	int N;
	map<int, int> mp;
	cin >> N;

	/*for (int i = 2; i <= N; i++)
	{
		int x = i;
		for (int j = 2; j <= x; j++)
		{
			while (x % j == 0)
			{
				x /= j;
				mp[j]++;
			}
		}
	}
	ll ans = 1;
	for (auto x : mp)
	{
		ans = ((ans % mod) * (x.second+1) % mod) % mod;
	}

	cout << ans << endl;*/

	if (N >= 1200)
	{
		cout << "ARC" << endl;
	}
	else if (N < 1200)
	{
		cout << "ABC" << endl;
	}
	return 0;

		
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int mod = 1000000007;
ll f[100001] = {};
ll fact(ll x){
    if(x == 0) return 1;
    if(f[x] != 0) return f[x];
    else return f[x] = x * fact(x - 1) % mod;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, ans;
    cin >> n >> m;
    if(abs(n - m) < 1){
        ans = (2 * fact(n) % mod) * fact(n) % mod;
    }else if(abs(n - m) < 2){
        ans = fact(n) * fact(m) % mod;
    }else{
        ans = 0;
    }
    cout << ans << "\n";
    return 0;
}


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

int main()
{
	// 1<<29だとWA
	// 1LL<<60にするとAC
	const long long int INF = 1LL << 60;

	int N, K;
	cin >> N >> K;

	// K個分増やす（N+Kまでアクセスするため）
	vector<long long int> H(N+K+1, INF);
	for(int i = 0; i < N; i++) cin >> H[i];

	// K個分増やす（N+Kまでアクセスするため）
	vector<long long int> dp(N+K+1, INF);

	// 初期化
	dp[0] = 0;

	for(int i = 0; i < N; i++)
	{
		for(int j = 1; j <= K; j++)
		{
			dp[i+j] = min(dp[i+j], dp[i] + abs(H[i] - H[i+j]));
		}
	}

	// N番目までの最小コストが分かればよい
	cout << dp[N-1] << endl;

	return 0;
}


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

const ll mod = 998244353;
const ll zero = 0;

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<ll> l(k), r(k);
    rep(i,k) cin >> l[i] >> r[i];
    
    vector<ll> dp(n+1);
    dp[1] = 1;
    for(int i = 2; i <= n; i++) {
        ll route = 0;
        rep(j,k) {
            if(i-l[j] > 0) {
                route += dp[i-l[j]] - dp[max(i-r[j]-1,zero)];
                route %= mod;
            }
        }
        dp[i] = (dp[i-1] + route) % mod;
        //cout << dp[i] << endl;
    }
    
    ll ans = dp[n] - dp[n-1];
    if(ans < 0)
        ans += mod;
    cout << ans << endl;
    
    
    
    return 0;
}




Measured memory_bytes: 4816
//Never stop chasing!-MD.SOURAV.

// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll             long long int
#define li              ong int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define MOD 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
#define ignore         cin.ignore (std::numeric_limits<std::streamsize>::max(),'\n');
 #define sex(a,b,n)   ( n>=a && n<=b)
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;
typedef vector<pair<ll,ll>> vpllll;
typedef vector<pair<int,int>> vpiiii;
typedef map<ll,ll> mllll;
typedef map<char,ll> mchll;
typedef map<string,ll>msll;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

     int a,b,c;
     cin>>a>>b>>c;
     int k;
     cin>>k;
     int cnt=0;
     if(b<=a)
	 {
	 	while(b<=a)
		{
			b=b*2;
			cnt++;
		}
	 }
	 if(c<=b)
	 {
	 	while(c<=b)
		{
			c=c*2;
			cnt++;
		}
	 }
	 if(cnt<=k)
	 {
	 	cout << "Yes";
	 }
	 else
	 {
	 	cout << "No";
	 }



}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
   // cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

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

using namespace std;

int main() {
	vector<string> oput;
	string S, T;
	cin >> S >> T;
	string tmp;
	if (T.size() > S.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	//cout << S.size() - T.size() << endl;
	for (int i = 0; i <= S.size() - T.size(); i++) {
		
		for (int j = 0; j < T.size(); j++) {
			if (S[i + j] != '?') {
				if (T[j] != S[i + j]) {
					goto conti;
				}
			}
		}
		
		tmp.clear();
		for (int j = 0; j < S.size(); j++) {
			if (j < i) {
				if (S[j] == '?')tmp += 'a';
				else tmp += S[j];
			}
			else if (i <= j && j < i + T.size()) {
				tmp += T[j - i];
			}
			else {
				if (S[j] == '?')tmp += 'a';
				else tmp += S[j];
			}
		}
		oput.push_back(tmp);
		
	conti:;
	}
	if (oput.size() == 0) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	sort(oput.begin(), oput.end());
	cout << oput[0] << endl;
	return 0;
}

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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  if (A == 0) {
    cout << 0 << endl;
  } else {
    if (N % (A + B) <= A) {
      cout << N/(A+B) * A + N%(A+B) << endl;
    } else {
      cout << N/(A+B) * A + A << endl;
    }
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int n;
long long W;
long long w[44],v[44];
const long long inf=1000000000000000001ll;
int target=20;
vector<pair<long long,long long> > res;
vector<pair<long long,long long> > res2;
void dfs(int i,long long ww,long long vv){
	if(i==target){if(ww<=W)res.push_back({ww,vv});return;}
	dfs(i+1,ww,vv);
	dfs(i+1,ww+w[i],vv+v[i]);
}
long long find(long long ww){
	pair<long long,long long> p=make_pair(ww,inf);
	int i=lower_bound(res2.begin(),res2.end(),p)-res2.begin()-1;
	if(i<0||i>=res2.size())return 0;
	return res2[i].second;
}
void dfs2(int i,long long ww,long long vv){
	if(i==target){if(ww<=W)res2.push_back({ww,vv});return;}
	dfs2(i+1,ww,vv);
	dfs2(i+1,ww+w[i],vv+v[i]);
}
int main(){
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>v[i]>>w[i];
	target=n/2;dfs(0,0,0);
	target=n;dfs2(n/2,0,0);
	sort(res2.begin(),res2.end());
	for(int i=res2.size()-2;i>=0;i--)
		while(i<(int)res2.size()-1&&res2[i+1].second<res2[i].second)res2.erase(res2.begin()+i+1);
	long long ans=0;	
	for(int i=0;i<res.size();i++)
		ans=max(ans,res[i].second+find(W-res[i].first));
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 43764
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for(int i = 0; i < N; i++){
    ans = min(ans + K, 2 * ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256