akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin >> b[i];
    }
    for(int i=0;i<n-1;i++)
    {
        cin >> c[i];
    }
    
    long long answer = 0;
    for(int i=0;i<n-1;i++)
    {
        answer += b[a[i]-1];
        if(a[i]+1 == a[i+1])
        {
            answer += c[a[i]-1];
        }
    }
    answer += b[a[n-1]-1];
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    for i in range(n):
        a[i] = [a[i], i + 1]
    a.sort()
    ans = []
    for v in a:
        b, c = v
        ans.append(c)
    print(*ans)


if __name__ == '__main__':
    slove()


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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

const int MAX_EDGE = 200;

vector<int> graph[MAX_EDGE];
int match[MAX_EDGE];
bool used[MAX_EDGE];

int V;

void add_edge(int from, int to)
{
    graph[from].push_back(to);
    graph[to].push_back(from);
}

int dfs(int v)
{
    used[v] = true;
    for (int u : graph[v])
    {
        int w = match[u];
        if (w < 0 || !used[w] && dfs(w))
        {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }

    return false;
}

int bipartite_maching()
{
    int res = 0;

    memset(match, -1, sizeof(match));

    for (int v = 0; v < V; v++)
    {
        if(match[v] < 0)
        {
            memset(used, 0, sizeof(used));
            if(dfs(v))
            {
                res++;
            }
        }
    }

    return res++;
}

int main()
{
    int X, Y, E;    
    cin >> X >> Y >> E;
    V = X + Y;

    rep(i, E)
    {
        int x, y;
        cin >> x >> y;
        add_edge(x, X + y);
    }

    cout << bipartite_maching() << endl;

    return 0;
}


Measured memory_bytes: 3272
Roma = {"I" => 1, "V" => 5, "X" => 10, "L" => 50, "C" => 100, "D" => 500, "M" => 1000}
Minus = {"V" => 1, "X" => 1, "L" => 10, "C" => 10, "D" => 100, "M" => 100}
def toa(arg)
  temp = 1000
  return arg.inject(0){|sum, i|
    if Roma[i] > temp
      temp = Roma[i]
      sum - 2 * Minus[i] + Roma[i]
    else
      temp = Roma[i]
      sum + Roma[i]
    end
  }
end
while num = gets
  puts toa(num.chomp.split(//))
end

Measured memory_bytes: 6104
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n>>x>>y)
    {
        if(y<=x) cout<<"delicious"<<en;
        else if(y-x<=n) cout<<"safe"<<en;
        else cout<<"dangerous"<<en;
    }
}


Measured memory_bytes: 3608
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
l=[]
for i in range(0,m-1):
    l.append(abs(x[i+1]-x[i]))

l.sort()
if m-n>=0:
    ans=sum(l[0:m-n])
else:
    ans=0

print(ans)


Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
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;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
  string s;
  cin >> s;
  int ans=INF;
  rep (i,s.size()-2){
    ans = min(ans,abs(753-((s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0')));
  }
  cout << ans << endl;

}


Measured memory_bytes: 3620
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
difAB = [a-b for a,b in zip(A,B)]
sum_difAB = sum(difAB)
if sum_difAB<0:
  print(-1)
elif sum_difAB == 0:
  print(N)
else:
  difAB.sort()
  neg_num = 0
  neg_sum = 0
  for dif in difAB:
    if dif < 0:
      neg_num += 1
      neg_sum += dif
    else:
      break
  
  pos_num = 0
  pos_sum = 0
  for dif in difAB[::-1]:
    if pos_sum + neg_sum < 0:
      pos_num += 1
      pos_sum += dif
    else:
      break
  print(neg_num+pos_num)
  print()

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

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<double> p(n);
	vector<double> dp(n + 1, 0);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		for (int j = i; j >= 0; j--) {
			dp[j + 1] += dp[j] * p[i];
			dp[j] *= 1 - p[i];
		}
	}

	double ans = 0;
	for (int i = n; i > n / 2; i--) {
		ans += dp[i];
	}
	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main
 
import "fmt"
 
func main(){
	var  i int;
  	var num5,num7 int;
  	num5 = 2;
  	num7 = 1;
  for a:=0;a<3;a++{
    fmt.Scan(&i);  	
    if(i==5){
    	num5--;
    }else if(i==7){
    	num7--;
    }else{
    	continue;
    }
  }
  if(num5==0 && num7==0){
    fmt.Println("YES")	
  }else{
    fmt.Println("NO")
  }
  
}

Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define INF 1e9+5
#define ll long long
int main(void){
set<int> s;
int x,n;
cin>>x>>n;

int b;
for(int i=0;i<n;i++){
    cin>>b;
    s.insert(b);
}

int ans,ansdiff=INF;
for(int i=0;i<=101;i++){
    if(s.find(i)==s.end()){
        if(ansdiff > abs(x-i))
            {
                ansdiff= abs(x-i);
                ans=i;
            }
    }
}
cout<<ans;
    
}



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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ll K;
  cin >> K;

  ll a[50];
  FOR(i, 1, 50) a[i] = a[i - 1] + 1;
  REP(i, 50) { a[i] += K / 50L; }

  REP(i, K % 50L) {

    REP(j, 50) {
      if (i == j)
        a[j] += 50L;
      else
        a[j]--;
    }
  }

  cout << 50 << endl;
  REP(i, 50) cout << a[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {

	long long N = 0, X=0, Y = 0,D=0;
	cin >>N;
	int a = 0;
	for (long long i = 1; i <= N; i ++) {
		a+=i;
		

	}
	
	cout << a << endl;
	return 0;


}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    ll cnt = 0;
    REP(i, N){
        ll a; cin >> a;
        if(a%2 == 1) cnt++;
    }
    cout << (cnt%2 == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

long long dp[110][110][510];
int p[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	reverse(p,p+a);
	dp[1][1][p[0]]=1;
	for(int i=1;i<a;i++){
		for(int j=1;j<=a;j++){
			for(int k=1;k<=b;k++){
				if(!dp[i][j][k])continue;
				long long T=dp[i][j][k];
				if(j+1<=a&&k+p[i]<=b)dp[i+1][j+1][k+p[i]]=(dp[i+1][j+1][k+p[i]]+T)%mod;
				dp[i+1][j][k]=(dp[i+1][j][k]+T*max(0,k-(p[i]-1)*j))%mod;
				for(int l=1;l<=p[i]&&k+l<=b;l++){
					dp[i+1][j][k+l]=(dp[i+1][j][k+l]+T*2*j)%mod;
				}
				for(int l=1;l<=p[i]&&k+l<=b;l++){
					dp[i+1][j-1][k+l]=(dp[i+1][j-1][k+l]+T*j*(j-1)*(p[i]-l+1))%mod;
				}
			}
		}
	}
	printf("%lld\n",dp[a][1][b]);
}

Measured memory_bytes: 43392
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())

a, p = nm()
print((3 * a + p) // 2)

Measured memory_bytes: 3316
import java.util.*;
import java.math.*;

public class Main{

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[][] count = new int[10][10];
    for(int i = 1; i <= n; ++i) {
      int cur = i;
      int j = i % 10;
      if(j == 0) continue;
      while(cur >= 10) {
        cur /= 10;
      }
      int k = cur % 10;
      if(k == 0) continue;
      ++count[j][k];
    }
    int res = 0;
    for(int i = 1; i < 10; ++i) {
      for(int j = 1; j < 10; ++j) {
        res += count[i][j] * count[j][i];
      }
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 22996
#include  <bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u){
    cout<<a-1<<" "<<b<<endl;
  }else if(t==u){
    cout<<a<<" "<<b-1<<endl;
  }else
    cout<<a<<" "<<b<<endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int ans = max(min(B, D) - max(A, C), 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
   int N;
   cin>>N;
   string s;
   cin>>s;
   if(N%2==1){
       cout<<"No"<<endl;
   }
   else{
       string T=s.substr(0,s.length()/2);
       if(s==T+T){
           cout<<"Yes"<<endl;
       }
       else {
           cout<<"No"<<endl;
       }
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 998244353;

ll modInv(ll a, ll b = MOD - 2) {
	if (b & 1) return a * modInv(a, b ^ 1) % MOD;
	if (b == 0) return 1;
	return modInv(a*a % MOD, b >> 1);
}

const int N = 1e7;
ll fact[N+1];

ll choose(ll a, ll b) {
	if (a < b) return 0;
	ll dv = fact[b] * fact[a - b] % MOD;
	return fact[a] * modInv(dv) % MOD;
}

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

	int n;
	cin >> n;

	fact[0] = 1;
	for (int i = 1; i <= n; ++i) fact[i] = i * fact[i-1] % MOD;

	ll res = modInv(3, n);
	for (int k = n/2 + 1; k <= n; ++k) {
		ll add = choose(n, k) * modInv(2, n - k) % MOD;
		res -= 2*add;
	}
	res %= MOD;
	if (res < 0) res += MOD;
	cout << res << '\n';
}


Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &x[0], &x[n]
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int main(){
	string S;
	cin >> S;

	int ans = 0;
	rep(i, 0, 4)
		if(S[i] == '+') ans++;
		else ans--;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
pll ab[252521];

int main(){
  scanf("%d",&n);
  REP(i,n){
    ll a,b;
    scanf("%lld%lld",&a,&b);
    ab[i] = pll(a,b);
  }
  ll sum = 0;
  REP(i,n)sum += ab[i].first;
  ll mn = -1;
  REP(i,n){
    ll a = ab[i].first, b = ab[i].second;
    if(a<=b)continue;
    if(mn==-1){
      mn = b;
    }else{
      CHMIN(mn,b);
    }
  }
  ll ans = mn==-1 ? 0 : sum-mn;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 512
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, T = sc.nextInt()
    val A, B = new Array[Int](N)
    (0 until N) foreach { i =>
      A(i) = sc.nextInt()
      B(i) = sc.nextInt()
    }
    val idx = (0 until N).sortBy(i => A(i)).toArray

    val dp = Array.fill(N+1, T+1)(0)

    var _i = 0
    while (_i < N) {
      val i = idx(_i)
      var t = 0
      while (t < T) {
        val nextT = (t + A(i)) min T
        dp(_i+1)(nextT) = dp(_i+1)(nextT) max (dp(_i)(t) + B(i))
        dp(_i+1)(t) = dp(_i+1)(t) max dp(_i)(t)
        dp(_i+1)(t+1) = dp(_i+1)(t+1) max dp(_i)(t)
        t += 1
      }
      _i += 1
    }

    println(dp.map(_.max).max)
  }

}


Measured memory_bytes: 120204
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from math import sqrt

def get_yakusu(n):
    i = 1
    ans = []
    while i**2 <= n:
        if n % i == 0:
            ans.append((i, n//i))
        i += 1
    return ans

def main():
    n = int(input().strip())
    y = get_yakusu(n)
    ans = 10 ** 20
    for a, b in y:
        ans = min(ans, a-1+b-1)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 39988
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MaxN = 102;
const int MaxK = 1e5+2;
bool dp[MaxK], vis[MaxK];
int arr[MaxN];
int N;

bool rec(int rem){
    
    if(rem==0) return 0;
    if(rem<0) return 1;
    if(vis[rem]) return dp[rem]^1;
    vis[rem] = 1;
    auto &ret = dp[rem];
    ret = 1;
    for(int i=0; i<N; i++)
        ret = ret & rec(rem-arr[i]);

    return  ret^1;
}




void solve(){

    int total;
    cin>>N>>total;
    for(int i=0; i<N; i++)
        cin>>arr[i];

    bool ret = rec(total);
    if(ret) cout<< "First" << "\n";
    else cout<< "Second" << "\n";

}


int main(){

    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();

    return 0;
}


Measured memory_bytes: 10060
# D - RGB Triplets

n = int(input())
s = input()
assert len(s) == n

# post['R'][i] 位置i以降の'R'の個数
post = {a: [0] * (n + 1) for a in 'RGB'}
for i in range(n - 1, -1, -1):
    for a in 'RGB':
        post[a][i] = post[a][i + 1]
    post[s[i]][i] = post[s[i]][i + 1] + 1

def remain(a, b):
    return (list(set('RGB') - {a, b}))[0]

total = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            continue
        r = remain(s[i], s[j])
        total += post[r][j + 1]
        if j - i + j < n and s[j - i + j] == r:
            total -= 1
        
print(total)


Measured memory_bytes: 68828
#include <stdio.h>
#include <stdlib.h>

int N;

int edgeCount[271828];
int* edges[271828];

void addEdge(int from, int to) {
	int *c = &edgeCount[from];
	int **l = &edges[from];
	*l = realloc(*l, sizeof(**l) * (*c + 1));
	if (*l == NULL) exit(2);
	(*l)[(*c)++] = to;
}

int group[271828];
int group2[271828];

void dfs(int node, int g) {
	int i;
	int next = g == 1 ? 2 : 1;
	if (group[node] != 0) return;
	group[node] = g;
	for (i = 0; i < edgeCount[node]; i++) {
		dfs(edges[node][i], next);
	}
}

int gcount[2];
int gmember[2][271828];

int gsyori0, gsyori1;
int wariate[271882];

int main(void) {
	int i, j;
	int gcount[3] = {0};
	int threeCount;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N - 1; i++) {
		int a, b;
		if (scanf("%d%d", &a, &b) != 2) return 1;
		addEdge(a, b);
		addEdge(b, a);
	}

	dfs(1, 1);
	for (i = 1; i <= N; i++) {
		for (j = 0; j < edgeCount[i]; j++) {
			group2[edges[i][j]] = group[i] - 1;
		}
	}
	for(i = 1; i <= N; i++) {
		gmember[group2[i]][gcount[group2[i]]++] = i;
	}

	threeCount = N / 3;
	if (gcount[0] <= threeCount) {
		for (i = 3; i <= N && gsyori0 < gcount[0]; i += 3) {
			wariate[gmember[0][gsyori0++]] = i;
		}
		for (; i <= N && gsyori1 < gcount[1]; i += 3) {
			wariate[gmember[1][gsyori1++]] = i;
		}
		for (i = 1; i <= N && gsyori1 < gcount[1]; i++) {
			if (i % 3 == 0) continue;
			wariate[gmember[1][gsyori1++]] = i;
		}
	} else if (gcount[1] <= threeCount) {
		for (i = 3; i <= N && gsyori1 < gcount[1]; i += 3) {
			wariate[gmember[1][gsyori1++]] = i;
		}
		for (; i <= N && gsyori0 < gcount[0]; i += 3) {
			wariate[gmember[0][gsyori0++]] = i;
		}
		for (i = 1; i <= N && gsyori0 < gcount[0]; i++) {
			if (i % 3 == 0) continue;
			wariate[gmember[0][gsyori0++]] = i;
		}
	} else {
		for (i = 1; i <= N && gsyori0 < gcount[0]; i += 3) {
			wariate[gmember[0][gsyori0++]] = i;
		}
		for (i = 2; i <= N && gsyori1 < gcount[1]; i += 3) {
			wariate[gmember[1][gsyori1++]] = i;
		}
		for (i = 3; i <= N && gsyori0 < gcount[0]; i += 3) {
			wariate[gmember[0][gsyori0++]] = i;
		}
		for (; i <= N && gsyori1 < gcount[1]; i += 3) {
			wariate[gmember[1][gsyori1++]] = i;
		}
	}

	printf("%d", wariate[1]);
	for (i = 2; i <= N; i++) {
		printf(" %d", wariate[i]);
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 19840
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 55;
const int MAXM = 1010;
const int MAXK = 110;
const int MAXQ = 200010;

int n;
string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    char c = ' ';
    int res = 0;
    cin >> s;
    FOR(i,0,SZ(s)-1)
        if (s[i] == c) continue;
        else {
            c = s[i];
            res++;
        }
    cout << res;

    return 0;
}


Measured memory_bytes: 512
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 1e9+7;
//}}}

int a[100000];
int main(){
  int N;
  cin >> N;
  rep(i, N) cin >> a[i];
  sort(a, a+N);

  int ans = 1;
  rep(i, N){
    if(a[i] != (i + 2 - N % 2) / 2 * 2 + N % 2 - 1){
      cout << 0 << endl;
      return 0;
    }
    if (i % 2) {
      ans *= 2;
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;

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

}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ab[1100000],o=2,p=-1,ac[20],q=1;
pair<int,int> pp[20];
string s,ss[220000];
char c,ca;
queue<int> que;
signed main(){
    cin>>n;
    cout<<360/saidaikouyakusuu(n,360);
}


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

int V;
Graph G;
vector<int> d;
vector<int> f;
vector<int> color;

#define WHITE 0
#define GRAY 1
#define BLACK 2

int now;

void dfs(const Graph &G, int v){
    color[v] = GRAY;
    d[v] = ++now;
    for(auto nv : G[v]){
        if(color[nv]==WHITE){
            dfs(G, nv);
        }
    }
    color[v] = BLACK;
    f[v] = ++now;
}

int main()
{
    now = 0;
    cin >> V;
    G.resize(V);
    d.assign(V, -1);
    f.assign(V, -1);
    color.assign(V, 0);
    rep(j, V)
    {
        int from;
        cin >> from;
        --from;
        int k;
        cin >> k;
        rep(i,k){
            int to;
            cin >> to;
            --to;
            G[from].push_back(to);
        }
    }
    for (int i = 0; i < V; i++){
        if(color[i] == WHITE)
            dfs(G, i);
    }

    for (int i = 0; i < V; i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}


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

import itertools
import numpy as np


def main():

    n, m, x= map(int, input().split())
    matrix = np.array([list(map(int, input().split())) for _ in range(n)], dtype=np.int32)

    out = 10**18
    for i in itertools.product([False,True], repeat=n):
        row_sum = np.sum(matrix[np.where(i)], axis=0)
        if m == np.count_nonzero(row_sum[1:] >= x):
            out = min(out, row_sum[0])

    if out == 10**18:
        print('-1')
    else:
        print(out)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27356
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N; cin>>N;
  if(N==1){
   cout<<"0"<<endl;
  }
  else{
    int H[N];
    for(int i=0; i<N; i++){
      cin>>H[i];
    }
    vector<int> A(N);
    int i=0, x=0;
    for(int i=0; i<N-1; i++){
      if(H[i]>=H[i+1]){
        A[x]++;
      }
      else{
        x++;
      }
    }
    sort(A.begin(), A.end());
    cout<<A[N-1]<<endl;
  }
}


Measured memory_bytes: 1024
#include<cstdio>

int n, rem, x;
long long ans;

int main() {
	scanf("%d", &n);
	rem = 0;
	ans=0LL;
	for(int i=0;i<n;i++) {
		scanf("%d", &x);
		if (rem && x) {
			ans++; x--;
		}
		ans+=x/2;
		rem = x%2;
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

 int a,b;cin>>a>>b;
 if(((a*b)%2)==0){
   P("Even");
 }else{
   P("Odd");
 }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};

int main(){
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind u1(n);
    UnionFind u2(n);
    rep(i, k) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        u1.unite(p, q);
    }
    rep(i, l) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        u2.unite(r, s);
    }
    vector<P> v(n);
    map<P, int> mp;
    rep(i, n) {
        v[i] = P(u1.find(i), u2.find(i));
        mp[v[i]]++;
    }

    rep(i, n) {
        int ans = mp[v[i]];
        cout << ans << " ";
    }
    return 0;
}


Measured memory_bytes: 17612
"""
dp[i] : 足場i番目におけるコストの最小値
"""

N,K = map(int, input().split())
hs = list(map(int, input().split()))
INF = 10**10
dp = [INF]*110000
dp[0] = 0
for i in range(N):
    for j in range(K+1):
        #もらうDP
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i-j]+abs(hs[i-j]-hs[i]))
print(dp[N-1])

Measured memory_bytes: 52448
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m:usize = read();
    let mut a = vec![false; n+1];
    let mut w = vec![0; n+1];
    let mut ac = 0;
    let mut wa = 0;
    for _ in 0..m {
        let x:usize = read();
        let s:String = read();
        if a[x] {
            continue;
        }
        if s == "WA" {
            w[x] += 1;
        } else {
            a[x] = true;
            ac += 1;
            wa += w[x];
        }
    }
    println!("{} {}", ac, wa);
}


Measured memory_bytes: 2448
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> Q;

ll mod = 1000000007;
int n, k;
string s;
bool b[2];

int main()
{
	cin >> s;
	if (s[0] == '0')
	{
		if (s[1] != '0') b[0] = true;
	}
	if (s[0] == '1')
	{
		if (s[1] == '1' || s[1] == '2') b[0] = true;
	}
	if (s[2] == '0')
	{
		if (s[3] != '0') b[1] = true;
	}
	if (s[2] == '1')
	{
		if (s[3] == '1' || s[3] == '2') b[1] = true;
	}
	if (b[0] && b[1])
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if (b[0])
	{
		cout << "MMYY" << endl;
	}
	else if (b[1])
	{
		cout << "YYMM" << endl;
	}
	else
	{
		cout << "NA" << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a=0,b=0,x=0;
	scanf("%d %d",&a,&b);
	for(int i=0;i<2;i++){
		if(a>b){
			x+=a;
			a--;
		}
		else{
			x+=b;
			b--;
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
// 5/2

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

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

    bool have_okashi[N] = {false};

    for (int i = 0; i < K; i++) {
        int D;
        cin >> D;

        for (int j = 0; j < D; j++) {
            int a;
            cin >> a;
            a--;
            have_okashi[a] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (have_okashi[i] == false) ans++;
    }

    cout << ans << endl;
}


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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define MOD 1000000007

ll N;
vector <ll> A(10001);

ll modpow(ll n, ll k) {
    if(k == 0) return 1;
    if(k % 2 == 0) {
        ll tmp = modpow(n, k/2);
        return (tmp * tmp) % MOD;
    }
    return (n * modpow(n, k - 1)) % MOD;
}

void solve(){
    map<int, int> maap;
    for(int i = 1; i <= N; ++i){
        int a = A[i];
        for(int j = 2; j * j <= a; ++j){
            if(a % j == 0) {
                int k = 0;
                while(a % j == 0) { a /= j; k++; }
                maap[j] = max(maap[j], k);
            }
        }
        if(a > 1) maap[a] = max(maap[a], 1);
    }

    ll lcm = 1;
    for(auto it = maap.begin(); it != maap.end(); ++it){
        lcm *= modpow(it->first, it->second);
        lcm %= MOD;
    }

    ll ans = 0;
    for(int i = 1; i <= N; ++i){
        ans += (lcm * modpow(A[i], MOD - 2)) % MOD;
        ans %= MOD;
    }
    cout << ans;
}
int main(){
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 768
W, H, x, y = gets.split.map(&:to_i)
ans = W * H / 2
ama = W * H % 2

if W.to_f/2 == x.to_f and H.to_f/2 == y.to_f
  puts sprintf("%.6f %d", ans, 1)
else
  if ama == 1
    puts "#{ans}.5 0"
  else
    puts sprintf("%.6f %d", ans, 0)
  end
end


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  if (a % k == 0) {
    ANS("OK")
  } else {
    int t = a / k * k + k;
    if (t <= b) {
      ANS("OK");
    } else {
      ANS("NG");
    }
  }
  return 0;
}


Measured memory_bytes: 3620
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

string s;
string str = "CODEFESTIVAL2016";

int main() {
	int ans = 0;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != str[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) 
#define X first
#define Y second 
#define nl '\n'
#define AC return 0
#define mst(a,b) memset(a, b, sizeof a);
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef pair <int, int> PII;
const int N = 1e5+10, mod = 1e9+7, inf = 0x3f3f3f;


int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	cout<<b/c-(a-1)/c<<nl;
	
	AC;
} 

Measured memory_bytes: 3152
S = input()

is_easy = True
for s in S[0::2]:
    if s != 'R' and s != 'U' and s != 'D':
        is_easy = False
        break

if is_easy:
    for s in S[1::2]:
        if s != 'L' and s != 'U' and s != 'D':
            is_easy = False
            break

if is_easy:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<cstdio>

template<class _Tp>
	inline _Tp Abs(const _Tp&v)
		{return v<0?-v:v;}

template<class _Tp>
	inline _Tp Min(const _Tp&x,const _Tp&y)
		{return x<y?x:y;}
template<class _Tp>
	inline void chkMin(_Tp&x,const _Tp&y)
		{if(x>y)x=y;}

#define io (scanf(" %d",&_),_)

int x[100001];

inline int calc(const int&l,const int&r)
	{return(r<=0)?-l:((0<=l)?r:(r-l+Min(-l,r)));}

int main(){
	int _;
	const int n=io,k=io;
	for(int i=1;i<=n;++i)
		x[i]=io;

	int Ans=1e9;
	for(int i=1;i+k-1<=n;++i)
		chkMin(Ans,calc(x[i],x[i+k-1]));
	printf("%d\n",Ans);
}


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

char func(string str){
	for(int i=0;i<3;i++){
		if(str[i]==str[i+3] && str[i]==str[i+6]){if(str[i]!='s')return str[i];}
		else if(str[i*3]==str[i*3+1] && str[i*3]==str[i*3+2]){if(str[i*3]!='s')return str[i*3];}
	}
	if(str[0]==str[4] && str[0]==str[8]){if(str[0]!='s')return str[0];}
	else if(str[2]==str[4] && str[2]==str[6]){if(str[2]!='s')return str[2];}
	return 'd';
}

int main(){
	string ss;
	while(cin>>ss){
		cout<<func(ss)<<endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> v(n+2,0);
  for(int i=0;i<n;i++)
    cin>>v[i+1];
  long long ans=0;
  int tmp=0;
  for(int i=1;i<=n;i++){
    tmp=v[i]/2;
    ans+=tmp;
    if(v[i]%2==1&&v[i+1]!=0){
      v[i+1]--;
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    int N; cin >> N;

    int res = 0;
    FOR(A,1,N+1) {
        FOR(B,1,N+1) {
            if (A*B > N) break;
            int X = A*B;

            if (N-X > 0) {
                res++;
            } 
        }
    }

    cout << res << "\n";

}	

Measured memory_bytes: 3656
#include <stdio.h>
int main(){
  int S,h,m,s;
  scanf("%d",&S);
  h=S/3600;
  m=(S-h*3600)/60;
  s=(S-(h*3600+m*60))%60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 592
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val lucas = mutableListOf<Long>()
    lucas.add(2)
    lucas.add(1)
    for(i in (2..n)) {
        lucas.add(lucas[i-1]+lucas[i-2])
    }
    println(lucas[n])
}


Measured memory_bytes: 31796
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;



int main(){
	string s,t;
	cin>>s>>t;
	for(int i=0; i<3; i++){
		if(s[i]==t[i]) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
#define MOD 1000000007LL
typedef long long ll;
using namespace std;
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; }

int main() {
    ll N, ans = 0;
    cin >> N;
    FOR(i, 1, N+1) {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    string S; cin >> S;
    for(int i = 0; i < S.length();i++){
        string S1 = S.substr(0,i);
        string S2 = S.substr(i);
        
        set<int> s1(S1.begin(),S1.end()),s2(S2.begin(),S2.end());
        set<int> s;
        set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), std::inserter(s, s.end()));
        res = max(res,(ll)s.size());
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256