akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VI vector<int>
#define VL vector<long long>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

const LL N=100003;
struct NODE{
	db o,r,d;
};
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;
LL a[N];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0,u,v,d;
	cin>>n;
	repu(i,1,n)cin>>a[i];
	
	repu(i,1,n){
		ans+=a[i]/2,a[i]%=2;
		if(a[i]&&a[i+1]){
			ans++;
			a[i]=0;
			a[i+1]-=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
/// b.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,K;
    fi>>n>>K;
    vi s[1 << 20];
    vii v;
    int mn = 1e9 + 55;
    while (n --)
    {
        int a,b;
        fi>>a>>b;
        smin(mn,a);
        v.pb(mp(a,b));
    }
    for (auto &it : v)
        it.x -= mn - 1;
    for (auto it : v)
        s[it.x].pb(it.y);
    int ans = 0;
    for (int i = 1;i <= 4;++i)
        sort(s[i].begin(),s[i].end(),greater < int > ()),s[i].pb(0);
    for (int i = 0,s1 = 0;i < s[1].size();s1 += s[1][i],++i)
        for (int j = 0,s2 = 0;j < s[2].size();s2 += s[2][j],++j)
            for (int k = 0,s3 = 0;k < s[3].size();s3 += s[3][k],++k)
                for (int l = 0,s4 = 0;l < s[4].size();s4 += s[4][l],++l)
                    if (1ll * i * mn + 1ll * j * (mn + 1) + 1ll * k * (mn + 2) + 1ll * l * (mn + 3) <= K)
                        smax(ans,s1 + s2 + s3 + s4);
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 24832
#include<iostream>

using namespace std;

int main() {
  int n, p;
  long long ans(0);
  cin >> n >> p;
  int arr[n];
  char c;
  
  for (int i = 0; i < n; ++i) {
    cin >> c;
    arr[i] = c - '0';
  }
  
  if (p == 2 || p == 5) {
    for (int i = 0; i < n; ++i)
      if (arr[i] % p == 0)
        ans += i + 1;
  } else {
    int x(0), p2(1);
    long long mods[p] = {};
    mods[0] = 1;
    for (int i = n - 1; i >= 0; --i) {
      x = (x + p2 * arr[i]) % p;
      ans += mods[x]++;
      p2 = (p2 * 10) % p;
    }
  }
  
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int h, w, d;
char c[5] = "RYGB";
int main(){
	scanf("%d%d%d", &h, &w, &d);
	rep(i,h){
		rep(j,w) printf("%c", c[(i+j)/d%2*2+(i-j+w)/d%2]);
		puts("");
	}
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

ll f(ll b, ll n) {
	if (n < b) return n;
	else return f(b, n / b) + (n % b);
}

int main() {
	ll n, s; cin >> n >> s;
	if (n == s) printf("%lld", n+1);
	else {
		ll ans = 1LL*inf*inf;
		rep(i, 2, sqrt(n) + 1) {
			if (f(i, n) == s) {
				ans = min(ans, 1LL*i);
			}
			ll b = (n-s) / i+1;
			if (b < 2) continue;
			if (f(b, n) == s) {
				ans = min(ans, b);
			}
		}
		if (n-s+1>1&&f(n-s+1, n) == s) {
			ans = min(ans, n-s+1);
		}
		if (ans == 1LL * inf * inf) printf("-1");
		else printf("%lld",ans);
	}
	return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    # too slow
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def get_all_members(self):
        pare_d = {}
        for i in range(self.n):
            parent = self.find(i)
            pare_d.setdefault(parent,[])
            pare_d[parent].append(i)
        return list(pare_d.values())

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m,k = map(int, input().split())
uf = UnionFind(n+1)
direct_cnts = [0]*(n+1)

for _ in range(m):
    a,b = map(int, input().split())
    uf.union(a,b)
    direct_cnts[a] += 1
    direct_cnts[b] += 1


block = [[] for _ in range(n+1)]
for _ in range(k):
    c,d = map(int, input().split())
    block[c].append(d)
    block[d].append(c)


ansl = []
for i in range(1,n+1):
    cnt = uf.size(i)-1
    cnt -= direct_cnts[i]
    for b in block[i]:
        if uf.same(i,b): cnt -= 1
    ansl.append(cnt)

print(*ansl)

Measured memory_bytes: 101584
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}


const int N = 2e4 + 10;
int dp[N];


struct stone
{
    int s;
    int w;
    int v;
};

bool cmp(stone a, stone b)
{

    return a.s + a.w < b.s + b.w;
}

int32_t SALI()
{
    int n; cin >> n;
    stone a[n]; for(int i = 0; i < n; i++) cin >> a[i].w >> a[i].s >> a[i].v;
    memset(dp,-1,sizeof(dp));
    dp[0] = 0;
    sort(a,a+n,cmp);
    for(int i = 0; i < n; i++){
        for(int j = N-1; j >= 0; j--){
            if(dp[j] < 0) continue;
            if(j <= a[i].s){
                dp[j+a[i].w] = max(dp[j+a[i].w], dp[j] + a[i].v);
            }
        }
    }

    int ans = 0; for(int i = 0; i < N; i++) ans = max(ans,dp[i]);
    cout << ans;
}



/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
	int H,W; cin >> H >> W;
	int a[H][W]; int cnt=0;
	vector<vector<int>> ans;
	rep(i,H) rep(j,W){cin >> a[i][j]; a[i][j]%=2;}
	rep(i,H){
		int b=0;
		rep(j,W-1){
			if(a[i][j]^b){
				b=1; cnt++;
				ans.push_back({i+1,j+1,i+1,j+2});
			}
			else b=0;
		}
		a[i][W-1]^=b;
	}
	int b=0;
	rep(i,H-1){
		if(a[i][W-1]^b){
			b=1; cnt++;
			ans.push_back({i+1,W,i+2,W});
		}
		else b=0;
	}
	cout << cnt << endl;
	rep(i,cnt){
		rep(j,4){
			cout << ans[i][j] << (j==3 ? "":" ");
		}
		cout << endl;
	}


	return 0;
}


Measured memory_bytes: 13904
nk = list(map(lambda x: int(x), input().split(" ")))
n = nk[0]
k = nk[1]

ds = input().split(" ")

res = n
while True:
    is_ok = [str(res).find(d) == -1 for d in ds]
    if all(is_ok):
        break
    else:
        res = res + 1

print(res)


Measured memory_bytes: 9044
S = input()
T = input()

# dp[i][j] := Sのi文字目, Tのj文字目まで見た場合のLCS
dp = [[0] * (len(T) + 1) for i in range(len(S) + 1)]

for i in range(1, len(S) + 1):
    for j in range(1, len(T) + 1):
        if S[i - 1] == T[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

ans = ''
i, j = len(S), len(T)
while i > 0 and j > 0:
    if S[i - 1] == T[j - 1]:
        ans += S[i - 1]
        i, j = i - 1, j - 1
    elif dp[i][j - 1] > dp[i - 1][j]:
        j -= 1
    else:
        i -= 1

print(ans[::-1])


Measured memory_bytes: 112220
import sys
N = int(input())
summer = []
for i in range(N):
    summer.append(list(map(int, sys.stdin.readline().rstrip().split(" "))))

INF = float('inf')
DP = [[-INF for i in range(3)] for i in range(N)]

for i in range(N):
    if i == 0:
        DP[i] = summer[i]
    else:
        DP[i][0] = max(DP[i-1][1], DP[i-1][2]) + summer[i][0]
        DP[i][1] = max(DP[i-1][0], DP[i-1][2]) + summer[i][1]
        DP[i][2] = max(DP[i-1][0], DP[i-1][1]) + summer[i][2]

print(max(DP[N-1]))

Measured memory_bytes: 47280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  bool ans = 1;
for(int i = 0; i < 3; i++){
if(S[i] == '7') ans = 0;

}

if(ans == 0) cout << "Yes" << endl;
else cout << "No" << endl;
} 


Measured memory_bytes: 3596
#include <iostream>
using namespace std;int main(void){
    // Your code here!
    int A,B,C,tmp,ct=0;
    std::cin >> A >> B >> C;
    int P[3] = {A,B,C};
    for (int a = 0; a <2; a++) {
        for (int i = 0; i < 2; i++) {
            if(P[i] > P[i+1]){
                tmp = P[i];
                P[i] = P[i+1];
                P[i+1] = tmp;
            }
        }
    }
    A = P[0];
    B = P[1];
    C = P[2];
    if((A % 2 == 1&& B % 2 ==0&& C % 2 ==0)||(A % 2 == 0&& B % 2 == 1&& C % 2 ==1)){
        B++;
        C++;
        ct++;
    }else if((A % 2 == 1&& B % 2 == 0&& C % 2 ==1)||(A % 2 == 0&& B % 2 == 1&& C % 2 ==0)){
        A++;
        C++;
        ct++;
    }else if((A % 2 == 1&& B % 2 == 1&& C % 2 ==0)||(A % 2 == 0&& B % 2 == 0&& C % 2 ==1)){
        A++;
        B++;
        ct++;
    }
    
    while(1){
        if(A == B && A == C)
            break;
        if(A <= B && A < C){
            A = A + 2;
            ct++;
        }
        else if(B < C){
            B = B + 2;
            ct++;
            }
        }
        std::cout << ct << std::endl;

}


Measured memory_bytes: 256
#include<iostream>

#include<string>
#include <algorithm> 
using namespace std;

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

    if((a < c && c < b) || (b < c && c < a) ) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

y = (a ** 2) * b / 2
if x == a**2*b:
    print(0)
elif x <= a**2*b/2:
    z = a*b**2 / (2*x)
    print(math.degrees(math.atan(z)))
else:
    z = 2 * (a ** 2 * b - x) / a ** 3
    print(math.degrees(math.atan(z)))

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

int main(){
int n,i;
cin>>n;
vector<int> a,b,c;
for(i=0;i<n;i++)
{
    int s,t,u;
    cin>>s>>t>>u;
    a.push_back(s);
    b.push_back(t);
    c.push_back(u);
}
int dp[n][3];
dp[n-1][0]=a[n-1];
dp[n-1][1]=b[n-1];
dp[n-1][2]=c[n-1];

for(i=n-2;i>=0;i--)
{
    dp[i][0]=max(dp[i+1][1],dp[i+1][2])+a[i];
    dp[i][1]=max(dp[i+1][0],dp[i+1][2])+b[i];
    dp[i][2]=max(dp[i+1][0],dp[i+1][1])+c[i];
}
int y=max(dp[0][1],dp[0][2]);
int x=max(y,dp[0][0]);
cout<<x<<endl;
}


Measured memory_bytes: 2796
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>


int main()
{
	int a, b;
	while (scanf("%d %d", &a, &b) > 0) {
		
		if (a+1 >= b*2) printf("YES\n");
		else printf("NO\n");
	}
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main(){
    int L,A,B,C,D,ans;
    cin>>L>>A>>B>>C>>D;
    ans=L;
    while(A>0 || B>0){
        ans--;
        A-=C; B-=D;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  int d,g; cin >> d >> g; g /= 100;
  vector<int> p(d), c(d);
  rep(i,d){
    cin>>p[i]>>c[i];
    c[i] /= 100;
  }
  
  int ans = 1000;
  rep(i, (1<<d)){//コンプリートする問題の集合
    int point = 0;
    int num = 0;
    rep(j,d){
      if((i>>j)&1){
        point += c[j] + (j+1)*p[j];
        num += p[j];
      }
    }
    
    if(point >= g){
      ans = min(ans, num);
      continue;
    }
    
    for(int j=d-1; j>=0; j--){
      if((i>>j)&1)continue;
      int now = min(p[j]-1, (g-point+(j+1)-1)/(j+1));
      num += now;
      point += (j+1)*now;
      if(point>=g){
        ans = min(ans, num);
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  if (A >= K) {
      cout << A - K << " " << B << endl;
      return 0;
  } else if (B >= K - A) {
      cout << 0 << " " << B - (K - A) << endl;
      return 0;
  }
cout << 0 << " " << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdio.h>
#include <queue>
#include <utility>
using namespace std;
int main(){
    int N,L,atmp;
    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >pq;
    scanf("%d%d",&N,&L);
    for(int i=0;i<L;i++){
        scanf("%d",&atmp);
        pq.push(make_pair(atmp,i));
    }
    printf("%d",pq.top().first);
    for(int i=L;i<N;i++){
        scanf("%d",&atmp);
        pq.push(make_pair(atmp,i));
        while(pq.top().second<=i-L)pq.pop();
        printf(" %d",pq.top().first);
    }
    printf("\n");
}



Measured memory_bytes: 10828
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)
        scores := map[string]int{}
        var s string
        for i := 0; i < n; i++ {
                fmt.Scan(&s)
                scores[s]++
        }
        var m int
        fmt.Scan(&m)
        for i := 0; i < m; i++ {
                fmt.Scan(&s)
                scores[s]--
        }

        var maxScore int
        for _, score := range scores {
                if maxScore < score {
                        maxScore = score
                }
        }
        fmt.Printf("%d\n", maxScore)
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(void){
    int N, Y;
    cin >> N >> Y;
    
    int y10000, y5000, y1000;
    int total;
    
    if(N * 10000 < Y){
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    
    int total10000, total5000, total1000;
    /*
    for(y1000 = 0; y1000 <= N; y1000++){
        total1000 = y1000 * 1000;
        for(y5000 = 0; y5000 <= N - y1000; y5000++){
            total5000 = y5000 * 5000;
            for(y10000 = 0; y10000 <= N + y5000 - y1000; y10000++){
                total = y10000 * 10000 + total5000 + total1000;
                if(y10000 + y5000 + y1000 == N && total == Y){
                    cout << y10000 << " " << y5000 << " " << y1000 << endl;
                    return 0;
                }
                if(total > Y)
                    break;
            }
        }
    }
     */
    
    for(y10000 = N; y10000 >= 0; y10000--){
        total10000 = y10000 * 10000;
        for(y5000 = N - y10000; y5000 >= 0; y5000--){
            total5000 = y5000 * 5000;
            for(y1000 = N - y10000 - y5000; y1000 >= 0; y1000--){
                total = y1000 * 1000 + total5000 + total10000;
                if(y10000 + y5000 + y1000 == N && total == Y){
                    cout << y10000 << " " << y5000 << " " << y1000 << endl;
                    return 0;
                }
                if(total > Y)
                    break;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main() {
  int n,k,a;
  int ans = 0;

  cin >> n >> k;
  int x[n];
  
  rep(i,0,n){
    cin >> x[i];
  }

  rep(i,0,n){
    a = min(x[i],k-x[i]);
    ans += a;
  }

  printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
const int N = 1e6 + 10, Mod = 1e9 + 7;
int n, m, q, r, t, a, b, c, d, A[N];
int main()
{
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", (a - b + 1) * (a - c + 1));
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 3000000000000001 // 3e15
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fill(a, n, x) for(int i = 0; i < n; i++) a[i] = x;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
ll mod = 1000000007;
const ll N = 1000001;
const ll M = 1;

struct point
{
    ll x, y;
};

void debug(stringstream &s) {}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x,ll n)
{
    if(n == 0) return 1;
    ll ans = 1;
    if( n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}

ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

vector<ll> p;
void SoE(ll n)
{
    bool Primes[n + 1];
    Primes[0] = Primes[1] = 0;
    for(ll i = 2; i < n + 1; i++)
        Primes[i] = 1;
    for(ll i = 2; i * i <= n; i++)
    {
       if(Primes[i] == 1)
       {
           for(ll j = i; i * j <= n; j++)
           {
               Primes[i * j] = 0;
           }
       }
    }
    for(ll i = 2; i < n + 1; i++)
    {
        if(Primes[i])
        {
            p.push_back(i);
        }
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        test++;
        ll n, m, x, y, ans = 0, k;
        cin >> m;
        n = m;
        ll dp[m + 1] = {};
        dp[0] = 1;
        for(int i = 0; i <= m; i++)
        {
            for(int j = n; j >= 3; j--)
            {
                if(i - j >= 0)
                {
                    dp[i] += dp[i - j];
                    dp[i] %= mod;
                }
            }
            ans += dp[m];
            ans %= mod;
        }
        cout << ans << "\n";
    }
    return 0;
}


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

#define MAX 50

int main() {
	int N, M;
	string A[MAX], B[MAX];
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	string ans = "No";
	for (int x = 0; x <= N - M; x++) {
		for (int y = 0; y <= N - M; y++) {
			bool flg = true;
			for (int i = 0; i < M; i++) {
				for (int j = 0; j < M; j++) {
					if (A[x + i][y + j] != B[i][j]) {
						flg = false;
					}
				}
			}
			if (flg) {
				ans = "Yes";
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k, len;
char a[100005];

int main()
{
    scanf("%s%d",&a,&k);
    len = strlen(a);
    for(int i=0;i<len;i++) {
        int tmp = (26-a[i]+'a')%26;
        if(tmp <= k) {
            k -= tmp;
            a[i] = 'a';
        }
    }
    a[len-1] = ((a[len-1]-'a')+k)%26 + 'a';
    printf("%s\n",a);
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
#include <numeric>
using namespace std;

int main(){
    int n, m, x, y;
    vector<int> xs, ys;
    int xx, yy;
    cin >> n >> m >> x >> y;
    
    int i;
    
    for(i = 0; i < n; i++){
        cin >> xx;
        xs.push_back(xx);
    }
    
    for(i = 0; i < m; i++){
        cin >> yy;
        ys.push_back(yy);
    }
    
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    
    int mx, my;
    mx = xs[xs.size()-1];
    my = ys[0];
    
    if(x <= mx && mx < my && my <= y){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}


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

using namespace std;
using ll = long long;

int main() {
    int n = 0;
    cin >> n;
    int sum = 0;
    for(int i = 1;i <= n;i++){
        int tmp = 0;
        cin >> tmp;
        if(i % 2 == 1 && tmp % 2 == 1){
            sum++;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3620
//by rko27
//One more....
//---------------------------------------------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int  long long 
#define ll  long long 
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define nl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)(x.size())
#define god ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//----------------------------------------------------------------------------------------------------------------------------------------------------

const long double pi = 3.14159265358979323;
int mod=1000000000+7;
int modu=998244353;

//----------------------------------------------------------------------------------------------------------------------------------------------------

ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
void fun()
{
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	//#endif
	//786
}
bool isPrime(int n){for(int i=2;i*i<=n;i++)if(n%i==0) return false;return true;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}

//-------------------------------------------------------------------------------------------------------------------------------------------------------

const int N=1e6+7;
std::vector<int> v[N];

//--------------------------------------------------------------------------------------------------------------------------------------------------------



//--------------------------------------------------------------------------------------------------------------------------------------------------------
signed main() 
{
	god;
	//rko;
	fun();
	int ttt=1; //cin>>ttt;
	while(ttt--)
	{
		int n; cin>>n; 
		int a[n];
		map<int,int> m;
		for(int i=2;i<=n;i++) cin>>a[i], m[a[i]]++;
		for(int i=1;i<=n;i++) cout<<m[i]<<nl;
	}
	return 0;
}

Measured memory_bytes: 41136
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

string bigger(string a,string b){
    string aa,bb;
    if(a.size()>b.size()){
        return a;
    }else if(b.size()>a.size()){
        return b;
    }
    for(ll i=0;i<a.size();i++){
        aa=a[i];
        bb=b[i];
        if(stoi(aa)>stoi(bb)){
            return a;
        }else if(stoi(aa)<stoi(bb)) {
            return b;
        }
    }
    return a;
}

int main(){
    ll n,m;cin>>n>>m;
    ll aa[m];
    vector<ll> a;
    ll num[10]={0,2,5,5,4,5,6,3,7,6};
    ll b[8]={0,0,0,0,0,0,0,0};
    for(ll i=0;i<m;i++){
        cin>>aa[i];
        b[num[aa[i]]]=max(b[num[aa[i]]],aa[i]);
    }
    m=0;
    for(ll i=0;i<8;i++){
        if(b[i]!=0){
            m++;
            a.push_back(b[i]);
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    string dp[n+1][m];
    dp[0][0]="";
    for(ll i=1;i<=n;i++){
        if(i%num[a[0]]==0){
            dp[i][0]=dp[i-num[a[0]]][0]+to_string(a[0]);
        }else{
            dp[i][0]="";
        }
    }
    for(ll j=1;j<m;j++){
        for(ll i=0;i<=n;i++){
            if(i-num[a[j]]<0){
                dp[i][j]=dp[i][j-1];
            }else if(i==num[a[j]]){
                dp[i][j]=bigger(dp[i][j-1],(dp[i-num[a[j]]][j]+to_string(a[j])));
            }else if(dp[i][j-1]=="" && dp[i-num[a[j]]][j]==""){
                dp[i][j]="";
            }else if(dp[i][j-1]==""){
                dp[i][j]=dp[i-num[a[j]]][j]+to_string(a[j]);
            }else{
                dp[i][j]=bigger(dp[i][j-1],(dp[i-num[a[j]]][j]+to_string(a[j])));
            }
        }
    }
    cout<<dp[n][m-1]<<endl;
    return 0;
}



Measured memory_bytes: 79744
def A():
    n, a, b = map(int, input().split())
    print(min(a, b), max(a + b - n, 0))
#A()

def B():
    N = int(input())
    A = input()
    B = input()
    C = input()
    cnt = 0
    ans = 0
    for i in range(N):
        cnt = 0
        if A[i] == B[i]:
            if B[i] == C[i]:
                cnt = cnt
            elif B[i] != C[i]:
                cnt += 1
        if A[i] != B[i]:
            if A[i] != C[i] and B[i] != C[i]:
                cnt += 3
            elif A[i] != C[i] and B[i] == C[i]:
                cnt += 1
            elif A[i] == C[i] and B[i] != C[i]:
                cnt += 1
        if cnt == 1:
            ans += 1
        elif cnt == 3:
            ans += 2

    print(ans)
B()

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long[] ary=new long[n];
        PriorityQueue<Long> pq=new PriorityQueue<>();
        long gt=0;
        for(int i=0;i<n;i++){
            ary[i]=sc.nextLong();
            gt+=ary[i];
        }
        sc.close();
        long a=0;
        for(int i=0;i<n;i++){
            a+=ary[i];
            pq.add((long)Math.abs(gt-2*a));
        }
        System.out.println(pq.remove());
    }
}

Measured memory_bytes: 93076
#include <cstdio>
using namespace std;

const int maxn = 1e5 + 1;
int cnt[maxn];

int main(void) {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		int a;
		scanf("%d", &a);
		++cnt[a];
	}
	
	int x = 0, y = 0;
	for(int i = 1; i <= 100000; ++i) {
		if(cnt[i] & 1) {
			cnt[i] = 1;
		} else if(cnt[i]) {
			cnt[i] = 2;
			++x;
		}
		y += cnt[i];
	}
	
	y -= (x + 1) / 2 * 2;
	printf("%d\n", y);
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int l = sc.nextInt() + sc.nextInt();
		int r = sc.nextInt() + sc.nextInt();

		System.out.println(l > r ? "Left" :
			l < r ? "Right" : "Balanced");
	}

}


Measured memory_bytes: 21716
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc;// = new Scanner(System.in);
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int A[][] = new int[n][m];
        int B[][] = new int[m][l];
        long C[][] = new long[n][l];
        for(int x = 0;x<n;x++){
            sc.nextLine();
            for(int y = 0;y<m;y++){
                A[x][y] = sc.nextInt();
            }
        }

        for(int x = 0;x<m;x++){
            sc.nextLine();
            for(int y = 0;y<l;y++){
                B[x][y] = sc.nextInt();
            }
        }

        for(int x = 0;x<n;x++){
            for(int y = 0;y<l;y++){
                C[x][y] = 0;
                for(int z = 0;z<m;z++){
                    C[x][y] += A[x][z]*B[z][y];
                }
                if(y == 0){
                    System.out.print(C[x][y]);
                }else{
                    System.out.print(" "+C[x][y]);
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 59716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}

int main(){
  ll a, b; cin >> a >> b;
  
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  ll ans = 0;
  ans = factor(gcd(a, b)).size();
  if (gcd(a, b) == 1) ans = 0;
  cout << ans + 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {

	public static void main(String[] args) {
		
		Scanner cin = new Scanner(System.in);
		
		
		int[] nums = new int[3];
		
		nums[0] = cin.nextInt();
		nums[1] = cin.nextInt();
		nums[2] = cin.nextInt();
		
		Arrays.sort(nums);
		
		if (nums[0] == 5 && nums[1] == 5 && nums[2] == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}



Measured memory_bytes: 22732
/*
Date: 2017/01/07 19:53:21 Saturday
*/
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C;
char s[N];
int main(){
#ifdef LOCAL
	freopen("A.in","r",stdin);//freopen("A.out","w",stdout);
#endif
	scanf("%s",s);
	n=strlen(s);
	rep(i,0,n-1)if(s[i]==',')s[i]=' ';
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 764
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n,a,b,c,d;
  cin >>n >> a >> b >> c >> d;
  string s;
  cin >> s;
  a--;
  b--;
  c--;
  d--;
  for(int i=a;i<c;i++){
    if(s[i]=='#' && s[i+1]=='#'){
      cout << "No"<< endl;
      return 0;
    }
  }
  for(int i=b;i<d;i++){
    if(s[i]=='#' && s[i+1]=='#'){
      cout << "No"<< endl;
      return 0;
    }
  }
  if(c<d){
    cout << "Yes" << endl;
    return 0;
  }
  else{
    for(int i=b;i<=d;i++){
      if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No"<< endl;
    return 0;
  }
}

Measured memory_bytes: 592
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
    int sideH, sideW;
    
    char cha[101][101];
    
    int masu;
    int x, y; //in this problem y axis is sideH, x axis is sideW
    
    while (cin>>sideH>>sideW)
    {
        if (sideW == 0 && sideH == 0)
        {
            break;
        }
        
        for (y = 0; y < sideH; y++) //save the data to array
        {
            cin>>cha[y];
        }
        
        masu = x = y = 0; // start from 0, 0
        
        while (true)
        {
            if (cha[y][x] == '.')
            {
                cout<<x<<" "<<y<<endl;
                break;
            }
            
            switch (cha[y][x]) // walk automatically by symbol
            {
                case '^':
                    y--;
                    break;
                case '<':
                    x--;
                    break;
                case 'v':
                    y++;
                    break;
                case '>':
                    x++;
                    break;
            }
            
            masu++;
            
            if (masu > sideH * sideW) // means infinite loop, or out of the limit
            {
                cout<<"LOOP"<<endl;
                break;
            }
        }
    }

}

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

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

int main() {
  int N,K;cin >> N >> K;
  vector<long> A(N);
  for (int i=0;i<N;i++) {
    cin >> A.at(i);
  }
  long min_cost = 100000000000;
  for (int bit=0;bit<(1<<(N-1));bit++) {
    vector<long> B = A;
    long max_h=B.at(0);
    long cost=0;
    int color=1;
    for (int i=0;i<N-1;i++) {
      if ((bit>>i) & 1) {
        if (max_h >= B.at(i+1)) {
          cost += (max_h+1L-B.at(i+1));
          B.at(i+1) = max_h + 1L;
        }
        color++;
      }
      max_h = max(max_h,B.at(i+1));
    }
    if (color>=K) min_cost=min(cost,min_cost);
  }
  cout << min_cost << endl;
}

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    x = [int(i) for i in input().split()]

    n = []
    p = []
    ans = []
    for xi in x:
        if xi < 0:
            n.append(xi)
        else:
            p.append(xi)

    # print(n,p)

    # i: nから選ぶ個数
    # k-i: pから選ぶ個数
    for i in range(k+1):
        # print(i, k-i, k)
        if i > len(n):
            continue
        if k-i > len(p):
            continue

        if i == 0:
            ans.append(p[k-1])
        elif k - i == 0:
            ans.append(-n[-k])
        else:
            nd = -n[-i]
            pd = p[k-i-1]
            ans.append(nd + pd + min(nd, pd))

    # print(ans)
    print(min(ans))


if __name__ == '__main__':
    main()


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

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    ll t = 0;
    rep(i, m) {
        t += b[i];
    }

    int j = m;
    int ans = 0;
    rep(i, n + 1) {
        while(j > 0 && t > k) {
            --j;
            t -= b[j];
        }
        if(t > k) break;
        ans = max(ans, i + j);
        if(i == n) break;
        t += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4844
def resolve():
    (N, W) = list(map(int, input().split(" ")))
    wvs = [[None, None]]
    wvs.extend([list(map(int, input().split(" "))) for _ in range(N)])
    dps = [[0] * (W+1) for _ in range(N+1)]

    for i in range(1, N+1):
        for j in range(1, W+1):
            if j >= wvs[i][0]:
                dps[i][j] = dps[i-1][j-wvs[i][0]] + wvs[i][1]
            dps[i][j] = max(dps[i][j], dps[i-1][j])

    print(dps[N][W])

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 118768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=1e6+10;
const int mod=1e9+7;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l,r,d;
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            cnt++;
    }
    cout<<cnt<<'\n';






}


Measured memory_bytes: 3608
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

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

	struct sushi { 
		int t, d; 
		sushi(int t, int d) :t(t), d(d) {}
	};
	vector<sushi> s;
	for (int i = 0; i < N; i++) {
		int t, d;
		cin >> t >> d;
		s.emplace_back(t, d);
	}
	sort(s.begin(), s.end(), [](sushi l, sushi r) {return l.d > r.d; });

	set<int> variety;
	priority_queue<int, vector<int>, greater<int>> free;
	lint sat = 0;
	for (int i = 0; i < K; i++) {
		sat += s[i].d;
		if (!variety.emplace(s[i].t).second) free.emplace(s[i].d);
	}

	lint vsz = variety.size();
	sat += vsz * vsz;

	lint id = K;
	lint ans = sat;
	while (id < N && !free.empty()) {
		
		if (variety.emplace(s[id].t).second) {

			sat += s[id].d - free.top();
			free.pop();

			sat += 2 * vsz + 1; // -vsz^2 + (vsz + 1)^2
			vsz++;

			ans = max(ans, sat);
		}

		id++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int N = s.size();
  int cnt = 0;
  int count = 0;
  
  //条件1
  for(int i = 0; i < N/2; i++){
    if(s[i] != s[(N-1)-i]){
      cnt++;
//      cout << "1 is ok" << endl;
    }
  }
  
  //条件2
  int M = (N-1)/2;
  for(int i = 0; i < M; i++){
    if(s[i] != s[(M-1) -i]){
      cnt++;
//      cout << "2 is ok" << endl;
    }
  }
  
  
  //条件3
  int L = (N+3)/2;
  for(int i = L; i < N; i++){
    if(s[i] != s[N-1 - i]){
      cnt++;
//      cout << i << endl;
//      cout << s[i] << " " << s[N-1 - L] << endl;
//      cout << "3 is ok" << endl;
    }
  }
  
  if(cnt > 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 200005
using namespace std;
int n,k,tot;
int a[maxn],b[maxn],cnt[maxn];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+1+n);
	int sz=unique(b+1,b+1+n)-(b+1);
	for(int i=1;i<=n;i++)
	{
		a[i]=lower_bound(b+1,b+1+sz,a[i])-b;
		if(!cnt[a[i]])
			tot++;
		cnt[a[i]]++;;
	}
	sort(cnt+1,cnt+1+sz);
	if(tot<=k)
		return printf("%d\n",0),0;
	int ans=0;
	for(int i=1;i<=tot-k;i++)
		ans+=cnt[i];
	printf("%d\n",ans);
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,q,dp[M];
char in[M];
int main()
{
    while (~scanf("%d %d",&n,&q)) {
        scanf("%s", in+1);
        dp[0] = 0;
        REP(i,1,n) {
            if (i>=2 && in[i]=='C' && in[i-1]=='A')
                dp[i] = dp[i-2] + 1;
            else dp[i] = dp[i-1];
        }

        while (q--) {
            int l,r, ans;
            scanf("%d %d",&l,&r);
            ans = dp[r] - dp[l-1];
            if (l>=2 && in[l]=='C' && in[l-1]=='A') ans--;
            printf("%d\n", ans);
        }
    }
    
    return 0;
}



Measured memory_bytes: 1280
//参考資料
//https://qiita.com/drken/items/ace3142967c4f01d42e9
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val memo = Array(200000, { n })
    memo[0] = 0

    for (i in 0 until n) {
        var pow6 = 1
        while (pow6 + i <= n) {
            memo[i + pow6] = Math.min(memo[i + pow6], memo[i] + 1)
            pow6 *= 6
        }

        var pow9 = 1
        while (pow9 + i <= n) {
            memo[i + pow9] = Math.min(memo[i + pow9], memo[i] + 1)
            pow9 *= 9
        }
    }
    println(memo[n])
}

Measured memory_bytes: 42484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;


int main(){
	int x, y;
	cin >> x >> y;
	
	if(x%y==0){
		cout<<-1<<endl;
		return 0;
	}
	
	for(long long i=x; i<=1e18; i+=x){
		if(i%y !=0){
			cout << i << endl;
			return 0;
	}}
	
	
	return 0;
}




Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;

int main() {
	int64_t N;
	cin >> N;
	int64_t count = 0;
	int a = 10;
	if (N % 2 == 0) {
		N /= 2;
		while (N) {
			count += N / 5;
			N /= 5;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_M=1e5;
int N,M;
int X[MAX_M];
int seg[MAX_M-1];
int main(){
	cin>>N>>M;
	REP(i,M)cin>>X[i];
	sort(X,X+M);
	REP(i,M-1){
		seg[i]=X[i+1]-X[i];
	}
	sort(seg,seg+M-1);
	int ans=X[M-1]-X[0];
	REP(i,min(N-1,M-1)){
		ans-=seg[M-2-i];
	}
	cout<<ans<<endl;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n;
vll c,s,f;

int main(){
  cin >> n;
  c = vll(n+1);
  s = vll(n+1);
  f = vll(n+1);
  for(lli i = 1;i < n;i++) cin >> c[i] >> s[i] >> f[i];
  for(lli i = 1;i <= n;i++){
    lli t = 0;
    for(lli j = i;j < n;j++){
      t = max(t,s[j]);
      if(t % f[j] != 0) t += f[j] - (t%f[j]);
      t += c[j];
    }
    cout << t << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, int> Pr;
const lint INF = 1ll << 61;

int n, m;
lint x;
lint h[100000];
vector<Pr> g[100000];
lint dist[100000];

void solve()
{
	fill_n(dist, 100000, INF);
	dist[0] = 0;
	
	priority_queue<Pr, vector<Pr>, greater<Pr>> pq;
	for (pq.push(Pr(0, 0)); pq.size(); ){
		Pr p = pq.top(); pq.pop();
		lint sum = p.first;
		int v = p.second;
		if (dist[v] < sum) continue;
		
		lint ch = max(x - sum, 0ll);
		//printf("%d %lld %lld\n", v, sum, ch);
		for (auto &e : g[v]){
			int to = e.second;
			lint cost = e.first;
			
			lint nh = ch - cost;
			if (nh < 0) cost += -nh;
			else if (nh > h[to]) cost += nh - h[to];
			
			if (dist[to] > sum + cost){
				dist[to] = sum + cost;
				pq.push(Pr(sum + cost, to));
			}
		}
	}
	
	lint res;
	if (dist[n - 1] == INF) res = -1;
	else if (dist[n - 1] < x) res = dist[n - 1] * 2 + h[n - 1] - x;
	else res = dist[n - 1] + h[n - 1];
	
	printf("%lld\n", res);
}

int main()
{
	scanf("%d %d %lld", &n, &m, &x);
	
	for (int i = 0; i < n; i++){
		scanf("%lld", &h[i]);
	}
	
	for (int i = 0; i < m; i++){
		int a, b;
		lint t;
		scanf("%d %d %lld", &a, &b, &t);
		--a; --b;
		if (h[a] >= t) g[a].push_back(Pr(t, b));
		if (h[b] >= t) g[b].push_back(Pr(t, a));
	}
	
	solve();
	
	return 0;
}

Measured memory_bytes: 21360