akhauriyash/Code-Regression huggingface dataset:
//AtCoder ABC070 C - Multiple Clocks
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int64_t calc_gcd(int64_t a,int64_t b){
    if (a<b){
        swap(a,b);
    }
	int64_t r = a % b;
	while(r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
    return b;
}
ll lcm(ll num1,ll num2){
	return num1 / calc_gcd(num1,num2) * num2;
}

void PrimeFactorization(ll n, unordered_map<ll,ll>& x){
    ll num=n;
	//for(int i = 2; i <= n; i++) {
	for(ll i = 2; i <= num; i++) {
		while(num % i == 0) { //素数で割り切れなくなるまで割っていく
			x[i]++; //割った個数を配列に足す
			num /= i;
		}
	}
}

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N;
    cin>>N;
    vector<ll> tn(N,0);
    for(auto&& t:tn){
        cin>>t;
    }
    ll ans=1;
    for(const auto& t:tn){
         ans=lcm(t,ans);
    }
    cout<<ans<<endl;
#if 0
    unordered_map<ll,ll> ans;
    for(const auto& t:tn){
		unordered_map<ll, ll> tmp;
		PrimeFactorization(t,tmp);
        for(const auto& t:tmp){
            ans[t.first] = max(ans[t.first], t.second);
        }
    }
    ll val=1;
    for(const auto& a:ans){
        val*=pow(a.first,a.second);
    }
    cout<<val<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
a = list(input())
b = list(input())
c = list(input())
now = "a"

while True:
    if now == "a":
        if a == []:
            print("A")
            break
        now = a[0]
        del a[0]
        
    elif now == "b":
        if b == []:
            print("B")
            break
        now = b[0]
        del b[0]
    elif now == "c":
        if c == []:
            print("C")
            break
        now = c[0]
        del c[0]

Measured memory_bytes: 3064
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

pos = [0] * (h*w + 1)
for i in range(h):
    for j in range(w):
        pos[a[i][j]] = (j, i)

dis = [0] * (h*w + 1)
for i in range(h*w+1):
    if i > d:
        x1, y1 = pos[i-d]
        x2, y2 = pos[i]
        dis[i] = abs(x1-x2) + abs(y1-y2) + dis[i-d]

res = []
q = int(input())
for i in range(q):
    l, r = map(int, input().split())

    res.append(dis[r]-dis[l])

print("\n".join(map(str,res)))


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

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

    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    //  vector<string> prize;
    // for (int i = 0; i < N; i++) {
    // if (find(prize.begin(), prize.end(), S[i]) == prize.end()) {
    //   prize.push_back(S[i]);
    //}
    //}
    cout << S.size() << endl;

    return 0;
}


Measured memory_bytes: 9588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,x,t;
    cin >> n >> x >> t;
    cout << ((n-1)/x+1)*t << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
 
int main(){
  ll n;
  cin >>n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);
  ll b=a[n/2];
  ll res =0;
  rep(j,n)res+=abs(a[j]-b);
  cout << res << endl;
}

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

signed main() {
  int N, K;
  cin >> N >> K;
  vector<int> leng(N);
  for( int i = 0; i < N; i++ ) cin >>leng.at(i);
  sort(leng.begin(), leng.end(), greater<int>());
  
  int ans = 0;
  for( int i = 0; i < K; i++ ){
    ans += leng.at(i);
  }
  cout << ans << endl;
  
}

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

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

	cout << fixed << setprecision(5);
	cout << a / b << " " << a%b << " " << (double)a / b << endl;

	return 0;
}

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

int main()
{
	ll n,i;
	cin >> n;
	vector<ll>a(n);
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	ll s=0LL;
	for(i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
			s+=(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout << s ;
	return 0;
}

Measured memory_bytes: 4768
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,temp,a1,a2;
//	double temp;
	cin >> n;
	temp=n/1.08;
	a1=temp*1.08;
	a2=(temp+1)*1.08;
	if(a1==n)
		cout << temp << endl;
	else if(a2==n)	cout << temp+1 << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
typedef long long ll;

int divider(int a) {
	int x = 0;
	while (true) {
		if (a % 2 == 0)x++, a /= 2;
		else return x;
	}
}

int main() {
	int N,tmp=0;
	cin >> N;
	int* a = (int*)malloc(sizeof(int)*N);
	for (int i = 0;i < N;i++) {
		cin >> a[i];
		tmp += divider(a[i]);
	}
	cout << tmp << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main(){
 
    ll n;
    cin >> n;
    vector<string> s(n);
    for (ll i = 0;i < n;i++){
        cin >> s[i];
    }
    ll m = 0,a = 0,r = 0,c = 0,h = 0;
 
    for (ll i = 0; i < n; i++){
        if (s[i][0] == 'M'){
            m++;
            continue;
        }
        if (s[i][0] == 'A'){
            a++;
            continue;
        }
        if (s[i][0] == 'R'){
            r++;
            continue;
        }
        if (s[i][0] == 'C'){
            c++;
            continue;
        }
        if (s[i][0] == 'H'){
            h++;
            continue;
        }
    }
 
    ll ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
    cout << ans << endl;
    
}


Measured memory_bytes: 6376
N = int(input())
S = input()
r = 0
g = 0
b = 0

for c in S:
    if c == 'R':
        r += 1
    elif c == 'G':
        g += 1
    else:
        b += 1

ans = r * g * b

cnt = 0
for d in range(1, (N - 3) // 2 + 1 + 1):
    i = 0
    while i + 2 * d < N:
        if not (S[i] == S[i + d]) and  not (S[i + d] == S[i + 2*d]  ) and not (S[i + 2 * d] == S[i]):
            cnt += 1
        i += 1

ans -= cnt

print(ans)


Measured memory_bytes: 67952
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int f(int x)
{
    int ans = 0;
    while(x > 0){
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

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

    if(n % f(n) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
key=[[] for _ in range(M)]
for i in range(M):
  A,B=map(int,input().split())
  key[i].append(A)
  C=list(map(int,input().split()))
  bit=0
  for c in C:
    bit+=2**(c-1)
  key[i].append(bit)

dp=[float("inf")]*(2**N)
dp[0]=0
ndp=[0]*(2**N)
for i in range(M):
  cost=key[i][0]
  bit=key[i][1]
  ndp=dp[:]
  for j in range(2**N):
  	ndp[bit|j]=min(dp[j]+cost,ndp[bit|j])
  dp=ndp[:]
 
print(dp[-1] if dp[-1]!=float("inf") else -1)
  

Measured memory_bytes: 50904
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include "bits/stdc++.h"
#include <stdio.h>
#include <vector>
using namespace std;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using dd = double;
using vdd = std::vector<dd>;
using vvdd = std::vector<vdd>;
using vvvdd = std::vector<vvdd>;

constexpr ll INF = 1LL << 60;
constexpr dd EPS = 1e-11;

#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define REP(i, N) REPS(i, 0, N-1)
#define DEPS(i, S, E) for (ll i = (E); i >= (S); i--)
#define DEP(i, N) DEPS(i, 0, N-1)
#define EACH(e, v) for (auto&& e : v)


void solve()
{
	int N, M;
	char S[100001];
	scanf("%d %d", &N, &M);
	scanf("%s", S);

	vll ans;
	ans.reserve(N+1);

	ll idx = N;
	while (1){
		ll retJ = -1;
		REPS(j, idx-M, idx-1){
			if (j < 0)continue;
			if (S[j] == '0'){
				retJ = j;
				break;
			}
		}
		if (retJ == -1){
			printf("-1\n"); return;
		}


		ans.push_back(idx-retJ);
		idx = retJ;
		if (idx == 0) break;
	}

	DEP(i, ans.size()){
		printf("%d", (int)ans[i]);
		if (i == 0) printf("\n");
		else        printf(" ");
	}
}


int main(){
	solve();
	return 0;
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll h[n];
  list_input(h, n)
  ll sa = a-b;
  ll min = 0, max = 1000000000, middle;
  while (max >= min) { //2分探索
    middle = (max+min)/2; //半分のところを探索する
    ll t = 0;
    rep(i, n){
      if (h[i] > b*middle) {
        t += (h[i] - b*middle+sa-1) / sa;
      }
    }
    if (t > middle) {
      min = middle+1;
    }else{
      max = middle-1;
    }
  }
  puts(min)
}


Measured memory_bytes: 1152
#include<cstdio>
#include<vector>
#include<cstdlib>

#define	mp	make_pair
#define	pb	push_back

using namespace std;

typedef	pair<int,int>	pii;

int memo[1000][5];

int dis(const pii &a,const pii &b){
	return abs(a.first-b.first)+abs(a.second-b.second);
}

int main(){
	for(int w,h;scanf("%d%d",&w,&h),w;){
		pii s,g;
		vector<pii> pach[5];
		for(int i=0;i<h;i++){
			static char field[1001];
			scanf("%s",field);
			for(int j=0;j<w;j++){
				if     (field[j]=='S')	s=mp(i,j);
				else if(field[j]=='G')	g=mp(i,j);
				else if(field[j]=='1')	pach[field[j]-'1'].pb(mp(i,j));
				else if(field[j]=='2')	pach[field[j]-'1'].pb(mp(i,j));
				else if(field[j]=='3')	pach[field[j]-'1'].pb(mp(i,j));
				else if(field[j]=='4')	pach[field[j]-'1'].pb(mp(i,j));
				else if(field[j]=='5')	pach[field[j]-'1'].pb(mp(i,j));
			}
		}

		int ans=1<<30,bestpartner;
		for(int partner=0;partner<5;partner++){
			int bef=partner,next=(partner+1)%5;
			for(int i=0;i<pach[next].size();i++){
				memo[i][next]=dis(s,pach[next][i]);
			}
			bef=next; next=(next+1)%5;
			for(int k=1;k<4;k++){
				for(int i=0;i<pach[next].size();i++){
					memo[i][next]=1<<30;
					for(int j=0;j<pach[bef].size();j++){
						memo[i][next]=min(memo[i][next],
							memo[j][bef]+dis(pach[bef][j],pach[next][i]));
					}
				}
				bef=next; next=(next+1)%5;
			}
			for(int j=0;j<pach[bef].size();j++){
				int tmp=memo[j][bef]+dis(pach[bef][j],g);
				if(tmp<ans){
					ans=tmp;
					bestpartner=partner;
				}
			}
		}

		if(ans==(1<<30))	puts("NA");
		else	printf("%d %d\n",bestpartner+1,ans);
	}

	return 0;
}

Measured memory_bytes: 896
S = input()

N = len(S)

S_2 = S[:(N-1)//2]
S_3 = S[(N+3)//2 - 1:N]

if S == S[::-1] and S_2 == S_2[::-1] and S_3 == S_3[::-1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
s = list(input())
K = int(input())

for i in range(len(s)):
    if K == 0:
        continue
    n = ord(s[i]) - ord("a")
    if n == 0:
        continue
    m = 26 - n
    if K >= m:
        s[i] = "a"
        K -= m

if K != 0:
    K %= 26
    s[-1] = chr(ord(s[i]) + K)

print("".join(map(str,s)))        
        
    

Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define maxs 202020
#define mme(i,j) memset(i,j,sizeof(i))
#define ll long long
#define pb push_back
using namespace std;
const ll inf = LONG_LONG_MAX;

int main()
{
    ll n,m;
    while(~scanf("%lld%lld",&n,&m))
    {
        ll ans=0;
        if(m>=2*n)
        {
            ans+=n;
            m-=2*n; 
            ans+=m/4;
            printf("%lld\n",ans);
        }else
            printf("%lld\n",m/2);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int A[2][101];

int main(){

    cin >> N;
    for(int i = 0; i < 2; i++)
        for(int j = 0; j < N; j++)
            cin >> A[i][j];
    
    int opt = -1;
    int before = A[0][0];
    for(int i = 0; i < N; i++){
        // iで下にシフト
        int after = 0;
        for(int j = i; j < N; j++){
            after += A[1][j];
        }
        opt = max(opt, before + after);
        if(i+1<N)
            before += A[0][i+1];
    }

    cout << opt << endl;


    return 0;
}


Measured memory_bytes: 256
#define FNAME ""
 
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cassert>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <string>
 
#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;
 
template <class T> T sqr(const T &a) {return a * a;}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
// #ifdef LOCAL
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int a, b;
    cin >> a >> b;
    if (a == b) {
    	cout << "Draw";
    } else {
    	if (b != 1 && (a == 1 || a > b)) {
    		cout << "Alice"; 
    	} else {
    		cout << "Bob";
    	}
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100000

int partition(int *A, int p, int r) {
	int x, tmp;
	int i,j;

	x = A[r];
	i = p-1;

	for (j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	tmp = A[i+1];
	A[i+1] = A[r];
	A[r] = tmp;

	return i+1;
}

int main() {
	int n,i;
	int q;
	int A[N];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}

	q = partition(A,0,n-1);
	for (i = 0; i < n; i++) {
		if (i == q) {
			printf("[%d] ", A[i]);
			continue;
		}
		printf("%d", A[i]);
		if (i != n-1) printf(" ");
	}
	printf("\n");

	return 0;
}

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

int main() {
   int N;
   int x;
   int maxi_king;
   int max_bs;
   vector <int> sanyiszamok;
   cin >> N;
   for(int i=0;i<N;i++){
     cin >> x;
    sanyiszamok.push_back(x);
   }
   maxi_king=0;
   max_bs=sanyiszamok[0];
   for(int i=1;i<N;i++){
     if(sanyiszamok[i]>max_bs){
       max_bs=sanyiszamok[i];
       maxi_king=i;
     }
   }
   int osszegsanyi=0;
   for(int i=0;i<N;i++){
     osszegsanyi+=sanyiszamok[i];
     
   }  
   osszegsanyi-=max_bs;
   if(max_bs<osszegsanyi){
     cout << "Yes";
   }else{
     cout << "No";
   }
	return 0;
}


Measured memory_bytes: 3608
def main():
  while True:
    h, w = map(int, input().split(' '))
    if h == 0 and w == 0:
      exit()
    
    for i in range(h):
      if i == 0 or i == (h-1):
        print('#'*w)
      else:
        print('#'+ '.'*(w-2) +'#')
    print('')
    
  
if __name__ == "__main__":
  main()



Measured memory_bytes: 5620
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

a, b, c = MAP()
 
if Decimal(a)**Decimal(0.5) + Decimal(b)**Decimal(0.5) < Decimal(c)**Decimal(0.5):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5780
#include <iostream>
#include <algorithm>
#include <cmath>

int main(int argc, char * argv[])
{
int n, t, a;
std::cin >> n;
std::cin >> t;
std::cin >> a;
int * h = new int[n];
for (auto i = 0; i < n; i++)
std::cin >> h[i];

double min_dif = INFINITY;
int min_idx = 0;

for(auto i=0; i<n;i++)
{
auto y = t - h[i] * 0.006;
auto d = std::abs(a - y);
if ( min_dif > d )
{
min_dif = d;
min_idx = i;
}
}

std::cout << min_idx + 1 << std::endl;

delete[] h;

return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		
		Scanner src = new Scanner(System.in);
		
		//約数のカウント
		int count = 0;		
		
		//標準入力
		int a = src.nextInt();
		int b = src.nextInt();
		int c = src.nextInt();
       
		//aがbより小さい場合a～bの計算を繰り返す
		if(a <= b){
			int n = b - a;
			
			//a～b間でcの約数をカウントする
			for(int i = 0; i <= n; i++) {
				int answer = c % a;
				a += 1;
					
				if(answer == 0) {
					count += 1;
				}
			}
			
			System.out.println(count);
		
		}else {
			
			System.out.println(count);
			
		}
	}
}


Measured memory_bytes: 26260
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int k, a, b;

		k = scan.nextInt();
		a = scan.nextInt();
		b = scan.nextInt();

		for (int i = a; i < b + 1; i++) {
			if (i % k == 0) {
				System.out.println("OK");
				return;
			}
		}

		System.out.println("NG");
	}

	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 35756
#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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N, M, X, Y; cin >> N >> M >> X >> Y;
  vector<int> x(N); REP(i, N) cin >> x[i];
  vector<int> y(M); REP(i, M) cin >> y[i];
  sort(all(x)); sort(all(y));
  string ans = "War";
  for(int i = X + 1; i <= Y; ++i) {
    if(x[N - 1] < i && i <= y[0]) ans = "No War";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
const int mod = 1e9 + 7;
int qp(int x, int y)
{
    int ans = 1;
    int base = x;
    while (y)
    {
        if (y % 2)
            ans = 1ll * ans * base % mod;
        base = 1ll * base * base % mod;
        y = y / 2;
    }
    return ans;
}

int cc(int x, int y)
{
    int ans = 1;
    for (int i = 1; i <= y; i++)
    {
        ans = 1ll * ans * (x - y + i) % mod * qp(i, mod - 2) % mod;
    }
    return ans;
}
int main()
{
    int n, a, b;
    scanf("%d", &n);
    scanf("%d%d", &a, &b);
    printf("%d\n", (qp(2, n) - 1 - (cc(n, a) + cc(n, b)) % mod + mod) % mod);
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	while (N) {
		int num[1000] = {};
		for (int i = 0; i < N; i++)cin >> num[i];
		ans = 0;
		sort(num, num + N);
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (num[i] + num[j] <= M)ans = max((int)ans, num[i] + num[j]);
			}
		}
		if (!ans)cout << "NONE\n";
		else cout << ans << endl;
		cin >> N >> M;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
string a,b;
cin>>a>>b;
if (a=="H")
{
    if (b=="H")
    {
        cout<<"H"<<endl;
    }
    else if (b=="D")
    {
        cout<<"D"<<endl;
    }
    
}
else if (a=="D")
{
    if (b=="H")
    {
        cout<<"D"<<endl;
    }
    else if (b=="D")
    {
        cout<<"H"<<endl;
    }
    
}

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define N 10000

using namespace std;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int d[ N * 2 ];
    int n, m;
    int res;

    scanf ( "%d%d", &n, &m );
    if ( !( n | m ) ) break ;
    m += n;

    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d", &d[ i ] );
    }
    for ( i = n; i < m; ++i )
    {
      scanf ( "%d", &d[ i ] );
    }
    inplace_merge ( d, d + n, d + m );

    res = d[ 0 ];
    for ( i = 1; i < m; ++i )
    {
      res = max( res, d[ i ] - d[ i - 1 ] );
    }
    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import Control.Monad.State

data Player = PlayerA [Card] | PlayerB [Card] | PlayerC [Card]
            deriving (Show)

data Card = CardA | CardB | CardC
          deriving (Show)

toCard :: Char -> Maybe Card
toCard 'a' = Just CardA
toCard 'b' = Just CardB
toCard 'c' = Just CardC
toCard _   = Nothing

unsafeRemoveMaybe :: Maybe Card -> Card
unsafeRemoveMaybe (Just x) = x
unsafeRemoveMaybe Nothing  = error "card muri"

data Winner = WinA | WinB | WinC
instance Show Winner where
  show WinA = "A"
  show WinB = "B"
  show WinC = "C"

type Players   = (Player, Player, Player)
type GameStage = State Players Winner


main :: IO ()
main = do
  sa <- PlayerA . map (unsafeRemoveMaybe . toCard) <$> getLine
  sb <- PlayerB . map (unsafeRemoveMaybe . toCard) <$> getLine
  sc <- PlayerC . map (unsafeRemoveMaybe . toCard) <$> getLine
  print $ evalState (pay sa) (sa, sb, sc)

pay :: Player -> GameStage
pay (PlayerA []) = return WinA
pay (PlayerB []) = return WinB
pay (PlayerC []) = return WinC
pay (PlayerA (x:xs)) = do
  (_, bs, cs) <- get
  put (PlayerA xs, bs, cs)
  case x of
    CardA -> pay $ PlayerA xs
    CardB -> pay $ bs
    CardC -> pay $ cs
pay (PlayerB (x:xs)) = do
  (as, _, cs) <- get
  put (as, PlayerB xs, cs)
  case x of
    CardA -> pay $ as
    CardB -> pay $ PlayerB xs
    CardC -> pay $ cs
pay (PlayerC (x:xs)) = do
  (as, bs, _) <- get
  put (as, bs, PlayerC xs)
  case x of
    CardA -> pay $ as
    CardB -> pay $ bs
    CardC -> pay $ PlayerC xs


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

const string YES = "Yes";
const string NO = "No";

bool f(long long a, long long b, long long c){
    auto rhs = c - a - b;
    if(rhs <= 0){
        return false;
    }else{
        // rhs > 0
        return 4*a*b < (c-a-b)*(c-a-b);
    }
}

void solve(long long a, long long b, long long c){
    if(f(a, b, c)){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


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

long ans = 1;
long mod = 1e+9 + 7;

void f(string s1, string s2, int p, bool flag){
  if(p >= s1.length()) return;
  if(s1[p] == s2[p]){
    if(flag){
      ans *= 2;
      ans %= mod;
      f(s1, s2, p + 1, flag);
    }else{
      flag = true;
      f(s1, s2, p + 1, flag);
    }
  }else{
    if(flag){
      ans *= 2;
      ans %= mod;
      flag = false;
      f(s1, s2, p + 2, flag);
    }else{
      ans *= 3;
      ans %= mod;
      f(s1, s2, p + 2, flag);
    }
  }
}

int main(void){
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  int p;
  bool flag;
  if(s1[0] == s2[0]){
    ans = 3;
    p = 1;
    flag = true;
  }else{
    ans = 6;
    p = 2;
    flag = false;
  }
  f(s1, s2, p, flag);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

type card struct {
	io *IO
}

func (c *card) output(score int) {
	c.io.Printf("%d", score)
}

func main() {
	io := NewStdIO()
	defer io.Flush()
	c := card{
		io: io,
	}

	N := stoi(c.io.Next())
	Ai := strings.Split(c.io.Next(), " ")

	var ai []int
	for _, a := range Ai {
		ai = append(ai, stoi(a))
	}
	sort.Ints(ai)

	var sum int
	for i := 0; i < N; i++ {
		odd := i%2 == 0
		if odd {
			sum += ai[N-i-1]
		} else {
			sum -= ai[N-i-1]
		}
	}
	c.output(sum)
}

func abs(i int) int {
	if i > 0 {
		return i
	} else {
		return i * -1
	}
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}

// NewStdIO return standard IO instance.
func NewStdIO() *IO {
	return &IO{
		In:  bufio.NewReader(os.Stdin),
		Out: bufio.NewWriter(os.Stdout),
	}
}

// IO supports IO processing.
type IO struct {
	In  *bufio.Reader
	Out *bufio.Writer
}

// Flush outputs buffed data.
func (io *IO) Flush() {
	if err := io.Out.Flush(); err != nil {
		panic(err)
	}
}

// Printf writes string to buffer.
func (io *IO) Print(s string) {
	if _, err := fmt.Fprint(io.Out, s); err != nil {
		panic(err)
	}
}

// Printf writes string to buffer.
func (io *IO) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(io.Out, format, a...); err != nil {
		panic(err)
	}
}

// Next reads line and return string.
func (io *IO) Next() string {
	var b []byte
	for {
		l, pre, err := io.In.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}


Measured memory_bytes: 640
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
struct angka
{
    long long int time;
    long long int finish;
};
struct angka node[200200];
bool desc(struct angka a, struct angka b)
{
    return a.finish < b.finish;
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        long long int a,b;
        scanf("%lld %lld",&a,&b);
        node[i].time = a;
        node[i].finish = b;
    }
    sort(node,node+n,desc);
    bool can = 1;
    long long int timeSpent = 0;
    for(i=0;i<n;i++)
    {
        timeSpent += node[i].time;
        if(timeSpent > node[i].finish)
        {
            can = 0;
            break;
        }
    }
    if(can)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
ll N, K, ans;
int main()
{
	cin >> N >> K;
	for (ll i = K; i <= N + 1; i++)
	{
		ans = (ans + i * (N - i + 2) - i + 1) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair;


int main(){
	int n,m,count=0;
	ll a[100002];
	scanf("%d%d",&n,&m);
	vector <ll> b;
	vector<ll>c;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		ll d = a[i]/2;
		ll v = a[i];
		ll g=0;
		while(v%2==0)
			g++,v=v/2;
		c.push_back(g);
		b.push_back(d);
		if(d%2==0)
			count++;
	}
	int value=1,s = c[0];
	for(int i=0;i<n;i++){
		if(s!=c[i]){
			value=0;
			break;
		}
	}
	if(!value){
		printf("0\n");
		return 0;
	}
	ll val=b[0];
	for(int i=1;i<b.size();i++){
		ll s = __gcd(val,b[i]);
		val=val/s;
		val*=b[i];
		if(val>m)
			break;
	}

	if(val>m || (count>0 && count<n))
		printf("0\n");
	else
	{
		ll ans= m/val;
		ans = ans - ans/2;
		printf("%lld\n",ans);
	}
	return 0;	

}


Measured memory_bytes: 2796
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,K = inpl()
hh = [int(input()) for _ in range(N)]
hh.sort()
l,r = 0,K-1
ans = INF
while True:
    tmp = hh[r] - hh[l]
    ans = min(ans,tmp)
    l += 1
    r += 1
    if r == N:
        break

print(ans)


Measured memory_bytes: 8352
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int n,m;
int a[200010];
int front[200010];
int cover[200010];
int covered;
void add(int x){
	int n= front[x]-1;
	if(n>0){
		if(cover[n]==0) covered++;
		cover[n]++;
	}
	front[x]--;
}
void erase(int x){
	int n=front[x];
	if(n>0){
		cover[n]--;
		if(cover[n]==0) covered--;
	}
	front[x]++;
}
int main(){
	cin >> n >>m;
	for(int i=1;i<=n;i++){
		front[i]=i+1;
	}
	for(int i=0;i<n;i++){
		cin >>a[i];
		add(a[i]);
	}
	for(int i=0;i<m;i++){
		int x,y;
		cin >>x>>y;
		x--;
		erase(a[x]);
		add(y);
		a[x]=y;
		cout<< n-covered << endl;
	}
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
int n, a, b;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n >> a >> b)
		cout << min(n*a, b) << endl;
}
/*
4 2 9
4 2 7
4 2 8
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  VEC<int>a(3);
  REP(i,0,3)cin>>a[i];
  VEC<int> b = {5,5,7};
  sort(ALL(a));
  bool ok=1;
  REP(i,0,3){
    if(a[i]!=b[i])ok=0;
  }
  cout<<(ok?"YES":"NO")<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  
  ll N;
  cin >> N;
  
  ll ans = 0;
  for(int i = 1;i <= N;++i){
    if(i % 3 != 0 && i % 5 != 0)  ans += i;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, 0, n) cin >> h[i];
  sort(h.begin(), h.end());

  int ans = 1e9 + 7;
  k--;
  rep(i, k, n) { chmin(ans, h[i] - h[i - k]); }

  cout << ans << endl;
}


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

N = int(input())

AB = [list(map(int, input().split())) + [0] for i in range(N)]

AB.sort(key=lambda x: x[1])

AB[0][2] = AB[0][0]
for i in range(N - 1):
    AB[i + 1][2] = AB[i][2] + AB[i + 1][0]

for i in range(N):
    if AB[i][1] < AB[i][2]:
        print('No')
        break
else:
    print('Yes')

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

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

    int ss = s.size(), ts = t.size();
    int ans = 10000, tmp = 0;
    rep(i, ss - ts + 1){
        tmp = 0;
        rep(j, ts){
            if(s[i+j] != t[j]) tmp++;
        }
        if(ans > tmp) ans = tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10 ** 7)

n = int(input())
li = []
lin = []

for _ in range(n):
    a,b = map(int,stdin.readline().rstrip().split())
    li.append([a,b])
    lin.append([b,a])

li.sort()
lin.sort()

if n%2 == 1:
    print(lin[n//2][0]-li[n//2][0]+1)
else:
    print((lin[n//2][0]+lin[(n-1)//2][0])-(li[n//2][0]+li[(n-1)//2][0])+1)

Measured memory_bytes: 125160
#include <iostream>
using namespace std;
long long n, cnt = 1;
bool b(long long k){
    if(k == 1) return false;
    long long m = n;
    while(m%k == 0){
        m /= k;
    }
    return m%k <= 1;
    
}
int main(void){
    cin >> n;
    if(n == 2){
        cout << 1 << endl;
        return 0;
    }
    for(long long k=1;k*k<=n;k++){
        if(n%k == 0){
            if(b(k)) cnt++;
            if(k*k != n && b(n/k)) cnt++;
        }
    }
    n--;
    for(long long k=2;k*k<=n;k++){
        if(n%k == 0){
            cnt++;
            if(k*k != n) cnt++;
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100
int dp[MAXN * MAXN  + 1];
int v[MAXN+1];
int main() {
    FILE * fi, * fout;
    int i,j,n,max;
    //fi = fopen("A.in" ,"r");
    //fout = fopen("A.out" ,"w");
    fi=stdin;
    fout=stdout;
    fscanf(fi,"%d" ,&n) ;
    for(i=1;i<=n;i++)
       fscanf(fi,"%d" ,&v[i]);
    dp[0]=1;
    for(i=1;i<=n;i++)
      for(j=MAXN*MAXN;j>=v[i];j--)
        dp[j]|=dp[j-v[i]];
    max=0;
    for(i=1;i<=MAXN*MAXN;i++)
      if(i%10!=0&&dp[i])
        max=i;
    fprintf(fout,"%d\n" ,max);
    //fclose(fi);
    //fclose(fout);
}


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


int main()
{
    string S ;
    cin>>S;
    int i , j ;
    stack < char > stk;
    for(i=0;i<S.length();++i)
        if(S[i]=='S')
            stk.push(S[i]);
        else if(!stk.empty() && stk.top()=='S')
            stk.pop();
        else
            stk.push(S[i]);
    cout<<stk.size();
    return 0;
}


Measured memory_bytes: 768
X = int(input())
x = X%100
cnt = 0
cnt += x//5
x = x%5
cnt += x//4
x = x%4
cnt += x//3
x = x%3
cnt += x//2
x = x%2
cnt += x
X = X-X%100
if X>=100*cnt:
    print(1)
else:
    print(0)

Measured memory_bytes: 38384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MAXN (5005)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

bool d[MAXN][MAXN];
bool od[MAXN];
int A[MAXN];
int N, K, Ans;

int main() {
	scanf("%d%d", &N, &K);
	for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
	d[0][0] = true;
	for(int i = 1; i <= N; i++) for(int j = 0; j <= K; j++) {
		bool &ret = d[i][j];
		if(j < A[i]) { ret = d[i-1][j]; continue; }
		ret = d[i-1][j] | d[i-1][j - A[i]];
	}
	od[0] = true;
	for(int i = N; i; i--) {
		if(K <= A[i]) { Ans++; continue; }
		int cnt = 0;
		for(int j = K-A[i]; j <= K-1; j++) cnt += od[j];
		for(int j = 0; j <= K-1; j++) {
			if(cnt && d[i-1][j]) { Ans++; break; }
			if(0 <= K-1-j) cnt -= od[K-1-j];
			if(0 <= K-A[i]-j-1) cnt += od[K-A[i]-j-1];
		}
		for(int j = K-A[i]; ~j; j--) if(od[j]) od[j+A[i]] = true;
	}
	printf("%d\n", N-Ans);
	return 0;
}

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

int LCS(const string& s, const string& t) {
	int ls = s.size(), lt = t.size();
	vector<vector<int>> dp(ls + 1, vector<int>(lt + 1));
	for (int i = 0; i < ls; i++) {
		for (int j = 0; j < lt; j++) {
			dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			}
		}
	}
	return dp[ls][lt];
}

int main()
{
	string S, T;
	cin >> S >> T;
	int n = S.size();
	string o, e;
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			o.push_back(S[i]);
		}
		else {
			e.push_back(S[i]);
		}
	}
	cout << (LCS(o, T) == o.size() || LCS(e, T) == e.size() ? "Yes" : "No") << endl;
	return 0;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long int64;

int main() {
    int n, k, r, s, p;
    int64 ans = 0;
    string t;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;

    map<char, int64> win;
    win['r'] = p;
    win['s'] = r;
    win['p'] = s;

    for (int i=0; i<n; i++) {
        if (i<k) ans += win[t[i]];
        else if (t[i-k] != t[i]) ans += win[t[i]];
        else t[i] = '-';
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>


int main() {

	int N; std::cin >> N;
	std::set<int> s;
	for (int i = 0; i < N; i++) {
		int a; std::cin >> a;
		if (s.find(a) == s.end())s.insert(a);//重複がないとき
		else s.erase(a);
	}

	std::cout << s.size();

	return 0;
}

Measured memory_bytes: 4864
# 解説を読んだ。優先度付きキューね，はい。
import heapq


def main():
    item_no, discount_no = [int(x) for x in input().split()]
    prices = [int(x) * -1 for x in input().split()]
    heapq.heapify(prices)

    for _ in range(discount_no):
        current_max = heapq.heappop(prices)
        current_max = current_max * -1 // 2 * -1
        heapq.heappush(prices, current_max)

    print(- sum(prices))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20456
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <iomanip>
//#include <bits/stdc++.h>
#define micro 0.01

using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n / 100 == 7)
	{
		cout << "Yes" << endl;
		return 0;
	}
	else
	{
		int a;
		a = n / 100;
		n -= a * 100;
	}
	if (n / 10 == 7)
	{
		cout << "Yes" << endl;
		return 0;
	}
	else
	{
		int a;
		a = n / 10;
		n -= a * 10;
	}
	if (n == 7)
	{
		cout << "Yes" << endl;
		return 0;
	}
	else
	{
		cout << "No" << endl;
	}
}


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

int main(){
	int N;
	cin >> N;
	vector<ll> A(N),B(N);
	for(int i=0; i<N; i++){
		cin >> A.at(i) >> B.at(i);
	}

	//Xiを全部Aiにした時
	vector<ll> x_min = A;
	sort(x_min.begin(), x_min.end());
	
	//Xiを全部Biにした時
	vector<ll> x_max = B;
	sort(x_max.begin(), x_max.end());

	if(N % 2== 0){//Nが偶数の場合
		// ll center_min = (x_min.at(N/2 - 1) + x_min.at(N/2)) /2 ;
		// ll center_max = (x_max.at(N/2 - 1) + x_max.at(N/2)) /2 ;
		// ll ans = center_max*2 - center_min*2 + 1;
		ll center_min = (x_min.at(N/2 - 1) + x_min.at(N/2)) ;
		ll center_max = (x_max.at(N/2 - 1) + x_max.at(N/2)) ;
		ll ans = center_max - center_min + 1;
		cout << ans << endl;
		return 0;
	}
	else{//Nが奇数の場合
		ll center_min = x_min.at(N/2) ;
		ll center_max = x_max.at(N/2) ;
		ll ans = center_max - center_min + 1;
		cout << ans << endl;
		return 0;
	}


}

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

//答え
//0と１の個数をそれぞれ数える
//個数の小さい方の値　* 2が取り除けるキューブの数の総数
//だって, 隣り合っているところから, 必ずキューブが２個ずつ取り除かれていくから
//ペアとなる数字がいなくなると, キューブを取り除けなくなる

int main(){
    string s;
    cin >> s;
    
    int count0 = 0;
    int count1 = 0;
    
    int N = s.size();
    rep(i, N){
        if (s[i] == '0') count0++;
        else count1++;
    }
    
    int halfAns = min(count0, count1);
    
    //ex 110000 count0 = 4, count1 = 2 
    //答えは min(4, 2) * 2である
    cout << halfAns * 2 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
int main() {
    // input
    int n; cin >> n;
    vector<int> x(n); repeat (i,n) { cin >> x[i]; -- x[i]; }
    // solve
    vector<int> a(n*n, -1);
    repeat (i,n) a[x[i]] = i;
    vector<int> ix(n);
    whole (iota, ix, 0);
    whole (sort, ix, [&](int i, int j) { return x[i] < x[j]; });
    int j = 0;
    for (int i : ix) {
        for (int k = 0; k < i; ) {
            assert (j < n*n);
            if (a[j] == -1) {
                a[j] = i;
                ++ k;
            } else if (a[j] == i) {
                a.clear();
                goto done;
            }
            ++ j;
        }
    }
    whole(reverse, ix);
    j = n*n-1;
    for (int i : ix) {
        for (int k = 0; k < n-i-1; ) {
            assert (j >= 0);
            if (a[j] == -1) {
                a[j] = i;
                ++ k;
            } else if (a[j] == i) {
                a.clear();
                goto done;
            }
            -- j;
        }
    }
done: ;
    // output
    if (a.empty()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        repeat (i,n*n) {
            if (i) cout << ' ';
            cout << a[i] + 1;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2176