akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		// それぞれの店舗の開店時間帯
		int[][] f = new int[n][10];
		// それぞれの店舗との開店時間帯数による利益
		int[][] p = new int[n][11];
		long ans = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 10; j++){
			f[i][j] = sc.nextInt();
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= 10; j++){
			p[i][j] = sc.nextInt();
			}
		}

		// 開店時間帯の全ての組み合わせをループ
		int cnt = 1;
		while (cnt < Math.pow(2, 10)) {
			// 開店時間を設定
			long sum = 0;
			String open = String.format("%010d", Integer.valueOf(Integer.toBinaryString(cnt)));
		for (int i = 0; i < n; i++) {
			int same = 0;
			for (int j = 0; j < 10; j++) {
				if (open.substring(j, j + 1).equals("1") && f[i][j] == 1) {
					same++;
				}
			}
			sum += p[i][same];
		}
		if (ans < sum || cnt == 1) {
			ans = sum;
		}
		cnt++;
		}

		System.out.println(ans);

		sc.close();
	}
}


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

#define           sf        scanf
#define           pf        printf
#define           mx        200005
#define           read      freopen("in.txt", "r", stdin)
#define           optimize  ios::sync_base_stdio(0);cin.tie(0);

using namespace std;

int main()
{
    string s;
    int cn = 0;

    cin >> s;

    for(int i = 0, j = s.size()-1; i < s.size()/2; i++, j--)
    {
        if(s[i]!=s[j]) cn++;
    }

    cout << cn << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin >>a;
    int b[a][4];
    int count[4][3][10]={0};
    for (int i=0;i<a;i++){
        cin >>b[i][0]>>b[i][1]>>b[i][2]>>b[i][3];
        count[b[i][0]-1][b[i][1]-1][b[i][2]-1]+=b[i][3];
    }
    for (int j=0; j<3;j++){
        for (int i=0;i<10;i++){
           cout << " "<<count[0][j][i];
       }cout<<endl;
    }
       
    cout<<"####################"<<endl;
    for (int j=0; j<3;j++){
        for (int i=0;i<10;i++){
           cout << " "<<count[1][j][i];
       }cout<<endl;
    }
      
    cout<<"####################"<<endl;
    for (int j=0; j<3;j++){
        for (int i=0;i<10;i++){
           cout << " "<<count[2][j][i];
       }cout<<endl;
    }
     
    cout<<"####################"<<endl;
    for (int j=0; j<3;j++){
        for (int i=0;i<10;i++){
           cout << " "<<count[3][j][i];
       }cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3112
# ABC140c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
b = list(map(int, input().split()))
a = [0]*n

a[0] = b[0]
for i in range(n - 1):
    a[i] = min(a[i], b[i])
    a[i+1] = b[i]
    # print(a)
print(sum(a))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.nextLine();
        String word1 = sc.nextLine();
        int counter = 0;
        for(int p=0; p<word.length(); p++){
            if(word.charAt(p) != word1.charAt(p)){
                ++counter;
            }

        }
        System.out.println(counter);
    }
}

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

int main() {
    string S;
    cin >> S;
    deque<char> dq;
    for(int i=0; i<S.size(); i++){
        dq.push_back(S.at(i));
    }
    int Q;
    cin >> Q;
    int count=0;

    for(int i=0; i<Q; i++){
        int c=0;
        cin >> c;
        if(c==1){
            count++;
        }
        else{
            int f=0;
            cin >> f;
            char c;
            cin >> c;
            if((f+count)%2==1){
                dq.push_front(c);
            }
            else{
                dq.push_back(c);
            }
        }
    }
    if(count%2==1){
        reverse(dq.begin(),dq.end());
    }
    for(int i=0; i<dq.size(); i++){
        cout << dq.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 896
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

#define REP(i,n) for(int i=0;i<(n);i++)

int main(){
	int N,K;
	scanf("%d %d",&N,&K);
	if(N%K==0){
		printf("0\n");
	}else{
		int to = N/K;
		int sheng = N-K*to;
		printf("%d\n",sheng/K+1);
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
const double eps = 1e-11;

int main(){
	int N;
	vd a(8);
	cin >> N;
	rep(i,N){
		rep(i,8){
			cin>>a[i];
		}
		if(abs((a[1]-a[3])*(a[4]-a[6])-(a[5]-a[7])*(a[0]-a[2]))< eps){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;


     signed main(){
int h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;
cout<<(h2*60+m2)-(h1*60+m1)-k<<endl;

 }

 


 






    





      

        


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
    cin >> n >> m;
    cout << ((1900*m+100*(n-m))<<m) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int i,n;
    int a[100];
    scanf("%d", &n);
    for(i = 0;i < n;i++)
        scanf("%d", &a[i]);
  
    for(i = n - 1; i >= 0; i--) {
        printf("%d", a[i]);
        if(i != 0)
                printf(" ");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2068
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		sc.close();
		double circumference = 2 * r * Math.PI;
		double area = r * r * Math.PI;
		System.out.println(String.format("%.6f",area) + " " + String.format("%.6f",circumference));
	}
}



Measured memory_bytes: 28124
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 

using namespace std;
#define MAXN 1000001
// stores smallest prime factor for every number 
int spf[1000001]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n,i;
    cin>>n;
    int flag=0;
    int count=0;
    for(i=0;i<n;i++)
    {
        int d1,d2;
        cin>>d1>>d2;
        if(d1==d2) count++;
        else count=0;
        if(count==3) flag=1;
    }
    if(flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        String s = scan.next();
        long sum = 0;

        for (int i = 0; i<s.length(); i++) {
            int a = s.charAt(i) - '0';
            sum += a;
        }

        if (sum % 9 == 0) {

            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    string s;
    int w;
    cin >> s >> w;

    string ans;
    for (int i = 0; i < s.size(); i += w) {
        ans.push_back(s[i]);
    }

    cout << ans << endl;

    return 0;
}

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

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using isize = std::intptr_t;
using usize = std::uintptr_t;


u32 a[200000];

auto main() -> i32 {
	i32 n;
	scanf("%d", &n);
	u32 all = 0;
	for (i32 i = 0; i < n; ++i) {
		scanf("%u", a + i);
		all = all xor a[i];
	}
	for (i32 i = 0; i < n; ++i) {
		printf("%u%c", all xor a[i], i == n - 1 ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 3304
#include <iostream>

using namespace std;

int main()
{
  int n,l;
  cin>>n>>l;
  int answer = n*l+(n*(n+1))/2-n;
  if(l>=0)
    cout<<answer-l;
  else
  {
    if(n+l>0)
      cout<<answer;
    else
      cout<<answer-l-n+1;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 1010
#define MAXM 5010
using namespace std;

int n;
int p[MAXN],a[MAXN],b[MAXN],f[MAXN][MAXM];

bool gao(int x){
	int temp=-1;
	for(int i=0;i<=a[x];i++)
		if(f[x][i]!=-1) temp=min((temp==-1)?0x7FFFFFFF:temp,f[x][i]);
	if(temp==-1) return 0;
	b[x]=temp;
	return 1;
}

void trans(int x){
	int y=p[x];
	for(int i=a[y];i>=0;i--){
		int temp=-1;
		if(i>=a[x] && f[y][i-a[x]]!=-1) temp=min((temp==-1)?0x7FFFFFFF:temp,f[y][i-a[x]]+b[x]);
		if(i>=b[x] && f[y][i-b[x]]!=-1) temp=min((temp==-1)?0x7FFFFFFF:temp,f[y][i-b[x]]+a[x]);
		f[y][i]=temp;
	}
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=2;i<=n;i++) scanf("%d",p+i);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=n;i>=1;i--){
		if(!gao(i)){
			puts("IMPOSSIBLE");
			return 0;
		}
		if(i>1) trans(i);
	}
	puts("POSSIBLE");
	return 0;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, m; cin >> n >> m;
  vector<pair<int, int>> p(m);
  for(int i=0;i<m;++i) {
    cin >> p[i].first >> p[i].second;
    p[i].second--;
  }

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

  vector<int> l(n), r(n);
  for(int i=0;i<n;++i) {
    l[i] = i;
    r[i] = i;
  }

  for(int i=0;i<m;++i) {
    int y = p[i].second;
    r[y] = r[y+1];
    l[y+1] = l[y];
  }

  for(int i=0;i<n;++i) {
    cout << r[i] - l[i] + 1;
    if(i == n-1) cout << endl;
    else cout << " " ;
  }
}



Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int p=x, sum=0;
	while(p>0)
	{
		sum+=p%10;
		p/=10;
	}
	if(x%sum==0)
	{
		cout <<"Yes"<<endl;
		return 0;
	}
	else
	{
		cout <<"No"<<endl;
		return 0;
	}
	return 0;
}

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

using ll = long long;

struct Answer { ll sum; int ways; };

Answer solve(string S)
{
    const auto N = static_cast<int>(S.length());
    if (N == 0) return {0, 1};
    else
    {
        auto sum = 0LL;
        auto ways = 0;
        for (auto i = 1; i <= N; i++)
        {
            auto subanswer = solve(S.substr(i));
            sum += stoll(S.substr(0, i))*subanswer.ways + subanswer.sum;
            ways += subanswer.ways;
        }
        return {sum, ways};
    }
}

int main()
{
    string S; cin >> S;
    cout << solve(S).sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int H, W;
	cin >> H >> W;
	int ans = LLINF;
	REP(k, 2) {
		FOR(i,1, H) {

			int a = i*W;
			int b = (H - i)*(W / 2);
			int c = (H - i)*(W - W / 2);
			int cnt = max(a, max(b, c)) - min(a, min(b, c));
			ans = min(cnt, ans);
			b = (H - i) / 2 * W;
			c = (H - i - (H - i)/2)*W;
			cnt = max(a, max(b, c)) - min(a, min(b, c));
			ans = min(cnt, ans);
		}
		swap(H, W);
	}

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



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) { if (c)print("Yes"); else print("No"); };


void solve() {
	double R; cin >> R;
	print(2 * pi*R);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vl a(n);
    ll ans=0;
    int cnt1=0,cnt2=0,cnt3=0;
    rep(i,n){
        cin>>a[i];
        a[i]-=i+1;
        ans+=abs(a[i]);
        if(a[i]>0)cnt1++;
        if(a[i]<0)cnt2++;
        if(a[i]==0)cnt3++;
    }
    sort(all(a));
    if(cnt3+cnt1>=cnt2&&cnt3+cnt2>=cnt1){
        cout<<ans<<endl;
    }
    else{
        if(cnt3+cnt1<cnt2){
            ll d=cnt2-cnt1-cnt3,c=0;
            for(int i=cnt2-1;i>=(n-1)/2;--i){
                ans-=(c-a[i])*d;
                c=a[i];
                d-=2;
            }
        }
        if(cnt3+cnt2<cnt1){
            ll d=cnt1-cnt3-cnt2,c=0;
            for(int i=cnt2+cnt3;i<=(n-1)/2;++i){
                ans-=(a[i]-c)*d;
                c=a[i];
                d-=2;
            }
        }
        cout<<ans<<endl;
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int A, B;

int main(){
    cin >> A >> B;

    int ans = 0, n = 1;
    while (n < B) {
        n--;
        n += A;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	ll w, h;
	cin >> w >> h;

	if (w == 1 && h == 1) {
		cout << 1 << endl;
	}
	else if (w == 1 || h == 1) {
		cout << max(w - 2, h - 2) << endl;
	}
	else {
		cout << (w - 2)*(h - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp!
s_digit = s.length
s_i = s.to_i(2)

x1 = "01" * (s_digit / 2) + (s_digit % 2 == 1 ? '0' : '')
x2 = "10" * (s_digit / 2) + (s_digit % 2 == 1 ? '1' : '')

diff1 = (s_i ^ x1.to_i(2))
diff2 = (s_i ^ x2.to_i(2))

puts [
  diff1.to_s(2).chars.count {|ch| ch == '1' },
  diff2.to_s(2).chars.count {|ch| ch == '1' }
].min


Measured memory_bytes: 15356
h1, m1, h2, m2, k = map(int, input().split())
if m2-k < 0:
    m2 = 60+(m2-k)
    h2 -= 1
else :
    m2 -= k
minute1 = h1*60+m1
minute2 = h2*60+m2
print(minute2-minute1)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;

ll add(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a + b) % mod;
}

ll mul(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return 1LL * a * b % mod;
}

vector<pair<ll, ll> > v, p;
map<pair<ll, ll>, ll> mp, mp2, mp3;
ll n, dp[N], pw[N];


ll solve(int idx){
    if(idx == p.size()) return 1;
    if(dp[idx] != -1) return dp[idx];
    ll op1 = solve(idx + 1);
    ll op2 = 0, op3 = 0;
    if(mp.find(p[idx]) != mp.end()) op2 = mul(add(pw[mp[p[idx]]], -1), solve(idx + 1));
    if(mp2.find(p[idx]) != mp2.end()) op3 = mul(add(pw[mp2[p[idx]]], -1), solve(idx + 1));
    return dp[idx] = add(add(op1, op2), op3);
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    pw[0] = 1;
    for(int i = 1; i < N; i++) pw[i] = mul(pw[i - 1], 2);
    cin >> n;
    int kam = -1;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        if(!a && !b) {
            kam++;
            continue;
        }
        v.push_back({a, b});
    }
    for(int i = 0; i < v.size(); i++){
        auto p = v[i];
        if(!p.first || !p.second){
            if(!p.first) mp[{0, 1}]++;
            else mp2[{0, 1}]++;
            continue;
        }
        bool found = 0;
        ll a = p.first, b = p.second;
        if(a > 0 && b > 0) found = 1;
        if(a < 0 && b < 0) found = 1;
        a = abs(a);
        b = abs(b);
        ll g = __gcd(a, b);
        a /= g;
        b /= g;
        if(found) mp[{a, b}]++;
        else mp2[{b, a}]++;
    }
    for(auto i: mp) mp3[i.first] = 1;
    for(auto i: mp2) mp3[i.first] = 1;
    for(auto i: mp3) p.push_back(i.first);
    int ans = 1;
    for(auto i: p){
        ans = mul(ans, add(pw[mp[i]], pw[mp2[i]] - 1));
    }
    cout << add(ans, kam);

    /*memset(dp, -1, sizeof dp);
    cout << add(kam, solve(0));*/

    return 0;

}


Measured memory_bytes: 49044
N, P = map(int, input().split())
S = input()
ans = 0
if P == 2:
    for i, d in enumerate(S):
        if d in "02468":
            ans += i + 1
elif P == 5:
    for i, d in enumerate(S):
        if d in "05":
            ans += i + 1
else:
    x = 1
    curr = 0
    mods = [0] * P
    mods[0] = 1
    for d in reversed(S):
        curr = (curr + x * int(d)) % P
        ans += mods[curr % P]
        mods[curr % P] += 1
        x = x * 10 % P
print(ans)


Measured memory_bytes: 41180
#include <iostream>
#define calc(x,y) (x*y)\

using namespace std;

int main(int argc, char **argv)
{
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			cout << i << "x" << j << "=" << calc(i,j) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.Scanner;
 //O(100000000)
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = Long.parseLong(sc.next());
        long D = Long.parseLong(sc.next());

        int[] g = new int[100];
        for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        }
        for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        }
        
         for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        }
        
        

        System.out.print(cnt);
        System.out.println();
    }
}

Measured memory_bytes: 22996
#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>;
 
 
int main() {
    int n;
    cin >> n;
    n=10000-n;
    cout << n%1000 << endl;
}


Measured memory_bytes: 3632
a, b, c, d = map(int, input().split())
mod = 998244353

dp = [[0 for _ in range(c - a + 1)] for _ in range(d - b + 1)]
dp[0][0] = 1
for j in range(c - a + 1):
    for i in range(d - b + 1):
        if i == j == 0:
            dp[i][j] = 1
        elif i == 0:
            dp[i][j] = dp[i][j - 1] * b % mod
        elif j == 0:
            dp[i][j] = dp[i - 1][j] * a % mod
        else:
            tmp1 = (j + a - 1) * dp[i - 1][j] % mod
            tmp2 = (i + b - 1) * dp[i][j - 1] % mod
            tmp3 = -dp[i - 1][j - 1] * (i + b - 1) * (j + a - 1) % mod
            tmp4 = (dp[i - 1][j] + dp[i][j - 1]) % mod
            dp[i][j] = (tmp1 + tmp2 + tmp3 + tmp4) % mod
print(dp[-1][-1])

Measured memory_bytes: 146740
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int main(){
    int n,k;
    cin>>n>>k;
    int ma=0;
    vi vec(n);
    REP(i,n){
        cin>>vec[i];
        ma=max(ma,vec[i]);
    }
    int g=vec[0];
    FOR(i,1,n){
        g=gcd(g,vec[i]);
    }
    if(k>ma){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    if(k%g==0){
        cout<<"POSSIBLE"<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
struct node{
	string s;
	int point;
	int id;
}b[101];
int cmp(node a,node b){
	if(a.s==b.s)
		return a.point>b.point;
	return a.s<b.s;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>b[i].s;
		cin>>b[i].point;
		b[i].id=i+1;
	}
	sort(b,b+n,cmp);
	for(int i=0;i<n;i++)
		printf("%d\n",b[i].id);
}

Measured memory_bytes: 3780
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

template<typename T>
struct Comb{
  vector<T> fac,finv,inv,sinv;
  // Comb() {}
  Comb(int MAX_N):fac(MAX_N,1),finv(MAX_N,1),inv(MAX_N,1),sinv(MAX_N,1) {init(MAX_N);}
  void init(int MAX_N){
    fac.assign(MAX_N,1),finv.assign(MAX_N,1),inv.assign(MAX_N,1),sinv.assign(MAX_N,1);
    sinv[0]=0;
    for(int i=2;i<MAX_N;i++){
      fac[i]=fac[i-1]*i;
      inv[i]=-inv[mod%i]*(mod/i);
      finv[i]=finv[i-1]*inv[i];
      sinv[i]=sinv[i-1]+inv[i];
    }
  }
  T com(int n,int k){ //1≦k≦n≦10^7
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    return fac[n]*finv[k]*finv[n-k];
  }
  T per(int n,int k){ //1≦k≦n≦10^7
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    return fac[n]*finv[n-k];
  }
};
Comb<mint> comb(300000);

int main(){
  int n; cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1) cin >> a[i];
  map<int,int> mp;
  int cnt=0;
  rep(i,n+1){
    if(mp.count(a[i])) cnt=n+1-(i-mp[a[i]]+1);
    mp[a[i]]=i;
  }
  rep1(i,n+1){
    cout << comb.com(n+1,i)-comb.com(cnt,i-1) << endl;
  }
  
}

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

using namespace std;

vector<int> adj[100010];
int arr[100010];
int meml[100010];
int memr[100010];
const int INF = 1000000;

bool f(int x, int p, int l, int r, int d)
{
    if(arr[x] != -1)
    {
        if(arr[x] % 2 != d % 2 || arr[x] < l || arr[x] > r)
            return 0;
        l = r = arr[x];
    }

    for(int y : adj[x])
    {
        if(y == p)
            continue;

        if(!f(y, x, l - 1, r + 1, d + 1))
            return 0;

        l = max(l, meml[y] - 1);
        r = min(r, memr[y] + 1);
        if(r < l)
            return 0;
    }

    meml[x] = l;
    memr[x] = r;
    return 1;
}

bool g(int x, int p, int l, int r)
{
    if(arr[x] != -1 && (arr[x] < l || arr[x] > r))
        return 0;

    l = max(l, meml[x]);
    r = min(r, memr[x]);
    if(r < l)
        return 0;

    if(arr[x] == -1)
    {
        arr[x] = l;
        r = l;
    }

    for(int y : adj[x])
    {
        if(y == p)
            continue;

        if(!(g(y, x, l - 1, r + 1)))
            return 0;
    }

    return 1;
}

int main()
{
    int n, k, i;
    scanf("%d", &n);
    for(i = 0; i < n - 1; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    memset(arr, -1, sizeof arr);
    scanf("%d", &k);
    int s;
    for(i = 0; i < k; i++)
    {
        int x, p;
        scanf("%d%d", &x, &p);
        arr[x] = p;
        s = x;
    }

    bool ok = f(s, s, -INF, INF, arr[s] % 2);
    if(!ok)
    {
        puts("No");
        return 0;
    }

    ok = g(s, s, -INF, INF);
    if(!ok)
    {
        puts("No");
        return 0;
    }

    puts("Yes");
    for(i = 1; i <= n; i++)
        printf("%d\n", arr[i]);

    return 0;
}

Measured memory_bytes: 15360
#include <cstdio>
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <algorithm> // for sort
#include <limits.h>

using namespace std;

int main(void){
  long long int x,y,z,kLen;
  int i,j,k;
  vector<long long int> a,b,c;
  vector<long long int> total;
  
  cin >> x >> y >> z >> kLen;
  for(i=0; i<x; i++){
    long long int value;
    cin >> value;
    a.push_back(value);
  }
  for(i=0; i<y; i++){
    long long int value;
    cin >> value;
    b.push_back(value);
  }
  for(i=0; i<z; i++){
    long long int value;
    cin >> value;
    c.push_back(value);
  }
  
  std::sort(a.begin(),a.end(),std::greater<long long int>());
  std::sort(b.begin(),b.end(),std::greater<long long int>());
  std::sort(c.begin(),c.end(),std::greater<long long int>());
  
  long long int aMax = a[0];
  long long int bMax = b[0];
  long long int cMax = c[0];
  i=j=k=1;
  long long int diff = 0;
  long long int aDiff, bDiff, cDiff;
  while(1){
    aDiff = bDiff = cDiff = LLONG_MAX;
    if(i<a.size()){
      aDiff = aMax - a[i];
    }
    if(j<b.size()){
      bDiff = bMax - b[j];
    }
    if(k<c.size()){
      cDiff = cMax - c[k];
    }
	if(aDiff <= bDiff && aDiff <= cDiff){
      i++;
    }
	if(bDiff <= aDiff && bDiff <= cDiff){
      j++;
    }
	if(cDiff <= aDiff && cDiff <= bDiff){
      k++;
    }

    if( i==a.size()
       && j==b.size()
       && k==c.size() ) break;
    if (i*j*k >= kLen*15 ) break;
  }

  int l,m,n;
  for (l=0;l<i;l++){
    for(m=0;m<j;m++){
      for(n=0;n<k;n++){
        total.push_back(a[l]+b[m]+c[n]);
      }
    }
  }
  
  std::sort(total.begin(),total.end(),std::greater<long long int>());

  for(i=0;i<kLen;i++){
    cout << total[i] << endl;
  }

  return 0;
}




Measured memory_bytes: 904
def cabc(s):
    ans = 0
    for i in range(0, len(s) - 2):
        if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C':
            ans += 1
    print(ans)

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    cabc(in_str[1])

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b, x;
  cin >> a >> b >> x;
  if (a == 0) cout << b/x + 1 << endl;
  else cout << (b/x) - ((a-1)/x) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
x = gets.to_i
t ,a = gets.chop.split.map(&:to_i)
i = gets.chop.split.map(&:to_i)

hoge = 0
ans = 0
q = 0
while hoge < x do 
    q = ((t - i[hoge] * 0.006) - a).abs
    if hoge == 0 then
        min = q
        #1
        #5
        ans = hoge + 1
    elsif q < min then
        min = q
        ans = hoge + 1
    end
    hoge += 1
end

puts ans

Measured memory_bytes: 1916
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int n;
  cin>>n;
  int d=100000;
  rep(i,n){
    d*=1.05;
    if(d%1000!=0){
      d=d-(d%1000)+1000;
    }
  }
  cout<<d<<endl;
  return 0;
}

Measured memory_bytes: 3048
import java.util.*;

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int mn = Math.min(b, c);
        b -= mn;
        c -= mn;
        int ans = mn * 2;
        mn = Math.min(a+1, c);
        System.out.println(ans+mn+b);
        sc.close();
    }
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, M;
map<ll, ll> num;    // num[i]: 数 i が存在する数

signed main()
{
    cin >> N >> M;
    REP(i, N) {
        ll a;
        cin >> a;
        num[a]++;
    }
    REP(i, M) {
        ll b, c;
        cin >> b >> c;
        num[c] += b;
    }

    vector< pair<ll, ll> > num2;
    for(auto& n : num) {
        num2.push_back(make_pair(n.first, n.second));
    }
    sort(num2.begin(), num2.end(), greater< pair<ll, ll> >());

    ll ans = 0;
    ll cnt = 0;
    for(auto& n : num2) {
        if(cnt + n.second > N) {
            ans += n.first * (N - cnt);
            cnt = N;
        }
        else {
            ans += n.first * n.second;
            cnt += n.second;
        }
        if(cnt == N) { break; }
    }
    printf("%lld\n", ans);

    return 0;
}


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

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

  if (N / 1000 == N % 1000 / 100
   && N % 1000 / 100 == N % 1000 % 100 / 10) {
    cout << "Yes" << endl;
  }
  else if (N % 1000 / 100 == N % 1000 % 100 / 10
   && N % 1000 % 100 / 10 == N % 1000 % 100 % 10) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<ll>vp;


int main()
{
    FIO;
    ll a,b,c,d,e,f=0,sum=0,ck=0,m,n,k,l,t1=-1,t2=-1,p,q,r,t,add=0,x,y,z;
   vector<pii>v;
   cin>>n;
   for(int i=0;i<2*n;i++){
    cin>>l;
    vp.pb(l);
   }
   sort(vp.begin(),vp.end());
   for(int i=0;i<2*n;i++){
        if(i%2==0){
    sum+=vp[i];}
   }
  cout<<sum<<endl;
  vp.clear();
    return 0;
}



Measured memory_bytes: 3640
use scanner::Scanner;
use std::cmp::{max, min};

fn main() {
    let mut sc = Scanner::new();
    let w: i32 = sc.read();
    let h: i32 = sc.read();
    let n: i32 = sc.read();
    let mut x1 = 0;
    let mut y1 = 0;
    let mut x2 = w;
    let mut y2 = h;
    let xya: Vec<(i32, i32, i32)> = (0..n).map(|_| (sc.read(), sc.read(), sc.read())).collect();

    for (x, y, a) in xya {
        if a == 1 {
            x1 = max(x, x1);
        } else if a == 2 {
            x2 = min(x, x2);
        } else if a == 3 {
            y1 = max(y, y1);
        } else if a == 4 {
            y2 = min(y, y2);
        };
    }
    println!("{}", max(x2 - x1, 0) * max(y2 - y1, 0));
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<iterator>
using namespace std;

int main()
{
    string str;
    int N, i, j, count=0;
    cin>>N>>str;
    i = 0;
    j = N-1;
    while(i<j)
    {
        if(str[i]=='W' && str[j]=='R')
        {
            count+=1;
            i+=1;
            j-=1;
        }
        else if(str[i]=='W' && str[j]=='W')
        {
            j-=1;
        }
        else if(str[i]=='R' && str[j]=='R')
        {
            i+=1;
        }
        else
        {
            i+=1;
            j-=1;
        }
    }
    cout<<count<<endl;
    
}

Measured memory_bytes: 3752
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

ll N,K;

int main() {
    cin >> N >> K;
    cout << N-K+1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
N,Ma,Mb=map(int,input().split())
medic=[tuple(map(int,input().split())) for _ in range(N)]
from collections import defaultdict
inf = float('inf')
dp=defaultdict(lambda :inf)
dp[(0,0)]=0
for n in range(N):
    dpc=dp.copy()
    a,b,c=medic[n]
    for d,cost in dpc.items():
        da,db=d
        dp[(da+a,db+b)]=min(dp[(da+a,db+b)],c+cost)
ans=inf
nowa,nowb=Ma,Mb
while nowa<=400 and nowb<=400:
    ans=min(ans,dp[nowa,nowb])
    nowa+=Ma
    nowb+=Mb
if ans>4000:ans=-1
print(ans)

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

int main(){
    
    string s;
    cin >> s;
    
    for(int i=0; i<3; i++){
        if(s.at(i) == '1'){
            s.at(i) = '9';
        }
        else if(s.at(i) == '9'){
            s.at(i) = '1';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[200005],b[200005];
int lb(int k){
  int lb=-1,ub=n;
  while(ub-lb>1){
    int mid=(ub+lb)/2;
    if(b[mid]>=k)ub=mid;
    else lb=mid;
  }
  return ub;
}

signed main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  int ans=0;
  for(int k=(1<<28);k;k>>=1){
    for(int i=0;i<n;i++)a[i]&=(2*k-1);
    for(int i=0;i<n;i++)b[i]&=(2*k-1);
    sort(b,b+n);
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=lb(2*k-a[i])-lb(k-a[i]);
      sum+=n-lb(3*k-a[i]);
    }
    if(sum%2)ans+=k;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

string s;
ll d;
ll dp[MAXN][105];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> s;
    cin >> d;

    dp[0][0] = 1;
    REP1 (i,SZ(s)) {
        REP (j,d) {
            REP (k,10) {
                ll st = j-k;
                while (st < 0) {
                    st += d;
                }
                dp[i][j] += dp[i-1][st];
                dp[i][j] %= MOD;
            }
        }
    }
    ll sum = 0;
    ll ans = 0;
    REP (i,SZ(s)) {
        ll num = s[i]-'0';
        REP (j,num) {
            ll st = d-(j+sum);
            st %= d;
            while (st < 0) {
                st += d;
            }
            ans += dp[SZ(s)-i-1][st];
            ans %= MOD;
        }
        sum += num;
    }

    ans -= (sum%d != 0);
    while (ans < 0) {
        ans += MOD;
    }

    REP1 (i,SZ(s) - 1) {
        pary(dp[i],dp[i]+d);
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,t;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>s>>t;
      rrep(i,0,Size(s)){
        string co;
        rrep(j,i,Size(s)){
          cnt++;
          co+=s[j];
          if(j==Size(s)-1){
            if(cnt!=Size(s)){
              rrep(k,0,Size(s)-cnt){
                co+=s[k];
              }
              break;
            }
          }
        }
        cnt=0;
        if(co==t){
          Cout("Yes");
          return 0;
        }
      }
      Cout("No");
     

       
return 0;
}


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

int main(){
	ll n ; cin >> n ;
	vector<ll> a(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i) ;
	sort(a.begin(),a.end()) ;
	ll mx = a.at(n-1) ;
	ll sub = 0 ;
	ll pos = 0 ;
	for(int i=0;i<n-1;i++){
		if(sub<min(a.at(i),mx-a.at(i))){
			sub = min(a.at(i),mx-a.at(i)) ;
			pos = i ;
		}
	}
	cout << mx << " " << a.at(pos) << endl ;
}



Measured memory_bytes: 1024