akhauriyash/Code-Regression huggingface dataset:
n = int(input())
hs = list(map(int, input().split()))

cnt = 0
cnt_max = 0
for i in range(n-1):
  if hs[i] >= hs[i+1]:
    cnt += 1
    cnt_max = max(cnt, cnt_max)
  else:
    cnt_max = max(cnt, cnt_max)
    cnt = 0
    
print(cnt_max)

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

int main() {
	char a, b;
	cin >> a >> b;
	if (b == 'H') {
		if (a == 'H')cout << "H";
		else cout << "D";
	}
	else {
		if (a == 'D')cout << "H";
		else cout << "D";
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int[] a = new int[n];
		
		ArrayList<int[]>[] t = new ArrayList[n];
		for (int i = 0; i < n; i++)
			t[i] = new ArrayList<>();
		
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
			for (int j = 0; j < a[i]; j++) {
				int x = in.nextInt() - 1;
				int y = in.nextInt();
				t[i].add(new int[]{x, y});
			}
		}

		int max = 0;
		for (int i = 0; i < (1 << n); i++) {
			boolean valid = true;
			for (int j = 0; j < n; j++) {
				boolean p = ((1 << j) & i) > 0;
				for (int[] tt : t[j]) {
					boolean x = ((1 << tt[0]) & i) > 0;
					if (p && x && tt[1] == 0)
						valid = false;
					if (p && !x && tt[1] == 1)
						valid = false;
				}
			}
			if (valid)
				max = (int) Math.max(max, Integer.bitCount(i));
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 39128
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
flag = [False] * 26
for si in s:
    flag[ord(si) - ord('a')] = True
for ti in t:
    if not flag[ord(ti) - ord('a')]:
        print(-1)
        quit()
n = len(s)
S = s + s
idx = [[] for _ in range(26)]
for i in range(2*n):
    idx[ord(S[i]) - ord('a')].append(i)

dp = [[inf] * 26 for _ in range(n)]
for i in range(n):
    for j in range(26):
        if idx[j]:
            r = br(idx[j], i)
            dp[i][j] = idx[j][r]
c = ord(t[0]) - ord('a')
i = idx[c][0]
ans = i + 1
for ti in t[1:]:
    c = ord(ti) - ord('a')
    ni = dp[i][c] % n
    ans += dp[i][c] - i
    i = ni
print(ans)

Measured memory_bytes: 133472
N = int(input())
A = [None]*N
x = [[None]*N for _ in range(N)]
y = [[None]*N for _ in range(N)]

for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        x[i][j],y[i][j] = map(int, input().split())
        

ans =0
for num in range(2**N):
    #bit = bin(num)#正直者リスト
    flag = 1 #これが1のままならOK
    
    #N人を順に見る
    for i in range(N):
        #下からi桁目を取り出す
        if (num>>i & 1)==1:#正直者なら検討
            
            #各発言に対して，NGケースを調査
            for j in range(N):
                #xijの対応に注意，文章では1から
                if x[i][j] != None and y[i][j]!=(num>>(x[i][j]-1) & 1):
                    flag = 0
                elif x[i][j] == None:
                    break
        if flag ==0:
            break
    if flag ==1:
        ans = max(ans,bin(num).count("1"))
print(ans)

Measured memory_bytes: 42348
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int parent,left,right;};

struct Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL){
    h1=setHeight(T[u].left)+1;
  }
  if(T[u].right!=NIL){
    h2=setHeight(T[u].right)+1;
  }
  return H[u]=(h1>h2?h1:h2);
}

int getSibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
    return T[T[u].parent].right;
  return NIL;  
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent==NIL){
    printf("root\n");
  }else if(T[u].left== NIL&&T[u].right==NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,i,l,r,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].parent=NIL;

  for(i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }

  for(i=0;i<n;i++) if(T[i].parent==NIL) root=i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++) print(i);

  return 0;
}

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

int main() {

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


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

int main(){
    string s,s2;
    string ans = "Yes";
    cin >> s;
    cin >> s2;
    rep(i,s.size()){
        if(s[i]!=s2[i]){
            ans = "No";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3132
/////////////////////////   _LeMur_
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
//#include <chrono>
//#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
int a[N];

long long dp[N][6];

int calc(int i,int j){
    if(j == 0 || j == 4)return a[i];
    if(j == 1 || j == 3){
        if(a[i] == 0)return 2;
        return a[i] % 2;
    }
    return 1 - a[i] % 2;
}

int main() {
    //mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<5;i++){
        dp[0][i] = 0;
    }
    for(int i=1;i<=n;i++){
        long long mn = inf * 1ll * inf;
        for(int j=0;j<5;j++){
            mn = min(mn , dp[i - 1][j]);
            dp[i][j] = mn + calc(i , j);
        }
    }
    long long answ = dp[n][0];
    for(int i=0;i<5;i++){
        answ = min(answ , dp[n][i]);
    }
    cout<<answ<<endl;
	return 0;
}
/*
9 6
1 2 3
1 3 1
1 4 2
2 5 6
2 6 2
4 7 4
4 8 2
8 9 5
2 9
9 2
5 9
6 9
7 9
6 5
*/


Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) ((x).begin(), (x).end())
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int x, y;
    cin >> x >> y;
    int a, b, c;
    cin >> a >> b >> c;
    priority_queue<ll> r;
    priority_queue<ll, vector<ll>, greater<ll>> p, q;
    rep(i, a) {
        int x;
        cin >> x;
        p.push(x);
    }
    rep(i, b) {
        int x;
        cin >> x;
        q.push(x);
    }
    rep(i, c) {
        int x;
        cin >> x;
        r.push(x);
    }
    while(p.size() > x)
        p.pop();
    while(q.size() > y)
        q.pop();
    while(!r.empty()) {
        if(q.top() < p.top() && q.top() < r.top()) {
            q.pop();
            q.push(r.top());
            r.pop();
            continue;
        }
        if(p.top() <= q.top() && p.top() < r.top()) {
            p.pop();
            p.push(r.top());
            r.pop();
            continue;
        }
        break;
    }
    ll ans = 0;
    while(!p.empty()) {
        ans += p.top();
        p.pop();
    }
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;

    return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    string s;
    cin >> s;
    //string t =s;
    
    string r[4] = {"dream", "dreamer", "erase", "eraser" };
    
    bool flg = false;
    
    while(s.size()>0){
//        string t =s.substr(0,);
        if(s.size()>=7 && s.substr(s.size()-7,7) ==r[1]){
            s.erase(s.size()-7,7);
        }
        else if(s.size()>=5 &&s.substr(s.size()-5,5) ==r[0]){
            s.erase(s.size()-5,5);
        }
        else if(s.size()>=6 &&s.substr(s.size()-6,6) ==r[3]){
            s.erase(s.size()-6,6);
        }
        else if(s.size()>=5 && s.substr(s.size()-5,5) ==r[2]){
            s.erase(s.size()-5,5);
        }
        else{
            break;
        }
        
        if(s.size()==0){
            flg = true;
            break;
        }
           
    }
    
    if(flg)
        cout << "YES"<<endl;
    else
        cout << "NO"<<endl;
    
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAX (ll)(2e5 + 1)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int n;
	cin >> n;
	bool fl = 0;
	for (int i = 0; i < n; i++) {
		int va;
		cin >> va;
		if (va % 2 == 0) {
			if (va % 3 && va % 5) {
				fl = 1;
			}
		}
	}
	if (fl) {
		cout << "DENIED\n";
	}
	else {
		cout << "APPROVED\n";
	}
}
	
					


Measured memory_bytes: 256
S = list(input())
T = list(input())

sd = dict()
td = dict()
ans = True
for s, t in zip(S, T):
    if s not in sd:
        sd[s] = t
    else:
        if sd[s] != t:
            ans = False
            break

    if t not in td:
        td[t] = s
    else:
        if td[t] != s:
            ans = False
            break

print("Yes" if ans else "No")

Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, t, a;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> t;
	map<int, int> mp;
	cin >> a;
	int mi = a, ma = 0;
	for (int i = 1; i < n; i++) {
		cin >> a;
		if (a < mi) mi = a;
		else {
			mp[a-mi]++;
			ma = max(ma, a-mi);
		}
	}
	cout << mp[ma] << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(void){
   int W,H,x,y,r;
   
   scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
   
   if(x-r<0||x+r>W){
       if(y-r<0||y+r>H){
       printf("No\n");
       }else if(y-r>=0&&y+r<=H){
           printf("No\n");
       }
   }else if(x-r>=0&&x+r<=W){
       if(y-r<0||y+r>H){
           printf("No\n");
       }else if(y-r>=0&&y+r<=H){
       printf("Yes\n");
   }
       return(0);
   }
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  string t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  //sort~reverseで降順に並べ替えられる！
  bool b = false;
  if(s<t){
    b = true;
  }
  if(b) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<bool> e(m, true);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    vector<bool> tmp(m, false);
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      tmp[--a] = true;
    }
    for (int i = 0; i < m; i++) {
      e[i] = e[i] && tmp[i];
    }
  }
  int ret = 0;
  for (int i = 0; i < m; i++) {
    if (e[i]) {
      ret++;
    }
  }
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 256
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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


char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int a; cin >> a;
    if(a == 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3632
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.format,
       std.math;

void main()
{
	auto n = readln.chomp.to!int;
	int i = 1;
	while(true){
		if(n < i^^2) break;
		else i++;
	}
	writeln((i-1)^^2);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int x,y;cin>>x>>y;

  int g[12]={0,2,0,1,0,1,0,0,1,0,1,0};

  cout<<(g[x-1]==g[y-1]?"Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// solve by union find

const int N_MAX = 100010;
ll parent[N_MAX] = {};

int findRoot(int x){
    if(parent[x] == x){
        return x;
    }else{
        // 経路圧縮
        return parent[x] = findRoot(parent[x]);
    }
}

bool sameGroup(int x, int y){
    return findRoot(x) == findRoot(y);
}

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

    // input
    int N, M;
    cin >> N >> M;

    vector<ll> P(N);
    FOR(i, 0, N){
        cin >> P.at(i);
    }

    vector< pair<int, int> > XY;
    XY.reserve(M);
    FOR(i, 0, M){
        int x, y;
        cin >> x >> y;
        XY.push_back(make_pair(x, y));
    }

    FOR(i, 0, N){
        parent[i] = i;
    }

    for(auto xy : XY){
        int x = xy.first - 1;
        int y = xy.second - 1;

        int parent_x = findRoot(x);
        int parent_y = findRoot(y);
        parent[parent_x] = parent_y;
    }

    int answer = 0;
    FOR(i, 0, N){
        if(sameGroup(i, P[i]-1)){
            answer++;
        }
    }

    p(answer);
    
    return 0;
}

Measured memory_bytes: 2560
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    if min(A) == 0:
        return 0
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            return -1
    return ans


def main():

    sys.setrecursionlimit(10 ** 6)

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


if __name__ == '__main__':
    main()


Measured memory_bytes: 90080
//code_sm
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int k,a,b;
bool flg=1;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flg=0;
    cout<<"OK";
    break;
        }
    }
    if(flg)
    cout<<"NG";
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int a,b,c;
    cin >> a >> b >> c;
    int ans=min(a+b, min(b+c, c+a));
    cout << ans << endl;

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


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

int main(){
    int N;
    long long ans = 0, sum =0;
    int mod = 1000000000+7;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        sum += a.at(i);
        sum %= mod;
    }
    for (int i = 0; i < N-1; i++) {
        sum -= a.at(i);
        if(sum<0) sum += mod;
        ans += sum * a.at(i);
        ans %= mod;
    }
    cout << ans << endl;
}
/*

*/

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 r; cin >> r;
  cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  int n, k;
  cin >> n >> k;
  vector<long long int> s;
  long long int sum = 0;
  s.push_back(0);
  for(int i=0;i<n;i++){
    int p;
    cin >> p;
    sum += p+1;
    s.push_back(sum);
  }
  int max = 0.0;
  for(int i=0;i<n-k+1;i++){
    long long int c = s[i+k]-s[i];
    if(c>max){
      max = c;
    }
  }
  cout << fixed << setprecision(10) << (double)max/2.0 << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  if (c >= a && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const int mod=1e9+7;
int mu(int a,int b){
  return (long long)a*b%mod;
}
int ad(int a,int b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
int pw(int a,int b,int c=1){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
int dv(int a,int b){
  return mu(a,pw(b,mod-2));
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N , M;
  cin >> N >> M;
  ll a[M];
  rep(i, M){
    cin >> a[i];
  }

  ll dp[N+1];
  dp[0]=1;
  ll kaidan_i=0;
  rep1(i, N){
    if(i==a[kaidan_i]){
      dp[i] = 0;
      kaidan_i++;
    }
    else{
      if(i==1){
	dp[i] = dp[i-1];
      }
      else{
	dp[i] = ad(dp[i-1], dp[i-2]);
      }
    }
  }
  cout << ad(dp[N],0) << endl;
  return 0;
    

}


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

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

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

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

  ll N;
  cin>>N;

  vector<ll>ans;
  while(N>0){
    N--;
    ans.push_back(N%26ll);
    N/=26ll;
  }
  reverse(rng(ans));
  for(int i=0;i<ans.size();i++)cout<<(char)((ans[i])%26+'a');
  cout<<endl;

  return 0;
}


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

typedef pair<int,int> P;
const int INF = 500000000;

int main(){
    double l;
    cin >> l;
    double d = l/3.0;
    cout << fixed << setprecision(15) << d*d*d << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
	fast;
	ll a,b;
	cin>>a>>b;
	cout<<a*b;
	return 0;
}

//0,7569








Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		long x=sc.nextLong();
		long a[]=new long[n];
		long sum;
		int counter=0;


		for (int i=0;i<n;++i){
			a[i]=sc.nextLong();
		}

		Arrays.sort(a);
		sum=0;

		for (int i=0;i<n;++i){
			x=x-a[i];
			if(x>=0) ++counter;
			else break;
		}

		if(x<=0)System.out.println(counter);
		if(x>0)System.out.println(counter-1);

	}
}

Measured memory_bytes: 23764
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int main(){
    int a, b, h;
    scanf("%d %d %d", &a, &b, &h);
    printf("%d\n", ((a + b) * h) / 2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ABS(a, b) ((a) < (b) ? (b) - (a) : (a) - (b))

int main()
{
    int N;
    cin >> N;
    int A[N+2];
    for(int i = 1; i <= N; ++i ) cin >> A[i];
    A[0] = 0, A[N+1] = 0;
    int cnt = 0;
    for(int i = 0; i <= N; ++i) {
        cnt += ABS(A[i], A[i+1]);
    }
    for(int i = 1; i <= N; ++i) {
        cout << cnt + ABS(A[i-1], A[i+1]) - ABS(A[i-1], A[i]) - ABS(A[i], A[i+1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    // 累積和
    vector<ll> c_sum(n);
    for(int i = 0; i < n; i++){
        if(i == 0)  c_sum[i] = a[i];
        else    c_sum[i] = c_sum[i - 1] + a[i];
    }
    
    bool flag = true;
    for(int i = 1; i < n; i++){
        if(c_sum[i - 1] * c_sum[i] >= 0){
            flag = false;
        }
    }
    if(flag){       // flag = trueならば入力時点で成立
        cout << 0 << endl;
        return 0;
    }
    
    vector<ll> temp1(n), temp2(n);      // 走査用に累積和を格納しておくコンテナ
    for(int i = 0; i < n; i++){
        temp1[i] = c_sum[i];
        temp2[i] = c_sum[i];
    }
    
    ll ans;
    ll change = 0;
    ll cnt = 0;
    
    // a[0] > 0     正→負→正…
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            temp1[i] += change; 
            if(temp1[i] <= 0){
                change += 1 - temp1[i];
                cnt += abs(1 - temp1[i]);
                temp1[i] = 1;
            }
        }
        else{
            temp1[i] += change;
            if(temp1[i] >= 0){
                change += -1 - temp1[i];
                cnt += abs(-1 - temp1[i]);
                temp1[i] = -1;
            }
        }
    }
    ans = cnt;
    
    // a[0] < 0     負→正→負…
    change = 0;
    cnt = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            temp2[i] += change;
            if(temp2[i] >= 0){
                change += -1 - temp2[i];
                cnt += abs(-1 - temp2[i]);
                temp2[i] = -1;
            }
        }
        else{
            temp2[i] += change;
            if(temp2[i] <= 0){
                change += 1 - temp2[i];
                cnt += abs(1 - temp2[i]);
                temp2[i] = 1;
            }
        }
    }
    ans = min(ans, cnt);
    
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }

vector<vector<int>> dp;

int lcs(const string &x, const string &y, int i, int j) {
    if (i >= x.size() || j >= y.size()) return 0;
    if (dp[i][j] >= 0) return dp[i][j];
    int ret = 0;
    ret = max(ret, lcs(x, y, i + 1, j));
    ret = max(ret, lcs(x, y, i, j + 1));
    if (x[i] == y[j]) ret = max(ret, lcs(x, y, i + 1, j + 1) + 1);
    return dp[i][j] = ret;
}

int lcs(const string &x, const string &y) {
    for (int i = x.size() - 1; i >= 0; --i) {
        for (int j = y.size() - 1; j >= 0; --j) {
            dp[i][j] = max(dp[i][j], dp[i + 1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j + 1]);
            if (x[i] == y[j]) dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1);
        }
    }
    return dp[0][0];
    // return lcs(x, y, 0, 0);
}

int main() {
    int n;
    string x, y;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        dp = vector<vector<int>>(x.size() + 5, vector<int>(y.size() + 5, 0));
        cout << lcs(x, y) << endl;
    }
    return 0;
}



Measured memory_bytes: 10780
#include <iostream>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <cstdlib>
#include <iterator>
#include <algorithm>
#include <functional>
#include <random>
#include <bits/stdc++.h>

#include <stdio.h>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>

typedef long long ll;
using namespace std;

#define FOR(i,N) for(int i=0;i<N;i++) 
#define RFOR(i,N) for(int i=N-1;i>=0;--i)
#define COUT(str) cout << str << endl

#define MAX_N 100 //"long long","int"かを変えること!!!!

//入力
int h,w ;
string BUR[105];

int main() {
	int h, w;

	cin >> h >> w;

	FOR(i, h) {
		cin >> BUR[i];

		COUT(BUR[i]);

		COUT(BUR[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 1987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007LL
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
//int dx[] = { 0,0,1,-1 }, dy[] = { 1,-1,0,0 };
int dx[] = { 0,0,0,1,1,1,-1,-1,-1 }, dy[] = { 1,0,-1,1,0,-1,1,0,-1 };

set<Pi> S;
map<Pi, int> M;
ll cnt[10];
int main() {
	int h, w, n;
	scanf("%d%d%d", &h, &w, &n);
	while (n--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		S.insert(Pi(x, y));
	}
	set<Pi>::iterator it;
	for (it = S.begin(); it != S.end(); it++)
	{
		int x = it->X, y = it->Y;
		fup(i, 0, 8, 1)
		{
			int nx = x + dx[i], ny = y + dy[i];
			if (nx <= 1 || nx >= h || ny <= 1 || ny >= w)continue;
			if (M[Pi(nx, ny)])continue;
			int cnt = 0;
			fup(ii, 0, 8, 1)
			{
				int nnx = nx + dx[ii], nny = ny + dy[ii];
				if (S.find(Pi(nnx, nny)) != S.end())cnt++;
			}
			M[Pi(nx, ny)] = cnt;
		}
	}
	map<Pi, int>::iterator it2;
	for (it2 = M.begin(); it2 != M.end(); it2++)
	{
		cnt[it2->second]++;
	}
	cnt[0] = (1LL * (h - 2)*(w - 2) - M.size());
	fup(i, 0, 9, 1)printf("%lld\n", cnt[i]);
}

Measured memory_bytes: 61184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define Q 1000000007
char v[1000][1000];
ll rec(ll i,ll j,ll n,ll m){
   // cout<<i<<" "<<j<<"\n";
    if(i==n && j==m) return 1;
    if(i>n || j>m) return 0;
    if(v[i-1][j-1]=='#') return 0;
    ll a=-1,b=-1;
    a=rec(i,j+1,n,m);
    b=rec(i+1,j,n,m);
    //cout<<a<<" "<<b<<"\n";
    if(a && b) return ((a)%Q+(b)%Q)%Q;
    else if(a) return a%Q;
    else return b%Q;
}

int main() {
   ll n,m;
   cin>>n>>m;
   char v[n][m];
   ll dp[n][m];
   for(int i=0;i<n;i++){
       for(int j=0;j<m;j++){
           cin>>v[i][j];
       }
   }
   dp[0][0]=1;
   for(int i=1;i<m;i++){
       if(v[0][i]=='#') dp[0][i]=0;
       else dp[0][i]=dp[0][i-1];
   }
   for(int i=1;i<n;i++){
       if(v[i][0]=='#') dp[i][0]=0;
       else dp[i][0]=dp[i-1][0];
   }
   for(int i=1;i<n;i++){
       for(int j=1;j<m;j++){
           if(v[i][j]=='#') dp[i][j]=0;
           else dp[i][j]=((dp[i-1][j])%Q+(dp[i][j-1])%Q)%Q;
       }
   }
   cout<<dp[n-1][m-1]<<"\n";
}

Measured memory_bytes: 12368
N,M=map(int,input().split())
A =list(map(int,input().split()))

Left = [0]*(N+1)
for i in range(1,N+1):
    Left[i] = (Left[i-1]+A[i-1])%M
Left = Left[1:]
Left.sort()

cnt = []
zero = Left.count(0)
Left = Left[zero:]
Num = len(Left)

for i in range(Num):
    if i == 0:
        cnt.append(1)
    else:
        if Left[i-1] == Left[i]:
            cnt[-1] += 1
        else:
            cnt.append(1)

res = 0
res += zero + (zero*(zero-1))//2

for c in cnt:
    if c > 1:
        res += (c*(c-1))//2
print(res)

Measured memory_bytes: 14480
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e18
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main(){
	int n, k;
	cin >> n >> k;
	vector<p> a(n);
	vector<ll> b(n);
	rep(i, n) {
		cin >> a[i].second >> a[i].first;
	}
	sort(a.rbegin(), a.rend());
	ll ans=0,knd = 0, sub = 0;
	vector<ll> cnt(n+1, 0), t;
	rep(i, k) {
		sub += a[i].first;
		if (cnt[a[i].second] == 0) {
			knd++;
		}
		else {
			t.push_back(i);
		}
		cnt[a[i].second]++;
	}
	ans = max(ans, sub+knd*knd);
	rep(i, n - k) {
		if (cnt[a[i + k].second] == 0&&t.size()!=0) {
			int j = t.back();
			t.pop_back();
			cnt[a[j].second]--;
			sub -= a[j].first;
			cnt[a[i+k].second]++;
			sub += a[i+k].first;
			knd++;
			ans = max(ans, sub+knd*knd);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  bool x = false;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      int a = i*m+j*n-i*j*2;
      if (a == k) x = true;
    }
  }
  dump(x ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 10000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int H,i,A[M+1];

  scanf("%d",&H);
  for(i = 1; i <= H; i++) scanf("%d",&A[i]);
  for(i = 1; i <= H; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H) printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}

    



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  vector<pi> a(n);
  rep(i,n){
    int v;
    cin>>v;
    a[i]=make_pair(v,i);
  } 
  sort(allr(a));
  vector<vi> dp(n+3,vi(n+3,-1));
  dp[0][0]=0;
  rep(k,n){
    int enjoy=a[k].first,start=a[k].second;
    rep(l,k+1){
      chmax(dp[l+1][k-l],dp[l][k-l]+enjoy*abs(start-l));
      chmax(dp[l][k-l+1],dp[l][k-l]+enjoy*abs(n-(k-l)-1-start));
    }
  }
  int res=0;
  rep(i,n+1) chmax(res,dp[i][n-i]);
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 34684
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

ll f(ll a, ll b)
{
	if (a == 0 || b == 0)
		return -a - b;
	if (a < b)
		return 2ll * a * (b / a) + f(a, b % a);
	return 2ll * b * (a / b) + f(a % b, b);	 
}

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	ll n, x;
	cin >> n >> x;	
	cout << n + f(x, n - x) << endl;

	return 0;
}



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

namespace ConsoleApplication1
{
    class SearchCombination
    {
        readonly int n, target, len;

        int count;

        public SearchCombination(int n, int s)
        {
            this.n = n;
            target = s;

            len = target < 10 ? target % 10 : 9;
        }

        public int Count()
        {
            count = 0;
            DFS(0, 0, 0);
            return count;
        }

        private void DFS(int depth, int cur, int sum)
        {
            if (depth == n)
            {
                if (sum == target) count++;
                return;
            }

            for (int i = cur; i <= len; i++)
            {
                DFS(depth + 1, i + 1, sum + i);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');

                int n = int.Parse(input[0]);
                int s = int.Parse(input[1]);

                if (n == 0 && s == 0) break;

                SearchCombination SC = new SearchCombination(n, s);

                sb.AppendLine(SC.Count().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9112
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li mod = 1e9 + 7;

int main() {
    li n, a, b;
    cin >> n >> a >> b;
    vector<li> ps(n);
    for (int i = 0; i < n; ++i) {
        cin >> ps[i];
        ps[i]--;
    }

    vector<li> costs(n, 1LL << 60);
    for (int i = 0; i < n; ++i) {
        const li x = ps[i];
        costs[x] = a * i;
        for (int j = 0; j < i; ++j) {
            if (ps[j] < x) {
                costs[x] = min(costs[x], costs[ps[j]]);
                costs[ps[j]] += a;
            } else {
                costs[ps[j]] += b;
            }
        }
    }
    const li ans = *min_element(costs.begin(), costs.end());
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 384
N=int(input())
T=1
A=1
for i in range(N):
    x,y=map(int,input().split())
    d1=1
    d2=1
    if T>x:
        d1=(T-1)//x+1
    if A>y:
        d2=(A-1)//y+1
    T=max(d1,d2)*x
    A=max(d1,d2)*y

print(T+A)

Measured memory_bytes: 38768
#include <iostream>
#include <vector>
#include <tuple>
#include <string.h>
#include <algorithm>
#include <map>
using namespace std;
const int MAX_N = 110;
const int MAX_XY = 310;

int dp[MAX_N][2 * MAX_XY][2 * MAX_XY];
bool ok[MAX_N][2 * MAX_XY][2 * MAX_XY];
int N;
vector<tuple<int, int, int, int>> A;
int memo(int pos, int x, int y){

  if (pos == N){
    //    cout << x << " " << y << endl;
    if (x >= 305 and y >= 305){
      return 0;
    }
    return -114514;
  }

  if (ok[pos][x][y]){
    return dp[pos][x][y];
  }
  ok[pos][x][y] = true;

  int res;
  res = -1141514;
  int a,b,c,d;
  
  tie(a, b, c, d) = A[pos];
  res = max(res, memo(pos + 1, x, y));
  if (x - a >= 0){
    res = max(res, memo(pos + 1, x - a, y + b));
  }
  if (y - c >= 0){
    res = max(res, memo(pos + 1,x, y - c) + d);
  }

  
  dp[pos][x][y] = res;
  return res;
}
int x,y;

int main(){

  cin >> N;
  cin >> x >> y;
  memset(ok, false, sizeof(ok));
  for (int i = 0; i < N; i++){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    A.push_back(make_tuple(a, b, c, d));
  }
  cout << memo(0, x + 305, y + 305) << endl;
  return 0;
}

Measured memory_bytes: 99300
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
        int x = sc.nextInt();
        int ans=max(0,n-x);
        if(1==x)ans=0;
        
        out.println(ans);
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}
//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int l,r,b;
    long s;
    P(int b, int l, int r, long s) {
    	this.b=b;
    	this.l=l;
        this.r=r;
        this.s=-s;
    }

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

int n;
ll k;
int arr[2005];

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

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

    ll ans = 0LL;
    for (int i=1; i<=n; i++) {
        ll smaller = 0LL;
        ll allSmaller = 0LL;
        for (int j=1; j<=n; j++) {
            if (arr[i] > arr[j]) {
                allSmaller++;
                if (j > i) {
                    smaller++;
                }
            }
        }
        ll tmp = (k*(k-1))/2;
        tmp %= MOD;
        tmp *= allSmaller;
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
        smaller = (k*smaller)%MOD;
        ans += smaller;
        ans %= MOD;
        //cout << "D: " << arr[i] << "  " << ans << "\n";
    }


    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	vint a;
	scan(N);
	rep(i,N){
		int A;
		scan(A);
		a.push_back(A);
	}
	sort(a.rbegin(),a.rend());
	int Alice=0,Bob=0;
	rep(i,N){
		if(i%2==0) Alice+=a[i];
		else Bob+=a[i];
	}
	prin(Alice-Bob);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/








int N, A[1010101];
//---------------------------------------------------------------------------------------------------
int solve() {
    rep(i, 0, N - 1) A[i] = abs(A[i] - A[i + 1]);
    N--;

    int tot = 0;
    rep(i, 0, N) if (A[i] == 1 && (i | (N - 1 - i)) == N - 1) tot ^= 1;
    if (tot) return 1;

    rep(i, 0, N) if (A[i] == 1) return 0;

    tot = 0;
    rep(i, 0, N) if (A[i] == 2 && (i | (N - 1 - i)) == N - 1) tot ^= 2;
    return tot;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N; string S; cin >> S;
    rep(i, 0, N) A[i] = S[i] - '0';
    cout << solve() << endl;
}







Measured memory_bytes: 5276
#include <stdio.h>

int main(void){
	setvbuf(stdout,NULL,_IONBF,0);

	char num[1001] = {};
	int i,sum;

	while(1){
		scanf("%s",num);
		if(num[0] == '0'){
			break;
		}
		else{
			sum = 0;
			for(i = 0;i < 1001;i++){
				if(num[i] == NULL){
					break;
				}
				else{
					sum += (num[i] - '0');
				}
			}
			printf("%d\n",sum);
		}
	}
	return 0;
}

Measured memory_bytes: 544