akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define vecin(n, a) rep(i, n)scanf("%d", &a[i])

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int a, b, k;
	scanf("%d%*d%*d%*d%d%d", &a, &b, &k);
	printf("%s\n", b - a <= k ? "Yay!" : ":(");

	Please AC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    char a;
    cin >> a;
    
      if (isupper(a))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }
    
    
  
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main()
{
  int N; cin >> N;
  vector<pair<ll, ll>> AB(N); REP(i, N) cin >> AB[i].first >> AB[i].second;

  sort(ALL(AB), comp);

  ll t = 0;
  for (int i = 0; i < N; ++i) {
    t += AB[i].first;
    if (t > AB[i].second) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	string s; cin >> s;

	FOR_LT(i, 0, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(int argc, char *argv[]) {  
	std::string s;
	std::cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '9') s[i] = '1';
		else if (s[i] == '1') s[i] = '9';
	}
	std::cout << s;
}

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

int main(int argc, const char * argv[]) {
    long long int A, B;
    int K;
    cin >> A >> B >> K;
    
    long long int max, start, end;
    start = A;
    if (A + K > B) {
        end = B;
    }else{
        end  = A + K;
    }
    for (long long int i = start; i < end; i++) {
        cout << i << endl;
        max = i;
    }
    //cout << "-----" << endl;
    if(max >= B - K + 1){
        start = max + 1;
    }else{
        start = B - K + 1;
    }
    end = B;
    for (long long int i = start; i <= end; i++) {
        cout << i << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
void solve();int main() {FastIO;solve();return 0;}
// ====================================================================================
void solve()
{
	int a,b,c;
    cin>>a>>b>>c;
    if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){cout<<"YES";}
    else{cout<<"NO";}

}

Measured memory_bytes: 3564
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        String str = s.replace("-", "");
        int result = str.length() - (4 - str.length());

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define pp4 pair<pp, pp>
#define pp3 pair<ll, pair<int, int> > 
#define fi first
#define se second
#define N  200200
#define mod 1000000007
#define inf 2000000001
#define esp 1e-9
#define BLOCK 333
#define BITNUM 555
#define BASE 311097
typedef long long ll;
// const ll oo = (ll)1e18 + 1;
using namespace std;
int X, Y, A, B, C;
ll a[N];
ll b[N];
ll c[N];
vector<pp> z;
ll ass[N];

int main() {
    ios::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    cin >> X >> Y >> A >> B >> C;
    for (int i = 1; i <= A; i++) {
    	cin >> a[i];
    	z.pb(mp(a[i], 1));
    }

    for (int i = 1; i <= B; i++) {
    	cin >> b[i];
    	z.pb(mp(b[i], 2));
    }

   	for (int i = 1; i <= C; i++) {
   		cin >> c[i];
   		z.pb(mp(c[i], 3));
   	}
   	
   	sort(z.begin(), z.end());

   	int da = 0;
   	int db = 0;
   	int dc = 0;

   	ll suma = 0;
   	ll sumb = 0;

   	ll ret = 0;

   	for (int i = z.size() - 1; i >= 0; i--) {
   		da += (z[i].se == 1);
   		db += (z[i].se == 2);
   		dc += (z[i].se == 3);

   		if (da <= X && z[i].se == 1) {
   			suma += z[i].fi;
   		}

   		if (db <= Y && z[i].se == 2) {
   			sumb += z[i].fi;
   		}

   		if (z[i].se == 3) {
   			ass[dc] = ass[dc - 1] + z[i].fi;
   		}

   		int needa = max(0, X - da);
   		int needb = max(0, Y - db);
   		
   		if (needa + needb <= dc) {
   			ret = max(ret, suma + sumb + ass[needa + needb]);
   		}
   	}

   	cout << ret;
    return 0;
}



Measured memory_bytes: 10992
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll N=0,K=0;
    cin >> N >> K;
    ll count=0;
    
     vector<ll> vec(N+1);
    
    
    ll a=0;
    for(ll i=0;i<N;i++){
        cin >> a;
        for(ll j=0;j<a;j++){
            ll b=0;
            cin >> b;
            vec.at(b)++;
        }
    }
    
    for (ll i = 0; i < N; i++) {
        if(vec.at(i+1)==0)
        count++;
    }
    
    cout<<count;
    
    
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int n,m;
	while (cin >> n >> m, n) {
		vector<int> t(n);
		int sum_t = 0;
		for (int i = 0; i < n; ++i) {
			cin >> t[i];
			sum_t += t[i];
		}
		vector<int> h(m);
		int sum_h = 0;
		for (int i = 0; i < m; ++i) {
			cin >> h[i];
			sum_h += h[i];
		}

		bool find = false;
		for (int i = 0; !find && i < n; ++i) {
			for (int j = 0; !find && j < m; ++j) {
				if (sum_t-t[i]+h[j] == sum_h-h[j]+t[i]) {
					cout << t[i] << " " << h[j] << endl;
					find = true;
				}
			}
		}
		if (!find) {
			cout << -1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
using namespace std;
int main(){
 char s;cin>>s;
  if(s == 'G')cout << 'C' << endl;
  else if(s == 'C')cout << 'G' << endl;
  else if(s == 'A')cout << 'T' << endl;
  else cout << 'A' << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	int d=max(a,max(b,c));
	int sum=d*3-a-b-c;
	int ans=sum/2;
	if(sum&1)ans+=2;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5 + 5;

int N;
set<int> nonzero;
int arr[MAXN];

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    cin >> N;

    arr[0] = -1;
    nonzero.insert(0);

    for(int a = 1; a <= N; a++){
        cin >> arr[a];
        if(arr[a] != 0){
            nonzero.insert(a);
        }
    }

    ll ans = 0;
    for(int a = 1; a <= N; a++){
        int curv = arr[a] | (1 << 30);
        int cur = a;

        int lbnd;
        while(true){
            auto iter = nonzero.lower_bound(cur);
            if(arr[*prev(iter)] & curv){
                lbnd = *prev(iter) + 1;
                break;
            } else {
                curv |= arr[*prev(iter)];
                cur = *prev(iter);
            }
        }
        ans += a - lbnd + 1;
    }
    cout << ans;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ld n; cin >> n;
    cout << fixed << setprecision(10) << 2.0 * n * M_PI << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define SORT(v) sort(v.begin(),v.end())
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define deb(x) cout<< #x << " " << x << endl;

double pi=3.14159265358979323846;

typedef pair<int,int> pii;
typedef pair<long long int, long long int>pll;
typedef vector<int>vi;
typedef vector<long long int>vl;
#define MAXN 10000001
 
int main ()
{
    ll T;
   T=1;
   //cin>>T;
    while(T--)
    {	
    ll n;
    cin>>n;
    vi v(n);
    fori(i,0,n)cin>>v[i];
    vi dp(n,0);
    dp[1]=abs(v[1]-v[0]);
    ll mn=INT_MAX;
    for(int i=2;i<n;i++){
    	ll x=dp[i-1]+abs(v[i]-v[i-1]);
    	ll y=dp[i-2]+abs(v[i]-v[i-2]);
    	dp[i]=x<y?x:y;
    }
    
	cout<<dp[n-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

struct UF {
	vi t;
	UF( int n) {
		t.resize(n, -1);
	}

	int find(int a){
		return t[a]<0 ? a : t[a] = find(t[a]);
	}

	void uni(int a, int b){
		a = find(a), b = find(b);
		if( a == b) return;
		t[a] = b;
	}
};

int main(){
	int n;
	cin >> n;
	vi p(n);
	vector<pii> v01(n);
	rep(i,1,n){
		cin >> p[i];
		--p[i];
	}
	rep(i,0,n){
		int v;
		cin >> v;
		if(v == 0) v01[i].first++;
		else       v01[i].second++;
	}

	function<ll(pii, pii)> invs = [&](pii a, pii b){
		return ll(a.second) * b.first;
	};

	function<bool(int, int)> compare = [&](int a, int b){
		ll res1 = invs(v01[a],v01[b]), res2 = invs(v01[b],v01[a]);
		if(res1 < res2) return true;
		if(res2 < res1) return false;
		return a < b;
	}; // a should come before b

	UF uf(n);

	set< int, function<bool(int, int)> > s( compare );

	rep(i,1,n) s.insert(i);

	ll ans = 0;

	while(sz(s)){
		int i = *s.begin();
		s.erase(s.begin());
		int par = uf.find(p[i]);
		uf.uni(i, par);
		ans += invs( v01[par], v01[i] );
		
		if(par) s.erase(par);
		v01[par].first += v01[i].first;
		v01[par].second += v01[i].second;
		if(par) s.insert(par);
		
	}

	cout << ans << endl;

}

Measured memory_bytes: 13568
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
static const int MAX_G = 10;
static const int MAX_N = 2000;

int N, K;
vector<int> va[MAX_G];
int memo1[MAX_G][MAX_N + 1], memo2[MAX_G];

int main(){
	cin >> N >> K;
	fill(memo2, memo2 + 10, 0);
	for(int i = 0; i < N; i++){
		int C, G;
		cin >> C >> G;
		G--;
		va[G].push_back(C);
		memo2[G]++;
	}
	for(int i = 0; i < MAX_G; i++){
		if(i == 0) continue;
		memo2[i] += memo2[i - 1];
	}
	for(int i = 0; i < MAX_G; i++){
		sort(va[i].begin(), va[i].end());
		reverse(va[i].begin(), va[i].end());
		for(int j = 1; j < va[i].size(); j++){
			va[i][j] += 2 * j;
			va[i][j] += va[i][j - 1];
		}
	}
	for(int i = 0; i < MAX_G; i++) va[i].insert(va[i].begin(), 0);
	for(int i = 0; i < MAX_G; i++){
		for(int j = 0; j <= memo2[i]; j++){
			if(i == 0) memo1[i][j] = va[i][j];
			else{
				for(int l = 0; l <= j; l++){
					if(l < va[i].size()) memo1[i][j] = max(memo1[i][j], va[i][l] + memo1[i - 1][j - l]);
				}
			}
		}
	}
	cout << memo1[MAX_G - 1][K] << endl;
	return 0;
}



Measured memory_bytes: 3204
N = gets.to_i

i = 0
ans = 1000
while 9 * i <= N
  base_6 = N - 9 * i
  base_9 = 9 * i
  str = base_6.to_s(6) + base_9.to_s(9)
  ans = [ans, str.split("").map{|m| m.to_i}.inject(:+)].min
  i += 1
end
puts ans


Measured memory_bytes: 1916
// Problem : C - 100 to 105
// Contest : AtCoder - Sumitomo Mitsui Trust Bank Programming Contest 2019
// URL : https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    for(int a=0;a<=1000;a++){
        if(a*100 > n) break;
        for(int b=0;b<=1000;b++){
            if(a*100+b*101 > n) break;
            for(int c=0;c<=1000;c++){
                if(a*100+b*101+c*102 > n) break;
                for(int d=0;d<=1000;d++){
                    if(a*100+b*101+c*102+d*103 > n) break;
                    for(int e=0;e<=1000;e++){
                        if(a*100+b*101+c*102+d*103+e*104 > n) break;
                        for(int f=0;f<=1000;f++){
                            if(a*100+b*101+c*102+d*103+e*104+f*105 > n) break;
                            if(a*100+b*101+c*102+d*103+e*104+f*105 == n){
                                cout<<1;
                                return;
                            }
                        }
                    }
                }
            } 
        }
    }
    cout<<0;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = arr_data[0][0]
b = arr_data[0][1]
c=int(a+b)



print("Yes" if math.sqrt(c).is_integer() else "No")

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




int main() {
	string s, t, u;
	cin >> s >> t >> u;
	cout << s[0] << t[1] << u[2] << endl;

	return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, K = getNM()
R, S, P = getNM()
T = input()

ans = 0
flag = [0] * N
for i in range(N):
    if i >= K and T[i] == T[i - K] and flag[i - K] == 1:
        continue
    if T[i] == "r":
        ans += P
    elif T[i] == "s":
        ans += R
    else:
        ans += S
    flag[i] = 1
print(ans)


Measured memory_bytes: 67820
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;


string s, t;

int main(){
	cin >> s >> t;
	ll ans=0;
	REP(i,0,3){
		if(s[i] == t[i]){
			ans++;
		}
	}
	p(ans);
	return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N,D;
  cin>>N>>D;

  ll t = 2*D+1;
  cout<<(N+t-1)/t<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int INF=1e9;

const int N_MAX=1<<20;
const int DAT_SIZE=N_MAX*2-1;
int dat[DAT_SIZE],lazy[DAT_SIZE];
int n;

void init(int size){
  fill(begin(dat),end(dat),INF);
  n=1;
  while(n<size){
    n*=2;
  }
}

void lazy_eval(int k){
  dat[k]+=lazy[k];
  if(k<n-1){
    lazy[k*2+1]+=lazy[k];
    lazy[k*2+2]+=lazy[k];
  }
  lazy[k]=0;
}

int rangemin(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return INF;
  lazy_eval(k);
  if(a<=l&&r<=b){
    return dat[k];
  }else{
    int v1=rangemin(a,b,k*2+1,l,(l+r)/2);
    int v2=rangemin(a,b,k*2+2,(l+r)/2,r);
    return min(v1,v2);
  }
}

int rangeadd(int v,int a,int b,int k,int l,int r){
  if(r<=a||b<=l){
    lazy_eval(k);
    return dat[k];
  }else if(a<=l&&r<=b){
    lazy[k]+=v;
    lazy_eval(k);
    return dat[k];
  }else{
    lazy_eval(k);
    int v1=rangeadd(v,a,b,k*2+1,l,(l+r)/2);
    int v2=rangeadd(v,a,b,k*2+2,(l+r)/2,r);
    return dat[k]=min(v1,v2);
  }
}

void change(int x,int v,int k,int l,int r){
  lazy_eval(k);
  if(k<n-1){
    if(x<(l+r)/2){
      change(x,v,k*2+1,l,(l+r)/2);
    }else{
      change(x,v,k*2+2,(l+r)/2,r);
    }
    lazy_eval(k*2+1);
    lazy_eval(k*2+2);
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }else{
    dat[k]=v;
  }
}

int main(){
  int N,Q;
  cin>>N>>Q;
  init(N);
  char s[323456];
  cin>>s;
  for(int i=0,c=0;i<N;i++){
    c+=(s[i]=='(')-(s[i]==')');
    change(i,c,0,0,n);
  }
  for(int i=0;i<n*2-1;i++){
    //    cout<<i<<' '<<dat[i]<<endl;
  }
  while(Q--){
    int q;
    cin>>q;
    q--;
    if(s[q]=='('){
      rangeadd(-2,q,N,0,0,n);
      int l=-1,h=N;
      while(h-l>1){
	int m=(l+h)/2;
	if(rangemin(m,m+1,0,0,n)==m+1){
	  l=m;
	}else{
	  h=m;
	}
      }
      cout<<h+1<<endl;
      rangeadd(2,h,N,0,0,n);
      s[q]=')';
      s[h]='(';
    }else{
      rangeadd(2,q,N,0,0,n);
      int l=-1,h=q;
      while(h-l>1){
	int m=(h+l)/2;
	if(rangemin(m,q+1,0,0,n)<=1){
	  l=m;
	}else{
	  h=m;
	}
      }
      // cout<<l<<' '<<h<<endl;
      // for(int i=0;i<N;i++){
      // 	cout<<i<<' '<<rangemin(i,i+1,0,0,n)<<endl;
      // }
      // cout<<l<<' '<<h<<' '<<q<<endl;
      // cout<<rangemin(l,q+1,0,0,n)<<endl;
      // cout<<rangemin(h,q+1,0,0,n)<<endl;
      cout<<h+1<<endl;
      rangeadd(-2,h,N,0,0,n);
      s[q]='(';
      s[h]=')';
    }
    //cerr<<s<<endl;
  }
}

Measured memory_bytes: 12916
import io.StdIn.readLine


object Main {

  def main(args: Array[String]): Unit = {
    val s = readLine()
    val res = s.foldLeft((0, s.charAt(0))) { (acc, c) =>
      if (acc._2 != c) (acc._1 + 1, c)
      else acc
    }

    println(res._1)
  }

}


Measured memory_bytes: 26932
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vll a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	vll bc(n);
	rep(i, n) {
		bc[i] = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
	}
	bc.push_back(0);	// bc[n] = 0
	for(int i = n; i >= 1; i--) bc[i-1] += bc[i];
	ll ans = 0;
	rep(i, n) {
		int j = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
		ans += bc[j];
	}
	cout << ans << endl;
}


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

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

void solve(std::string S)
{
    int ac = 0;
    int bc = 0;

    for(char c : S)
    {
        if(c == 'A')
        {
            ac++;
        }
        else if(c == 'B')
        {
            bc++;
        }
    }
    if(ac > 0 && bc > 0)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Hello{
    public static void Main(){
        int ans=0;
        
        while(true)
        {
            int [] read=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a=read[0];
            int b=read[1];
            if(a==0)break;
            
            for(int i=1;i<=a;i++)
            {
                for(int j=i+1;j<=a;j++)
                {
                    for(int w=j+1;w<=a;w++)
                    {
                        if((i+j+w)==b&&(i!=j&&j!=w&&i!=w))
                        {
                            ans++;
                        }
                        
                    }
                }
            }
            Console.WriteLine(ans);
            ans=0;
        }
    }
}


Measured memory_bytes: 20384
(defvar *days*
  '("SUN" "MON" "TUE" "WED" "THU" "FRI" "SAT"))

(defun solve (s)
  (- 7 (position s *days* :test 'equal)))

#-swank
(let ((s (read-line)))
  (format t "~A~%" (solve s)))


Measured memory_bytes: 11488
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;


int main()
{
    jaldi
    int n;
    cin>>n;
    string s;
    cin>>s;
    int q;
    cin>>q;
    set<int> ans[26];
    for(int i=0;i<n;i++)
    {
        int id=s[i]-'a';
        ans[id].insert(i+1);
    }
    // for(int i=0;i<26;i++)
    // {
    //     for(int it:ans[i]) cout<<it<<" ";
    //     cout<<endl;
    // }
    //check;
    while(q--)
    {
        int qt;
        cin>>qt;
        if(qt==1)
        {
            int ind;
            char ch;
            cin>>ind>>ch;
            char juno=s[ind-1];
            auto it=ans[juno-'a'].find(ind);
            ans[juno-'a'].erase(it);
            s[ind-1]=ch;
            ans[ch-'a'].insert(ind);
        }
        else
        {
            int l,r;
            cin>>l>>r;
            int count=0;
            for(int i=0;i<26;i++)
            {
                auto it=ans[i].lower_bound(l);
                if(it!=ans[i].end())
                {
                    int left=*it;
                    if(left<=r) count++;
                }
            }
            cout<<count<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25116
n = int(input())
d=[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]

x=[]
for i in range(n):
    x.append(str(d[i]))
k=' '.join(x)
print(k)

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

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

  int A[200000+5];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  for(int i = 0; i < N - K; i++) {
    cout << (A[i] < A[i+K] ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 4352
/*author ADITYA BANSAL
         MNNIT ALLAHABAD     */
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long
ll power(ll,ll);
ll mul(ll a,ll b);
#define watch(x) cerr<<(#x)<<"is"<<x<<nl;
#define mod 1000000007
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi(a,b) for(ll i=a; i<b; i++)
#define fk(a,b) for(ll k=a; k<b; k++)
#define fri(a,b) for(ll i=a; i>b; i--)
#define fj(a,b) for(ll j=a; j<b; j++)
#define ffi(a,b) for(ll i=a;i*i<=b;i++)
#define mp make_pair
#define ff first 
#define  tc ll t; cin>>t; while(t--)
#define all(v) (v).begin(),(v).end()
#define ss second
#define pb push_back
#define mem(v) memset((v),0,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define pob pop_back
#define nl endl
const ll  N=1000002LL;

signed main(){ fast
  //tc
 { ll n;
 cin>>n;
 ll a[n+1],b[n];
 fi(0,n+1) cin>>a[i];
 fi(0,n) cin>>b[i];
 ll ans=0;
 fi(0,n) { if(a[i]-b[i]>=0)
    { ans+=b[i];
	b[i]=0;
	}
	else { ans+=a[i]; b[i]-=a[i];} 
	if(a[i+1]-b[i]>=0)
	 { ans+=b[i]; a[i+1]-=b[i];}
	 else
	{ ans+=a[i+1]; a[i+1]=0;}	
}
 cout<<ans<<nl;
 
 }
    return 0;
}


/******************************************************************************/

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

/*--------------------<<BINARY EXPONENTIATION>>--------------------*/
ll power(ll a,ll n){
  ll res=1;
  while(n){
      if(n&1) res= mul(res,a);
     n>>=1; 
     a= mul(a,a);
  }
    return res;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	
	int n;
	int s[60000]={0};
	
	s[2]=1;
	
	for(int i=3;i<=60000;i+=2){
		int k=0;
		for(int j=3;j<=sqrt(i);j+=2){
			if(i%j==0)
			{
				k=1;
				break;
			}
		}
		if(k==0)
			s[i]=1;
	}
	while(cin>>n){
		for(int i=n-1;i>=2;i--){
		if(s[i]==1){
			cout<<i<<" ";
			
			break;
		}
	}
	for(int i=n+1;i<=60000;i++){
		if(s[i]==1){
			cout<<i<<endl;
			break;
		}
	}
	
	}
}

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

long long n,a[100005],dp[1][100005];
int main(){
	cin>>n;
	for (long long i=1;i<=n;i++){
		cin>>a[i];
	}
	dp[0][1]=a[1];
	dp[1][1]=-a[1];
	for (long long i=2;i<=n;i++){
		dp[0][i]=max(dp[0][i-1]+a[i],dp[1][i-1]-a[i]);
		dp[1][i]=max(dp[0][i-1]-a[i],dp[1][i-1]+a[i]);
	}
	cout<<dp[0][n];
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;


  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C; cin >> A >> B >> C;
    cout << (A+B+C-max({A,B,C})-min({A,B,C})==C?"Yes":"No") << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n, a; cin >> n >> a;
    vector<ll> x;
    rep(i,0,n){
        ll tmp; cin >> tmp;
        tmp -= a;
        x.pb(tmp);
    }

    // [j番目まで使用する][t-NXとなる組み合わせ]
    // dp[0][n*X] = 0
    // 
    ll dp[n+1][5001];
    rep(i,0,n+1) rep(j,0,5001) dp[i][j] = 0;
    dp[0][2500] = 1;
    rep(i,0,n){
        rep(j,0,5001){
            if(j - x[i] >= 0 && j - x[i] <= 5000)
                dp[i+1][j] = dp[i][j-x[i]] + dp[i][j];
            else
                dp[i+1][j] = dp[i][j];
        }
    }
    cout << dp[n][2500] - 1 << ednl;

}


Measured memory_bytes: 2304
s = str(input())
temp = s[0]
X = []
cnt = 0
for i in range(len(s)):
    if s[i] == temp:
        cnt += 1
    else:
        temp = s[i]
        X.append(cnt)
        cnt = 1
else:
    X.append(cnt)
print(len(X)-1)


Measured memory_bytes: 45168
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N, x, y, q, c int
  var P []int
  NextInt(&N)
  NextIntVec(&P)
  C := make([][]int, N + 2)
  for i := range C { C[i] = make([]int, N + 2) }
  S := make([][]int, N + 2)
  for i := range S { S[i] = make([]int, N + 2) }
  for i := 0; i < N; i++ {
    for j := 0; j < N; j++ {
      C[i + 1][j + 1] = MinInt(i, j, N - 1 - i, N - 1 - j)
      S[i + 1][j + 1]++
    }
  }
  cnt := 0
  Q := make([]int, 0)
  for _, p := range P {
    p--
    x, y = p / N + 1, p % N + 1
    cnt += C[x][y]
    S[x][y] = 0
    Q = append(Q, p)
    for 0 < len(Q) {
      q, Q = Q[0], Q[1:]
      x, y = q / N + 1, q % N + 1
      c = C[x][y] + S[x][y]
      if c < C[x - 1][y] { C[x - 1][y] = c; Q = append(Q, q - N) }
      if c < C[x + 1][y] { C[x + 1][y] = c; Q = append(Q, q + N) }
      if c < C[x][y - 1] { C[x][y - 1] = c; Q = append(Q, q - 1) }
      if c < C[x][y + 1] { C[x][y + 1] = c; Q = append(Q, q + 1) }
    }
  }
  Write(cnt)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 23388
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(0);cin.tie(0);
#define mod 1000000007
#define pi 2*acos(0)
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
using namespace std;



int main()
{

	io;
	
	int n; cin >> n;
	//a*b + c = n
	// a * b < n
	// b < floor(a/n)
	//#b = floor(a/n) if odd , floor(a/n) - 1 if even

	//a <= n/2

	ll ans = 0;
	for (int a = 1; a < n ; a++) {

		ans+= ((n-1) / a);

		/*if (a % 2 == 0)
			--ans;*/

	}
	cout << ans;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 998244353;
const int INF = 1e12;

int gcd(int a, int b){
   if(a < b) swap(a, b);
   if(b == 0) return a;
   return gcd(b, a % b);
}

// int extgcd(int a, int b, int& x, int& y){
//     int d = a;
//     if(b != 0){
//         d = extgcd(b, a % b, y, x);
//         y -= (a / b) * x;
//     }else{
//         x = 1; y = 0;
//     }
//     return d;
// }

long long mod_pow(long long x,long long n){
    if(n==0) return 1;
    long long res = mod_pow(x*x % mod, n/2);
    if(n & 1) res = res*x % mod;
    return res;
}
long long fact[300010];
long long get_nCk(long long n, long long k, long long mod){
    if(fact[0] == 0){
        fact[0] = 1;
        for(int i = 1; i < 300010; i++) fact[i] = fact[i-1] * i % mod;
    }
    return fact[n] * mod_pow(fact[k], mod - 2) % mod * mod_pow(fact[n - k], mod - 2) % mod;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b, k;
    cin >> n >> a >> b >> k;
    int g = gcd(a, b);
    if(k % g != 0){
        cout << 0 << endl;
        return 0;
    }
    a /= g; b /= g; k /= g;
    int ans = 0;
    rep(i, 0, n + 1){
        int tmp = k - a * i;
        if(tmp % b != 0) continue;
        int j = tmp / b;
        if(j < 0 || n < j) continue;
        int now = get_nCk(n, i, mod) * get_nCk(n, j, mod) % mod;
        ans = (ans + now) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;

int main()
{
  int64_t N, K, a, b, negs = 0, ans = 1;
  cin >> N >> K;
  vector<pair<int64_t, int64_t>> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (a >= 0)
      A[i] = {a, 0};
    else
      A[i] = {abs(a), 1};
    if (a < 0)
      negs++;
  }
  sort(A.begin(), A.end());

  if (N == K)
  {
    for (int i = 0; i < K; i++)
    {
      if (A[i].second)
        ans = (ans * -A[i].first) % MOD;
      else
        ans = (ans * A[i].first) % MOD;
    }
    cout << (ans + MOD) % MOD << endl;
    return 0;
  }

  if (negs == N && K % 2) // 全部マイナスで奇数
  {
    for (int i = 0; i < K; i++)
    {
      ans = (ans * -A[i].first) % MOD;
    }
    cout << (ans + MOD) % MOD << endl;
    return 0;
  }

  reverse(A.begin(), A.end());
  int64_t neg = 0;
  for (int i = 0; i < K; i++)
  {
    tie(a, b) = A[i];
    if (b)
      neg++;
  }

  if (neg % 2)
  {
    int64_t mineg = -1, mipos = -1, maneg = -1, mapos = -1, mipid = -1, minid = -1;
    // 負の数のうち、最小の物を探す & 正の数のうち、最小の物を探す
    for (int i = 0; i < K; i++)
    {
      if (A[i].second)
      {
        mineg = A[i].first;
        minid = i;
      }
      else
      {
        mipos = A[i].first;
        mipid = i;
      }
    }
    // 残りの負の数のうち、絶対値が最大の物を探す
    for (int i = K; i < N; i++)
    {
      if (A[i].second) // 負の数
      {
        maneg = A[i].first;
        break;
      }
    }
    // 残りの正の数のうち、絶対値が最大の物を探す
    for (int i = K; i < N; i++)
    {
      if (!A[i].second) // 正の数
      {
        mapos = A[i].first;
        break;
      }
    }

    // 正の数しかない場合 or 追加できる正の数がない場合 -> 正の数を減らして、負の数を足すのみ
    if (mineg == -1 || mapos == -1)
    {
      for (int i = 0; i < K; i++)
      {
        if (i != mipid)
          ans = (ans * A[i].first) % MOD;
      }
      ans = (ans * maneg) % MOD;
    }
    else if (mipos == -1 || maneg == -1) // 負の数しかない場合 or 追加できる負の数がない場合 -> 負の数を減らして、正の数を足すのみ
    {
      for (int i = 0; i < K; i++)
      {
        if (i != minid)
          ans = (ans * A[i].first) % MOD;
      }
      ans = (ans * mapos) % MOD;
    }
    else
    {
      if (mapos * mipos > maneg * mineg) // 正の数を足す
      {
        for (int i = 0; i < K; i++)
        {
          if (i != minid)
            ans = (ans * A[i].first) % MOD;
        }
        ans = (ans * mapos) % MOD;
      }
      else
      {
        for (int i = 0; i < K; i++)
        {
          if (i != mipid)
            ans = (ans * A[i].first) % MOD;
        }
        ans = (ans * maneg) % MOD;
      }
    }
  }
  else // 偶数
  {
    for (int i = 0; i < K; i++)
    {
      ans = (ans * A[i].first) % MOD;
    }
  }
  cout << (ans + MOD) % MOD << endl;
}

Measured memory_bytes: 6420
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int r;
	cin>>r;
	cout<<3*r*r<<endl;
	return 0;
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    string a, b, c;
    cin >> a >> b >> c;

    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int N, C;
int s[100000],t[100000],c[100000]; 
//時刻tを何個の区間が覆っているかをsm[t]に格納する。
int sm[200002];
//以下のfor文でsmの構築のために用いる一時配列。
//各チャンネルiについて、時刻jが区間に覆われているとき、tt[j]>0となるようにする。
int tt[200002]; 

int main () {
  scanf("%d%d",&N,&C); 
  for(int i=0;i<N;i++) scanf("%d%d%d",&s[i],&t[i],&c[i]);
  for(int i=1;i<=C;i++){//各チャンネルiについて
    for(int j=0;j<200002;j++)tt[j] = 0;
    for(int j=0;j<N;j++) if(c[j]==i) tt[s[j]*2-1]++,tt[t[j]*2]--; 
    for(int j=1;j<200002;j++)tt[j]+=tt[j-1];
    for(int j=0;j<200002;j++)if(tt[j]>0)sm[j]++;
  }
  int mx = 0;//求める最大値(答え)
  for(int j=0;j<200002;j++) if(mx < sm[j]) mx = sm[j];
  printf("%d\n",mx);
}


Measured memory_bytes: 4456
#include <iostream>
#include <string>
using namespace std;
string s;
int K;

int main(){
    cin>>s;
    cin>>K;
    for(auto &c:s){
        int n=(26-(int)(c-'a'))%26;
        if(K>=n){
            c='a';
            K-=n;
        }
    }
    s.back()+=(char)(K%26);
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 576
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
int main (){
  int d,e;
  while(cin >> d >> e,d){
    double min=200;
    for(int x=0;x<=d;x++){
      if(abs(sqrt(x*x+(d-x)*(d-x))-e)<min)min=abs(sqrt(x*x+(d-x)*(d-x))-e);
    }
    cout << setprecision(10) << min << endl;
  }
}

Measured memory_bytes: 3200
import math

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

cap = a * a * b

h = (x / cap) * b
if h / b >= 0.5:
    gap = b - h
    print(math.degrees(math.atan((gap / (a / 2)))))
else:
    vol = h * a
    gap = (vol / b) * 2
    print(math.degrees(math.atan(b / gap)))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int l = sc.nextInt();
		int r = sc.nextInt();
		int d = sc.nextInt();
		int a = 0;
		if (l % d == 0)
			a = 1;

		System.out.println(r / d - l / d + a);
	}

}


Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define S second
#define F first
#define ii pair <int,int>
#define IOS std::ios_base::sync_with_stdio(false)
#define pb push_back

const ll inf = 1e18;
int q = 1 ;
const int N = 1e5+10 ;
ll n , a[N], mem[N];
ll dp(int i)
{
    if(i == n-1)
        return 0ll;
    ll &ret =mem[i];
    if(ret != -1)
        return ret;
    ll p1 = dp(i+1) + abs(a[i+1] - a[i]);
    ll p2 = inf;
    if(i < n-2)
        p2 = dp(i+2) + abs(a[i+2] - a[i]);
    return ret = min(p1,p2);
}
void solve()
{
    cin>>n;
    for(int i = 0 ; i < n;i++ )
        cin>>a[i];
    memset(mem,-1,sizeof mem);
    cout<<dp(0);
}


int main()
{
    IOS;
//    cin>>;
    while(q--)
    {
         solve();
    }

}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N + 2);
  int sum = 0;
  int tempsum = 0;
  for (int i = 0; i <= N; i++)
  {
    if (i == 0)
    {
      A[0] = 5000;
      A[N + 1] = 5000;
      continue;
    }
    cin >> A[i];
    A[i] += 5000;
    sum += abs(A[i - 1] - A[i]);
  }
  sum += abs(A[N + 1] - A[N]);
  tempsum = sum;

  for (int i = 1; i <= N; i++)
  {
    sum = tempsum;
    if (A[i - 1] < A[i] && A[i - 1] < A[i + 1] && A[i] > A[i + 1])
    {
      sum -= abs(A[i + 1] - A[i]) * 2;
    }
    else if (A[i - 1] < A[i] && A[i - 1] >= A[i + 1])
    {
      sum -= abs(A[i - 1] - A[i]) * 2;
    }
    else if (A[i - 1] > A[i] && A[i - 1] > A[i + 1] && A[i + 1] > A[i])
    {
      sum -= abs(A[i + 1] - A[i]) * 2;
    }
    else if (A[i - 1] > A[i] && A[i - 1] <= A[i + 1])
    {
      sum -= abs(A[i - 1] - A[i]) * 2;
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h> 
using namespace std;
 
int main(void){
	int n;
	while (cin >> n) {
		vector<int> a(n, 0), b(n + 1, 0);
		int d = 0, r = 0;
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
			b[a[i]]++;
			d = max(d, a[i]);
		}
		bool flag = true;
		if(d % 2 == 0){
			r = d / 2;
			if(b[r] < 1){
				flag = false;
			}
			if(flag){
				b[r]--;
				for(int i = r + 1; i <= d; i++){
					if(b[i] < 2){
						flag = false;
						break;
					}
					b[i] -= 2;
				}
			}
		}else{
			r = d / 2 + 1;
			for(int i = r; i <= d; i++){
				if(b[i] < 2){
					flag = false;
					break;
				}
				b[i] -= 2;
			}
		}
		if(flag){
			for(int i = r; i >= 1; i--){
				if(b[i] > 0){
					flag = false;
				}
			}
		}
		if(flag) cout << "Possible" << endl;
		else cout << "Impossible" << endl; 	
	}
	return 0;
}

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

#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >

const int M = 107;
const int N = 1e5 + 7;
const int mod = 1e9 + 7;

double n;

main(){
    cin >> n;
    int a = n;
    cout << fixed << setprecision(10) << double(((a % 2) + a / 2) / n);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int D = cin.nextint;
        int N = cin.nextint;
        if (N == 100) N += 1;
        Write(N);
        for (int i = 0; i < D; i++)
        {
            Write("00");
        }
        WriteLine();
        //WriteLine((long)N * (long)Math.Pow(100, D));
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13268