akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int dp[2009][2009],M[2009][2009],M1[2009][2009];
int a[2009];
main()
{
    int n,Z,W;
    cin>> n >> Z >> W;
    for (int i = 1; i <= n; i++)
        cin >> a[n-i+1];
        a[n+1] = W;
        a[n+2] = Z;
        n+=2;
    for (int i = 1; i <= n; i++)
    {
        dp[1][i]=abs(a[i]-a[1]);
        dp[i][1]=dp[1][i];
        M[1][i] = dp[1][i];
        M1[i][1] = dp[i][1];
    }
    for (int i = 2; i <= n; i++)
        for (int j = 2; j <= n; j++)
    {
        if(j == i) continue;
        if(i > j)
        {
            dp[i][j] = M[j-1][j];
            M[i][j] = max(dp[i][j],M[i-1][j]);
            M1[i][j] = min(dp[i][j],M1[i][j-1]);
        }
        else
        {
            dp[i][j] = M1[i][i-1];
            M[i][j] = max(dp[i][j],M[i-1][j]);
            M1[i][j] = min(dp[i][j],M1[i][j-1]);
        }
        //cout << i << " " << j <<" " << dp[i][j]<<endl;
    }
    cout<<dp[n][n-1]<<endl;
}


Measured memory_bytes: 47488
#include <bits/stdc++.h>
  
using namespace std;
 
#define endl "\n"
#define JAM(x) cout<< #x <<" = "<<x<<"\n"

 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef vector<PII> VPI;
 
const int INF=2e9;
const int MX=100005;
const int MOD=1000000007;
const double PI=acos(-1.0);



long long int power(long long int a,long long int b,long long m)
{
    a %= m;
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
bool isprime(int n)
{
    if(n==1)
    return 0;
    int i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}




/*_______________________________________________*/





int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,x,m,i;
    long long ans=0;
    cin>>n>>x>>m;
    map<long long ,int> mp;
    vector<long long> vec;
    for(i=0;i<n;i++)
    {
        if(mp.find(x)!=mp.end())
        break;
        mp[x]=i;
        ans+=x;
        vec.push_back(ans);
        x=power(x,2,m);
    }
    if(i>=n)
    cout<<ans;
    else
    {
        long long ind=mp[x];
        long long temp=vec[i-1];
        if(ind>0)
        temp-=vec[ind-1];
        long long temp1=(n-i)/(i-ind);
        ans+=temp1*temp;
        temp1=(n-i)%(i-ind);
        if(temp1)
        {
            ans+=vec[ind+temp1-1];
            if(ind>0)
            ans-=vec[ind-1];
        }
        cout<<ans;
    }
}


Measured memory_bytes: 6740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define MOD 1000000007;

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int h, w, arr[81][81];
bool dp[81][81][12801];

int main(){
	//IO("input.txt", "output.txt");
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h >> w;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++) cin >> arr[i][j];
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++){
			int val;
			cin >> val;
			arr[i][j] = abs(arr[i][j] - val);
		}
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
			if(i == 1 && j == 1) dp[i][j][arr[i][j]] = true;
			else
				for(int k = 0; k <= 12800; k++)
					if(dp[i - 1][j][k] || dp[i][j - 1][k]){
						int a = abs(k - arr[i][j]), b = abs(k + arr[i][j]);
						if(a <= 12800) dp[i][j][a] = true;
						if(b <= 12800) dp[i][j][b] = true;
					}
	for(int i = 0; i <= 12800; i++)
		if(dp[h][w][i]){
			cout << i << "\n";
			return 0;
		}
 	return 0;
}

Measured memory_bytes: 80896
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>x, A[i]=(x==i);
	for (int i=1; i<=n; i++) if (A[i]) A[++i]=0, ans++;
	cout<<ans<<'\n';
	
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    vector<int> p(N);

    for (int i = 0; i < N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int ans = 0;
    for (int i = 0; i < N; i++){
        if(i == N-1){
            ans += p[i] / 2;    
        }
        else {
            ans += p[i];
        }
    }
    cout << ans << endl;
}

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

void show_ret(int cards[], char suit) {
	int i;
	for (i = 1; i < 14; i++) {
		if (cards[i] == 0) cout << suit << " " << i << endl;
	}
}

int main() {
	int spades[14] = {0};
	int hearts[14] = {0};
	int clubs[14] = {0};
	int diamonds[14] = {0};
	int n, num = 0;
	char suit;
	int i;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> suit >> num;
		switch (suit) {
			case 'S':
				spades[num] = 1;
				break;
			case 'H':
				hearts[num] = 1;
				break;
			case 'C':
				clubs[num] = 1;
				break;
			case 'D':
				diamonds[num] = 1;
				break;
			default:
				break;
		}
	}
	show_ret(spades, 'S');
	show_ret(hearts, 'H');
	show_ret(clubs, 'C');
	show_ret(diamonds, 'D');
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
    int n,a[55];
    long long s=0;
    cin >> n;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for (int i=1;i<n;i++)
    {
        for (int j=i+1;j<=n;j++)
        {
            s+=(a[i]*a[j]);
        }
    }
    cout << s;
}

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

int main() {

    int n;
    cin >> n;
    int count = 0;
    rep(i, (n / 4) + 1){
        rep(j, (n / 7) + 1){
            if((i * 4 + j * 7) == n){
                count++;
            }
        }
    }
    if(count > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll n;
map<pair<int,pair<ll,int> > ,ll> memo;

ll dfs(int h, ll rest, ll tt, int mode){

  ll ret = 0;
  
  if(h == 61){
    return 1;
  }
  
  if(memo.find({h,{rest,mode}}) != memo.end()) return memo[{h,{rest,mode}}];
  
  if(n & (1LL << h)){
    if(rest > 0) ret = (ret + dfs(h+1, (rest-1)/2, tt/2,0))%mod; //01
    
    ret = (ret + dfs(h+1, rest/2, tt/2,1))%mod; //00
    
    if(rest/2 > 0) ret = (ret + dfs(h+1, rest/2-1, tt/2,1))%mod; //11
    
  }else{
    if(rest > 0) ret = (ret + dfs(h+1, (rest-1)/2, tt/2,2))%mod; //10
    
    ret = (ret + dfs(h+1, rest/2, tt/2,0))%mod; //00
    
    if(rest/2 > 0) ret = (ret + dfs(h+1, rest/2-1, tt/2,0))%mod; //11
  }

  memo[{h,{rest,mode}}] = ret;
  return ret;
}

int main(){
  vector<ll> vec;
  
  cin >> n;

  ll ans = dfs(0,n,n,0);

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
 
int main(){
    vector<int> num(pow(10,5)+1);
 
    int n,q;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    long int sum=0;
  
  	for(int i=0;i<n;i++){
    sum+=a[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; i < pow(10,5)+1; j++)
        {
            if (a[i]==j)
            {
                num[j]++;
                break;
            } 
        }
    }
    
    
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        long int b,c;
        cin>>b>>c;
        sum=sum+(c-b)*num[b];
        cout<<sum<<endl;
        num[c]=num[c]+num[b];
        num[b]=0;
 
    }
    
return 0;
}

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

int main() {
  int x, n;

  cin >> x >> n;

  int left = x, right = x;

  if (n == 0) {
    cout << x;
    return 0;
  }

  vector<int> p(n);

  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  sort(p.begin(), p.end());

  for (int i = n - 1; i >= 0; i--) {
    if (p[i] == left) {
      left--;
    }
  }

  for (int i = 0; i < n; i++) {
    if (p[i] == right) {
      right++;
    }
  }

  if (abs(right - x) < abs(left - x)) {
    cout << right;
  } else {
    cout << left;
  }

  return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline

S = [ord(s) - ord('a') for s in input().rstrip()]

INF = 10 ** 9
N = len(S)
dp = [None] * (N+1)
# そこから始めたとき、次にxが現れる位置、および、次にxをとった場合に長さLのものが全て作れる
dp[N] = [[INF] * 26, [0] * 26, 0]

for n in range(N-1,-1,-1):
    prev = dp[n+1]
    cur = [prev[0].copy(), prev[1].copy(), prev[2]]
    s = S[n]
    cur[0][s] = n
    cur[1][s] = prev[2] // 26 + 1
    cur[2] = prev[2] + cur[1][s] - prev[1][s]
    dp[n] = cur

answer = []
i = 0
while i < N:
    # 辞書順で、作れる長さが一番短い文字
    L = dp[i][2] // 26
    for x in range(26):
        if dp[i][1][x] == L:
            break
    answer.append(chr(ord('a') + x))
    # その文字の場所に移動
    i = dp[i][0][x]
    i += 1

print(''.join(answer))

Measured memory_bytes: 156836
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

ll dsum(ll s) {
	ll ss = 0, sss = s;
	while (sss) {
		ss += sss % 10;
		sss /= 10;
	}
	return ss;
}

ll Stoi(string str) {
	ll ret;
	stringstream ss;
	ss << str;
	ss >> ret;
	return ret;
}


int main() {
	ll k;
	cin >> k;
	vector<ll>ans(200000);
	ans.clear();
	map<ll, bool>mp;
	for (int i = 1;i < 10;i++) {
		ans.pb(i);
		mp[i] = 1;
	}

	for (ll j = 1;j < 13;j++) {
		for (ll i = 1;i < 1000;i++) {
			string s;
			s += to_string(i);
			for (int l = 0;l < j;l++)s += "9";
			ll p = (ll)Stoi(s);
			bool fl = 1;
			for (int m = i + 1;m < i + 20;m++) {
				string t;
				t += to_string(m);
				for (int l = 0;l < j;l++)t += "9";
				ll q = (ll)Stoi(t);
				if (p*dsum(q) > q*dsum(p)) {
					fl = 0;
					//cout << p << ' ' << q << endl;
				}
			}
			if (fl && !mp[p]) {
				ans.pb(p);
				mp[p] = 1;
			}
		}
	}
	sort(ALL(ans));
	for (int i = 0;i < k;i++) {
		cout << ans[i] << endl;
	}
	k++;
	k++;
}

Measured memory_bytes: 1920
#!/usr/bin/env python3
import sys

INF = float('inf')

def solve(n: int, A: "List[int]"):
    dp = [[INF] * 5  for _ in range(n + 1)]
    dp[0][0] = 0
    dp[0][1] = 0
    dp[0][2] = 0
    for i in range(n):
        for j in range(5):
            if j == 0 or j == 4:
                extra = A[i]
            elif j == 1 or j == 3:
                extra = A[i] % 2 if A[i] > 0 else 2
            else:
                extra = (A[i] + 1) % 2
            dp[i + 1][j] = min(dp[i][:j + 1]) + extra
        #print(dp[i + 1])
    print(min(dp[n]))
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 67836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int X,Y;
    cin>>X>>Y;
    for(int i=0;i<=X;i++){
        int y=X-i;
        if(2*i+y*4==Y){
            cout << "Yes"<<endl;
            return 0;
        }
    }
    cout << "No"<<endl;

    



}


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

int main(void) {
  int N;
  vector<int>a(N);
  cin>>N;
  for(int i=1;i<=N;i++){
    cin>>a.at(i);
  }
  int m=0;
for(int i=1;i<=N;i++){
  if(i%2==1&&a.at(i)%2==1){
    m++;}
}
cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
    string s;
    int n; cin >> n;
    bool aflag = false;
    int cnt = 0;
    int bcnt = 0;
    int acnt = 0;
    int same = 0;
    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < s.size() - 1; j++){
            if(s[j] == 'A' && s[j+1] == 'B')cnt++;
        }
        if(s.front() == 'B')acnt++;
        if(s.back() == 'A')bcnt++;
        if(s.back() == 'A' && s.front() == 'B')same++;
    }

    
    int m = 0;
    if(acnt != 0 && bcnt != 0)m = min(acnt, bcnt);
    if(max(acnt, bcnt) == same && m != 0){
        m -= 1;
    }
    
    cout << cnt + m << endl;
}

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

a = 0
b = 0
ab = 0
count = 0
for i in range(n):
  line = input()
  count += line.count("AB")
  if line[0] == "B" and line[-1] == "A":
    ab += 1
  elif line[0] == "B":
    b += 1
  elif line[-1] == "A":
    a += 1

if ab > 0:
  count += ab - 1
  if a > 0:
    count += 1
    a -= 1
  if b > 0:
    count += 1
    b -= 1
count += min([a, b])
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int s;
    cin >> s;
    int a[1000003] = {};
    a[0] = s;
    int i = 0;
    if (a[0] <= 2) {
        cout << 4 << endl;
        return 0;
    } else {
        while(a[i] != 1) {
            i++;
            if (a[i - 1] % 2 == 0) {
                a[i] = a[i - 1] / 2;
            } else {
                a[i] = a[i - 1] * 3 + 1;
            }
        }
        cout << i + 2 << endl;
        return 0;
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;
int main() {
	int n;
	long long int h[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int count = 0, maxi = 0;
	for (int i = 0; i < n - 1; i++) {
		if (h[i] >= h[i + 1]) {
			count++;
		}
		else {
			if (count > maxi) {
				maxi = count;
			}
			count = 0;
		}
	}
	cout << max(maxi, count) << endl;

	return 0;
}

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

bool isprime[10000];

int main(void) {

  for(int i = 0; i < 10000; ++i) {
    isprime[i] = true;
  }
  isprime[0] = isprime[1] = false;

  for(int i = 2; i < 100; ++i) {
    if( isprime[i] ) {
      for(int j = i + i; j < 10000; j+=i) {
        isprime[j] = false;
      }
    }
  }

  int N;
  int A;
  int ans = 0;

  std::cin >> N;
  ans = N;
  for(int i = 0; i < N; ++i) {
    std::cin >> A;
    int n = std::min(10000, A);
    for(int j = 2; j < n; ++j) {
      if( isprime[j] ) {
        if( A % j == 0 ) {
          ans -= 1;
          break;
        }
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
    double a,b,c,d,e,f;
    while(cin >>a>>b>>c>>d>>e>>f){
        double x = (e*c-b*f)/(a*e-b*d);
        double y = (-(d*c)+a*f)/(a*e-b*d);
        if(x==0) x = 0;
        if(y==0) y = 0;
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n+1);
  int tmp;
  r(i,n){
    cin>>tmp;
    a.at(tmp)++;
  }
  sort(a.rbegin(),a.rend());
  int sum=0;
  r(i,k){
    sum+=a.at(i);
  }
  cout<<n-sum<<endl;

return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
strategy = ["stay"] * len(A)

trend = "down"
for i in range(len(A)):
    if i == len(A) - 1:
        new_trend = "down"
        strategy[i] = "sell"
    else:
        if A[i] < A[i+1]:
            new_trend = "up"
            if trend != new_trend:
                strategy[i] = "buy"
        elif A[i] > A[i+1]:
            new_trend = "down"
            if trend != new_trend:
                strategy[i] = "sell"
        else:
            strategy[i] = "stay"
            new_trend = trend
    trend = new_trend


money = 1000
stock = 0
for s in range(len(strategy)):
    if strategy[s] == "sell":
        money = money + stock * A[s]
        stock = 0
    elif strategy[s] == "buy":
        stock = money // A[s]
        money = money - A[s] * stock
    else:
        continue
print(money)

Measured memory_bytes: 62000
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define VEC vector<int>
#define INF 9999999
#define inta long long
typedef pair<int, int>pii;
typedef pair<int, bool>pib;
// vector<VEC> v (n, VEC(n))
//loop(i,n)loop(j,n)dp[i][j]=-1;
//printf("%d\n", n);

int a, b, c, d;
int tek(int a1, int b1, int c1)
{
	int s = 0;
	if (a1 == 0)s = a - b;
	else s = a + b;
	if (b1 == 0)s -=c;
	else s += c;
	if (c1 == 0)s -=d;
	else s +=d;
	return s;
}
char shi(int y)
{
	if (y == 0)return '-';
	else return '+';
}

int main()
{
	cin.tie(0);
	cin.sync_with_stdio(0);
	string s;
	int x;
	cin >> x;
	a = floor(x / 1000), b = (x - a * 1000) / 100, c = (x - a * 1000 - b * 100) / 10, d = (x - a * 1000 - b * 100 - c * 10);
	 bool ans = false;
	loop(i, 2)
	{
		if (ans) break;
		loop(j, 2)
		{
			if (ans)break;
			loop(k, 2)
			{
				if (ans)break;
				if (tek(i, j, k) == 7)
				{
					cout << a << shi(i) << b << shi(j) << c << shi(k) << d << "=7" << endl;
					ans = true;
				}
			}
		}
	}
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int a,b,c;
void solve(){
	cin >> a >> b >> c;
	
	cout << (a+b-1) / b *c << endl; 
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3604
N, M = map(int, input().split())
A = []
B = [[] for i in range(N)]
for i in range(M):
  P, Y = map(int, input().split())
  A.append([P, Y])
  B[P-1].append(Y)
for i in range(N):
  B[i].sort()
d = {}
for i in range(N):
  for y in range(len(B[i])):
    d[(i+1, B[i][y])] = y + 1
for i in range(M):
  print('{:0=6}'.format(A[i][0]) + '{:0=6}'.format(d[(A[i][0], A[i][1])]))

Measured memory_bytes: 119292
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() ;
const ll linf = numeric_limits<ll>::max() ;
const ull ulinf = numeric_limits<ull>::max();
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int n;
	cin >> n;
	int a[100005] = {};
	rep(i,0,n)cin >> a[i];
	
	ll sum = 0;
	ll ans = 0,ans2 = 0;

	sum = a[0];
	if(sum <= 0){
        ans += -sum+1;
        sum = 1;
	}
	rep(i,1,n){
        if(sum > 0){
            sum += a[i];
            if(sum > 0){
                ans += sum+1;
                sum = -1;
            }
        }else{
            sum += a[i];
            if(sum <= 0){
                ans += -sum+1;
                sum = 1;
            }
        }
	}
//	P(ans);

	sum = a[0];
	if(sum >= 0){
        ans2 += sum+1;
        sum = -1;
	}
	rep(i,1,n){
        if(sum > 0){
            sum += a[i];
            if(sum > 0){
                ans2 += sum+1;
                sum = -1;
            }
        }else{
            sum += a[i];
            if(sum <= 0){
                ans2 += -sum+1;
                sum = 1;
            }
        }
	}
	P(min(ans,ans2));
	return  0;
}

Measured memory_bytes: 640
N = int(input())
L = [1, 6, 9]

tmp = 6
while tmp < N:
    tmp *= 6
    L.append(tmp)
tmp = 9
while tmp < N:
    tmp *= 9
    L.append(tmp)

L.sort(reverse=True)


DP = [float('inf')] * 100001
DP[0] = 0
for i in range(1, 6):
    DP[i] = i
DP[6] = 1

for i in range(7, N+1):
    for l in L:
        if l <= i:
            DP[i] = min(DP[i], DP[i-l] + 1)

print(DP[N])


Measured memory_bytes: 44236
#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long> a;
int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        long long ain;
        cin >> ain;
        ain -= (i+1);
        a.push_back(ain);
    }
    sort(a.begin(), a.end());

    long long b = 0;
    if(n % 2 == 0) {
        int rino = n/2;
        int leno = rino-1;
        b = (a.at(rino)+a.at(leno)) / 2;
    }else {
        b = a.at(n/2);
    }

    long long sum = 0;
    for(int i = 0; i < n; ++i) {
        sum += abs(a.at(i)-b);
    }

    cout << sum << endl;
}

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

typedef long long ll;

ll gcd(ll numA, ll numB){
    while(numA % numB != 0){
        ll tmp = numB;
        numB = numA % numB;
        numA = tmp;
    }
    return numB;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> nums(N);
    int minusCount = 0;
    for(int i = 0; i < N; i++)
    {
       ll num;
       cin >> num;
       nums.at(i) = num;
    }
    vector<ll> gcds(N + 1);
    vector<ll> revGcds(N + 1);
    gcds.at(0) = nums.at(0);
    for(int i = 1; i < N; i++)
    {
        gcds.at(i) = gcd(nums.at(i), gcds.at(i - 1));
    }
    revGcds.at(N - 1) = nums.at(N - 1);
    for(int i = N - 2; i >= 0; i--)
    {
        revGcds.at(i) = gcd(nums.at(i), revGcds.at(i + 1));
    }
    ll answer = 0;
    for(int i = 0; i < N; i++){
        if (i == 0){
            answer = max(answer, revGcds.at(1));
        } else if(i == N - 1){
            answer = max(answer, gcds.at(N - 2));
        } else {
            answer = max(answer, gcd(gcds.at(i - 1), revGcds.at(i + 1)));
        }
    }

    cout << answer << endl;
    return 0;
}

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

int main(){
  int n,x,tmp;
  cin >> n >> x;
  int d[n+1];
  d[0]=0;
  rep(i,n){
    cin >> tmp;
    d[i+1] = d[i] + tmp;
  }
  
  cout << (upper_bound(d,d+(n+1),x) - d) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int A,B,C,D;
int X[10];
int main(){
  cin >> A >> B >> C >> D;
  for(int i=0;i<10;i++){
    X[i]=0;
  }
  X[A]=1;
  X[B]=1;
  X[C]=1;
  X[D]=1;
  if (X[1] && X[9] && X[7] && X[4]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
int a[8*N] ;
int te[20*N]={0},lzy[20*N]={0};
void get(int x,int l,int r){
	if(l==r){
		te[x]=1;
		return;
	}
	int mid=(l+r)/2;
	get(2*x,l,mid);
	get(2*x+1,mid+1,r);
	te[x]=te[2*x]+te[2*x+1];
}
void upd(int x,int s,int e,int l,int r,int val){
	if(s>e||s>r||e<l) return ;
	if(lzy[x]!=0){
		te[x]=0;
		if(s!=e)
			lzy[2*x]=lzy[2*x+1]=lzy[x];
		else
			a[s]=lzy[x];
		lzy[x]=0;
	}
	if(l<=s && e<=r){
        if(s==e) a[s]=val , te[x]=0;
        else te[x]=0,lzy[2*x]=lzy[2*x+1]=val;
        return ;
	}
	int mid=(s+e)/2;
    upd(2*x,s,mid,l,r,val);
    upd(2*x+1,mid+1,e,l,r,val);
    te[x]=te[2*x]+te[2*x+1];
}
void lazify(int x,int l,int r){
	if(l>r)return;
	if(lzy[x]>0){
		te[x]=0;
		if(l==r)
			a[l]=lzy[x];
		else
			lzy[2*x]=lzy[2*x+1]=lzy[x];
		lzy[x]=0;

	}
	int mid=(l+r)/2;
	if(mid!=r)
	lazify(2*x,l,mid);
    if(mid+1<=r)
	lazify(2*x+1,mid+1,r);
}


int  s[N],t[N],x[N],d[N];
multiset<int> st;
map<int,pii> map1;
map<int,int>m;
vector<pair<int,pii>> v;
signed main(){
  fast;
 
  int n,q;
  cin>>n>>q;
  for(int i=0;i<n;i++){
  	cin>>s[i]>>t[i]>>x[i];
  	st.insert(s[i]-x[i]);
  	st.insert(t[i]-x[i]-1);
  	v.pb({x[i],{s[i]-x[i] , t[i]-x[i]-1}});
  }
  for(int i=0;i<q;i++){
  	cin>>d[i];
  	st.insert(d[i]);
  }
  int cnt=0;
  while(st.size()>0){
  	m[*st.begin()]= ++cnt;
  	st.erase(st.begin());
  }

  // for(auto it=map1.begin();it!=map1.end();++it){
  //     v.pb({it->ff , it->ss});
  // }
  sort(v.begin() , v.end());
  memset(a , -1, sizeof(a) );
  get(1 , 1,cnt);
  for(int i=v.size()-1;i >= 0;i--){
  	 int l=m[v[i].ss.ff];
  	 int r=m[v[i].ss.ss];
  	 // cout<<l << " " << r << " " << v[i].ff<<endl;
  	 upd(1,1,cnt,l,r,v[i].ff);
  }
  lazify(1,1,cnt);
  for(int i=0;i<q;i++){
  	// cout <<d[i] << " " << m[d[i]]<<endl;
  	cout<<a[m[d[i]]]<<endl;
  }



}
  


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

typedef long long ll;
typedef long double ld;

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

const ll mod = 1e9+7;

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

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

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

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

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

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

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



int main(){
    int n,m,c;
    cin >> n >> m >> c;
    int b[m];
    rep(i,m) cin >> b[i];
    int a[n][m];
    rep(i,n){
        rep(j,m) cin >> a[i][j];
    }

    int ans = 0;

    for(int i=0;i<n;i++){
        int count=0;
        for(int j=0;j<m;j++){
            count+=a[i][j]*b[j];
        }
        if(count+c>0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int ans = 1;
    int up = INF;
    rep(i,n-1) {
        if (a[i+1] == a[i])
            continue;
        if (up == INF && a[i] != a[i+1]) {
            if (a[i+1] < a[i])
                up = 0;
            else
                up = 1;
            continue;
        }
        if (a[i+1] > a[i] && up == 1)
            continue;
        if (a[i+1] < a[i] && up == 0)
            continue;
        ans++;
        up = INF;
    }
    cout << ans<< endl;

    return 0;
}


Measured memory_bytes: 1024
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

result=0

for i in range(n):
    if i > 0:
        j=A[i]
        result+=B[j-1]
        if A[i] == A[i-1]+1:
            result += C[j-2]
    else:
        j=A[i]
        result+=B[j-1]

print(result)


Measured memory_bytes: 3064
#include <iostream>

int main(int argc, char const* argv[])
{
  while (true) {
    int N;
    std::cin >> N;
    if (N == 0) {
      break;
    }
    int grid[21][21];
    for (int i = 0; i < 21; ++i) {
      for (int j = 0; j < 21; ++j) {
        grid[i][j] = 0;
      }
    }
    for (int i = 0; i < N; ++i) {
      int x, y;
      std::cin >> x >> y;
      ++grid[x][y];
    }
    int M;
    std::cin >> M;
    int cur_x = 10, cur_y = 10;
    for (int j = 0; j < M; ++j) {
      char d; int i;
      std::cin >> d >> i;
      switch (d) {
        case 'N':
          // y+
          for (int k = 0; k < i; ++k) {
            ++cur_y;
            grid[cur_x][cur_y] = 0;
          }
          break;
        case 'E':
          // x+
          for (int k = 0; k < i; ++k) {
            ++cur_x;
            grid[cur_x][cur_y] = 0;
          }
          break;
        case 'S':
          // y-
          for (int k = 0; k < i; ++k) {
            --cur_y;
            grid[cur_x][cur_y] = 0;
          }
          break;
        case 'W':
          // x-
          for (int k = 0; k < i; ++k) {
            --cur_x;
            grid[cur_x][cur_y] = 0;
          }
          break;
      }
    }

    for (int k = 0; k < 21; ++k) {
      for (int l = 0; l < 21; ++l) {
        if (grid[k][l] > 0) {
          std::cout << "No" << std::endl;
          goto finish;
        }
      }
    }
    std::cout << "Yes" << std::endl;
finish:
    ++M;
  }
  return 0;
}

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

int main() {
  int X;
  cin >> X;
  
  if (X == 3){
    cout << "YES" << endl;
  }
  else if (X == 5){
    cout << "YES" << endl;
  }
  else if (X == 7){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int n;

	while( cin >> n , n ){
		string name[21];
		int time[21][31] = {0};
		int p[21] = {0};
		
		for(int i=0 ; i < n ; i++ ){	
			int m,d;
			
			cin >> name[i] >> m;
			for(int j=0 ; j < m ; j++ ){
				cin >> d;
				time[i][d] = 1;
			}
		}
		for(int i=0 ; i < 30 ; i++ ){
			int cnt=0;
			for(int j=0 ; j<n ; j++ ){
				if( time[j][i] ) cnt++;
			}
			for(int j=0 ; j<n ; j++ ){
				if( time[j][i] ){
					p[j] += n-(cnt-1);
				}
			}
		}
		int ans = p[0];
		vector<string> vc;
		for(int i=1 ; i<n ; i++ ){
			ans = min( ans , p[i] );
		}
		for(int i=0 ; i<n ; i++ ){
			if( p[i] == ans ){
				vc.push_back( name[i] );
			}
		}
		sort( vc.begin() , vc.end() );
		cout << ans << " " << vc[0] << endl;
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int Q; cin >> Q;
    REP(i,Q){
        ll A,B; cin >> A >> B;
        if(A==B){
            cout << 2*A-2 << endl;
        }else{
            ll max_score = A*B - 1;
            ll ng = -1;
            ll ok = 2e9;
            while(abs(ok-ng)>1){
                ll mid = (ok+ng)/2;
                if(mid*mid > max_score){//ここに条件をかく
                    ok = mid;
                }else{
                    ng = mid;
                }
            }
            if(ng*(ng+1) <= max_score) cout << 2*ng - 1 << endl;
            else cout << 2*ng - 2 << endl;
        }


    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}

void solve(){
	ll n,d;
	cin >> n >> d;
	d*=d;
	ll ans = 0;
	fi(n){
		ll x,y;
		cin >> x >> y;
		if(x*x+y*y <= d) ans++;
	}
	cout << ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	#endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3804
n = int(input())

# ans = 0

# for v in range(1, n + 1, 2):
#     num_divisor = 0
#     for i in range(3, v, 2):
#         if v % i == 0:
#             num_divisor += 1
#     if num_divisor == 6:
#         # print(v)
#         ans += 1

# print(ans)

if n < 105:
    print(0)
elif n < 135:
    print(1)
elif n < 165:
    print(2)
elif n < 189:
    print(3)
elif n < 195:
    print(4)
elif n <= 200:
    print(5)

Measured memory_bytes: 3060
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        if(n<=1){
            System.out.println(n);
            return;
        }
        HashSet<Long> count = new HashSet<>();
        for (int i = 0; i < n; i++) {
            String s = scanner.nextLine();
            long a = 0;
            for (char c : s.toCharArray()) {
                a = a*27+c-'a'+1;
            }
            count.add(a);
        }
        System.out.println(count.size());
    }
}


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

ll n;
ll a[55];

int main(){
    cin >> n;
    ll mmax=0,mmin=0;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        if(a[i]>a[mmax]) mmax=i;
        if(a[i]<a[mmin]) mmin=i;
    }
    if(abs(a[mmax])>=abs(a[mmin])){
        cout << 2*n-1 << endl;
        for(ll i=0;i<n;i++){
            cout << mmax+1 << " " << i+1 << endl;
        }
        for(ll i=0;i<n-1;i++){
            cout << i+1 << " " << i+2 << endl;
        }
    }
    else{
        cout << 2*n-1 << endl;
        for(ll i=0;i<n;i++){
            cout << mmin+1 << " " << i+1 << endl;
        }
        for(ll i=0;i<n-1;i++){
            cout << n-i << " " << n-i-1 << endl;
        }
    }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define MAX_N 100005

//Union-Find木
int par[MAX_N]; //親
int r[MAX_N]; //木の深さ

//n要素で初期化
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        r[i] = 0;
    }
}

//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unit(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(r[x] < r[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(r[x] == r[y]) r[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}

int main(void){
    ll n, m;
    cin >> n >> m;

    ll p[n];
    rep(i, 0, n){
        cin >> p[i];
        p[i]--;
    }

    init(n);
    rep(i, 0, m){
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        tmp1--;
        tmp2--;
        unit(p[tmp1], p[tmp2]);
    }

    ll ans = 0;
    rep(i, 0, n){
        if(same(i, p[i])){
            ans++;
        }
    }

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


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


//abc098 方針 文字列をXとYに分けたときに、どちらに文字含まれている文字の最大
// N < 100なので、全探索でもよい
int main() {

    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll res = -1;

    ll left[N][26] = {};
    ll right[N][26] = {};

    //右から数えたときのカウント数

    string alpha = "abcdefghijklmnopqrstuvwxyz";

    REP(i,N)
    {

        for(ll j = 0; j < 26; ++j)
        {
            if(i == 0)break;
            left[i][j] = left[i-1][j];
        }
        
        ll tmp = S[i] - 'a';
        left[i][tmp]++;
    }

    for(ll i = N-1; i >= 0; --i)
    {
        for(ll j = 0; j < 26; ++j)
        {
            if(i == N-1)break;
            right[i][j] = right[i+1][j];
        }
        ll tmp = S[i] - 'a';
        right[i][tmp]++;
    }

    ll iMax = 0;

    for(ll i = 0; i < N-1; ++i)
    {
        ll cnt = 0;
        for(ll j = 0; j < 26; ++j)
        {
            if(left[i][j] >= 1 && right[i+1][j] >= 1)cnt++;
        }
        iMax = max(iMax, cnt);
    }

    cout << iMax << endl;
    

    return 0;
}

Measured memory_bytes: 256
hoge = list(map(int, input().split()))
W=hoge[0]
H=hoge[1]
x=hoge[2]
y=hoge[3]
r=hoge[4]

if 0<=x-r and x+r<=W and 0<=y-r and y+r<=H:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5596
n = int(input())
a = map(int, input().split())
m = [0, 0, 0, 0]
for i in a:
    m[i%4] += 1
m[1] += m[3]
if m[2] > 0: m[1] += 1
if m[0] < m[1] - 1: print("No")
else: print("Yes")

Measured memory_bytes: 11096
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
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 INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N;
	cin>>N;
	vector<int>s(N,1000);
	int ans=0,j=0;
	REP(i,N){
		int x;
		cin>>x;
		if(x%10==0)
			ans+=x;
		else{
			s[j]=x;
			j++;
		}
	}
	if(j==0){
		cout<<0<<endl;
		return 0;
	}
	std::sort(s.begin(),s.end());
	REP(i,j){
		ans+=s[i];
		//cout<<s
	}
	if(ans%10==0)ans-=s[0];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);
    var T = parseInt(input[2], 10);

    var kaisuu = Math.floor(T/A);
    console.log(kaisuu * B);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 22076
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(i!=s.size()-1&&s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
def makeDictionary(in_item, out_item):
    for item in in_item:
        if item in out_item.keys():
            out_item[item] += 1
        else:
            out_item[item] = 1

sResult = {}
tResult = {}

N = int(input())
s = makeDictionary([input() for i in range(N)], sResult)
M = int(input())
t = makeDictionary([input() for i in range(M)], tResult)

for item in tResult.keys():
    if item in sResult:
        sResult[item] -= tResult[item]

result = max(sResult.values())

if result < 0:
    print(0)
else:
    print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){
  int L, R;
  cin >> L >> R;
  int ans=2020;
  int l,r;
  l=L/2019;
  r=R/2019;
  if(R-L>672){
  cout << 0 << endl;
    return 0;
  }
  if(l>1)
  L-=2019*(l-1);
  if(r>1)
  R-=2019*(r-1);
  if(L<=2019&&R>=2019)
  {
    cout << 0 << endl;
    return 0;
  }
   if(R-L==1)
  {
    cout << (R*L)%2019 << endl;
    return 0;
  }
  rep(i, R-L-1){
  rep2(j,i, R-L){
  ans=min(ans,((L+i)*(L+j+1))%2019);
  }
  
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    n, y = map(int, input().split())

    flag = 0
    for i in range(n+1):
        for j in range(n-i+1):
            dum = 10000*i + 5000*j + 1000*(n-i-j)
            if dum == y:
                print("{} {} {}".format(str(i), str(j), str(n-i-j)))
                flag = 1
                break
        if flag==1:
            break

    if flag==0:
        print("-1 -1 -1")


Measured memory_bytes: 3060
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    dx = dict()
    dy = dict()
    xs = []
    ys = []
    for _ in range(n):
        x,y = map(int,ipt().split())
        dx[x] = y
        dy[y] = x
        xs.append(x)
        ys.append(y)
    xs.sort()
    ys.sort()
    sm = [[0]*(n+1) for i in range(n+1)]
    f = False
    ly = dx[xs[n-1]]
    for i,yi in enumerate(ys[::]):
        if f:
            sm[n-1][i] = 0
        else:
            sm[n-1][i] = 1
        if ly == yi:
            f = True
    for i,xi in enumerate(xs[n-2::-1]):
        f = False
        smx = sm[n-i-2]
        smpx = sm[n-i-1]
        ly = dx[xi]
        for j,yj in enumerate(ys):
            if f:
                smx[j] = smpx[j]
            else:
                smx[j] = smpx[j]+1
            if ly == yj:
                f = True
    ma = 4*10**18+1
    for xl,xli in enumerate(xs[:n-1:]):
        smxl = sm[xl]
        for xr,xri in enumerate(xs[xl+1::]):
            smxr = sm[xl+xr+2]
            for yd,ydi in enumerate(ys[:n-1:]):
                for yu,yui in enumerate(ys[yd+1::]):
                    sk = smxl[yd]+smxr[yu+yd+2]-smxl[yu+yd+2]-smxr[yd]
                    if sk == k:
                        ss = (yui-ydi)*(xri-xli)
                        if ss < ma:
                            ma = ss
    print(ma)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 42984