akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    ll x,y,z,k;
    cin>>x>>y>>z>>k;
    V<ll> a(x),b(y),c(z);
    cinf(x,a);
    cinf(y,b);
    cinf(z,c);
    sort(all(b));
    sort(all(c));
    V<ll> d;
    for(ll i=0;i<x;i++){
        for(ll j=0;j<y;j++) d.push_back(a[i]+b[j]);
    }
    sort(all(d));
    priority_queue<ll> que;
    ll n=d.size();
    ll left=0,right=3*1e10+1;
    while(right-left>1){
        ll mid=(left+right)/2;
        ll cnt=0;
        for(ll j=0;j<z;j++){
            ll u=lb(all(d),mid-c[j])-d.begin();
            cnt+=n-u;
        }
        if(cnt>=k) left=mid;
        else right=mid;
    }
    for(ll i=n-1;i>=0;i--){
        for(ll j=z-1;j>=0;j--){
            if(d[i]+c[j]>left) que.push(d[i]+c[j]);
            else break;
        }
    }
    ll m=k-que.size();
    while(!que.empty()){
        cout<<que.top()<<endl;
        que.pop();
    }
    rep(i,m) cout<<left<<endl;
}

Measured memory_bytes: 10480
n,m,k=map(int,input().split())

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


a_pre,b_pre=[0],[0]

for i in range(n):
	a_pre.append(a_pre[i]+a[i])

for i in range(m):
	b_pre.append(b_pre[i]+b[i])

ans,j=0,m
for i in range(n+1):
	if a_pre[i]>k:
		break
	while b_pre[j]>k-a_pre[i]:
		j-=1

	ans=max(ans,i+j)

print(ans)


Measured memory_bytes: 47660
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	set<char> st;
	rep(i,n){
		char c;
		cin >> c;
		st.insert(c);
	}
	if(st.size() == 3) cout << "Three" << endl;
	else cout << "Four" << endl;
	return 0;
}

Measured memory_bytes: 3520
k, x = map(int, input().split())
ans = []

min = x - ( k - 1 )
max = x + ( k - 1 )

if min < -1000000:
  for i in range(-1000000, max+1):
    ans.append(i)
elif max > 1000000:
  for i in ragne(min, 1000001):
    ans.append(i)
else:
  for i in range(min, max+1):
    ans.append(i)

print(*ans)
  


Measured memory_bytes: 3060
import heapq
n,k = map(int,input().split())
L = []
for i in range(n):
    t,d = map(int,input().split())
    L.append([d,t])
L.sort()
ans = []
cur = [0]*n
heap = []
var = 0
for i in range(k):
    if cur[L[n-i-1][1]-1] == 0:
        ans.append(L[n-i-1][0])
        cur[L[n-i-1][1]-1] = 1
        var += 1
    else:
        heapq.heappush(heap, L[n-i-1])
temp = 0
for i in range(len(ans)):
    temp += ans[i]
for i in range(len(heap)):
    temp += heap[i][0]
temp += var**2
now = temp
for i in range(n-k):
    if len(heap) != 0:
        a = heapq.heappop(heap)
        if cur[L[n-k-i-1][1]-1] == 0:
            ans.append(L[n-k-i-1][0])
            cur[L[n-k-i-1][1]-1] = 1
            now -= var**2
            now -= a[0]
            var += 1
            now += var**2
            now += L[n-k-i-1][0]
            temp = max(temp, now)
        else:
            heapq.heappush(heap, a)
print(temp)


Measured memory_bytes: 21784
#include<algorithm>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;
char str[20],str2[20],str3[20];
int a,b;
int main()
{
    scanf("%s",str);
    scanf("%s",str2);
    scanf("%d%d",&a,&b);
    scanf("%s",str3);
    if(strcmp(str3,str)==0)
    {
        a--;
    }
    else
    {
        b--;
    }
    printf("%d %d",a,b);
}


Measured memory_bytes: 128
/*
 * 
 * 
 */

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
	string n;cin>>n;
	bool flag=false;
	for(int i=0;i<n.length();i++)
	{
		if(n.at(i)=='7')
		{
			cout<<"Yes";
			flag=true;
			break;
		}
		
	}
	if(!flag)
		cout<<"No";
	
	
	return 0;
}



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

bool mycheck(){
    int w,h,x,y,r;
    cin >> w >> h >> x >>y >>r;
    return x >= r && y>= r && x<=w-r && y<=h-r;
}

int main(){
    bool ok;
    ok = mycheck();
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main()
{

   /* int a,b,x,d,i,e,temp,k,s=0,p;

    scanf("%d %d",&a,&b);
    int l[a];
    for(e=0;e<a;e++){
        scanf("%d",&l);
    }
    for(i=0;i<a-1;i++){
        for(d=0;d<a-i;d++){
            if(l[d]<l[d+1]){
                temp=l[d];
                l[d]=l[d+1];
                l[d+1]=temp;
                temp=0;
            }
        }
    }

    for(p=0;p<a;p++){
        printf("%d\n",l[p]);
    }*/
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    c=a%500;
    if(c<=b){
        printf("Yes");
    }else{
     printf("No");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
//using Graph = vector<vector<int>>;
//#define pi 3.1415926535

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

  int ans = 0;
  for(int a = 1; a < n; a++){
    for(int b = 1; b < n; b++){
      if(a * b < n){
        ans++;
      }
      else{
        break;
      }
    }
  }
  
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3620
import sys
import math
h,w,k=map(int,input().split())
A =[input() for _ in range(h)]
ans=0

for iss in range(1<<h):
    for js in range(1<<w):
        cnt=0
        for i in range(h):
            for j in range(w):
                if iss>>i & 1: continue
                if js>>j & 1: continue
                if A[i][j]=='#': cnt+=1
        if cnt==k:
            ans+=1

print(ans)

Measured memory_bytes: 9088
import queue

n, m = map(int, input().split())
to = [[] for i in range(100001)]
for i in range(m):
    a, b = map(int, input().split())
    a = a - 1
    b = b - 1
    to[a].append(b)
    to[b].append(a)

INF = 1001001001
q = queue.Queue()
dist = [INF for i in range(n)]
pre = [-1 for i in range(n)]
dist[0] = 0
q.put(0)
while not q.empty():
    v = q.get()
    for u in to[v]:
        if dist[u] != INF:
            continue
        dist[u] = dist[v] + 1
        pre[u] = v
        q.put(u)

print('Yes')
for i in range(n):
    if i == 0:
        continue
    print(pre[i] + 1)


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

int main(void){
int n,k,h[100000],dp[100000];
int i,l;
scanf("%d %d",&n,&k);
for(i=0;i<n;i++){
  scanf("%d",&h[i]);
  dp[i] = 10000000000;
}
dp[0] = 0;
for(i=1;i<n;i++){
  for(l=1;l<=k;l++){
    if(i-l<0){
      break;
    }
    if(dp[i] > dp[i-l]+abs(h[i]-h[i-l])){
      dp[i] = dp[i-l]+abs(h[i]-h[i-l]);
    }
  }
}

printf("%d\n",dp[n-1]);
return 0;                          
}

Measured memory_bytes: 896
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MOD			1000000007								// 除数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// パターン数取得
long long
fGetPtn(
	int piCnt					// <I> 数
)
{
	long long llRet = 1;
	while (piCnt > 1) {
		llRet = llRet * (long long)piCnt % D_MOD;
		piCnt--;
	}

	return llRet;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 犬数・猿数取得
	int liDCnt, liMCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d", &liDCnt, &liMCnt);

	// 差
	int liDF = abs(liDCnt - liMCnt);

	// 全パターン数
	long long llSum = 0;
	if (liDF < 2) {
		llSum = fGetPtn(liDCnt) * fGetPtn(liMCnt) % D_MOD;
		if (liDF == 0) {
			llSum = llSum * (long long)2 % D_MOD;
		}
	}

	// 結果セット
	sprintf(lc1Out, "%lld\n", llSum);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main(){
	var a, b int
	for{
		fmt.Scan(&a, &b)
		var s string
		if a == 0 && b == 0{
			break
		}
		for i:=0; i<(b/2 +1); i++{
			s += "#."
		}
		for i:=0; i<a; i++{
			if i % 2 == 0{
				fmt.Print(s[:b])
			}else{
				fmt.Print(s[1:b+1])
			}
			fmt.Print("\n")
		}
		fmt.Print("\n")
	}
}


Measured memory_bytes: 1136
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int ans[100] = {};
int main() {
	int n, m;
	cin >> n >> m;
	REP(i, n) {
		int c;
		cin >> c;
		REP(q, c) {
			int d;
			cin >> d;
			ans[d]++;
		}
	}
	int cnt = 0;
	REP(i, m + 1) {
		if (ans[i] == n) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int card[3][10];

bool solve(){

	int cnt = 0;

	for(int c=0; c<3; ++c){
		for(int k=1; k<=9; ++k){
			
			//counting same-card set
			cnt += card[c][k]/3;
			card[c][k] %= 3;
				
			if(k<=7){
				
				//counting serial-number set
				int sub = min(card[c][k], min(card[c][k+1], card[c][k+2]));

				for(int i=0; i<3; ++i){
					card[c][k+i] -= sub;
				}

				cnt += sub;
			}
		}
	}
	
	return cnt>=3;
}

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

	while(n--){
			
		int a[10];
			
		memset(card, 0, sizeof(card));

		for(int i=0; i<9; ++i){
			cin>>a[i];
		}

		for(int i=0; i<9; ++i){

			char b;
			cin>>b;
			card[b=='R'?0:b=='G'?1:2][a[i]]++;
		}

		cout << solve() << endl;
	}	
	
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, k;
    cin >> n >> k;
    vi h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        if (h[i] >= k)
            ret++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,card[201],num,last=0,taro=0,hana=0,fi=0,fini=0;
    while(1){
    cin>>n;
    if(n==0)break;
    taro=n;hana=n;
    for(int i=1;i<=2*n;i++)card[i]=0;
    for(int i=0;i<n;i++){
        cin>>num;
        card[num]=1;
    }
    num=0;
    while(1){
        for(int i=1;i<=2*n;i++){
            if(last==1&&card[i]==0&&fi<i){
                card[i]=2;
                last=0;
                fi=i;
                hana--;
            }
            else if(last==0&&card[i]==1&&fi<i){
                card[i]=2;
                last=1;
                fi=i;
                taro--;
            }
            if(taro==0||hana==0){
                fini=1;
                break;
            }
         //   cout<<taro<<" "<<hana<<endl;
        }
        fi=0;
        if(fini==1)break;
        if(last==0)last=1;
        else last=0;
    }

    for(int i=1;i<=n*2;i++){
        if(card[i]==1)num++;
        if(card[i]==0)fi++;
    }
    cout<<fi<<endl<<num<<endl;
    fi=0;num=0;fini=0;last=0;
    }
}

Measured memory_bytes: 1160
S=input()
T=input()
ns=len(S)
nt=len(T)
ans=[]
i=0
while i+nt<=ns:
    j=0
    while j<nt:
        if S[i+j]=='?' or S[i+j]==T[j]:
            j+=1
        else:
            break
    if j==nt:
        A=S[:i]+T+S[i+nt:]
        A=A.replace('?','a')
        ans.append(A)
    i+=1
    
if ans:
    print(sorted(ans)[0])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 9020
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};



int main(){
    int n, x;
    cin >> n >> x;
    if(x ==  1 || x == 2 * n - 1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    vector<int> ans(2*n-1);
    REP(i, 2*n-1){
        ans[i] = 0;
    }
    if(n < x){
        ans[n - 2] = 2 * n - 1; 
        ans[n - 1] = x;
        ans[n] = 1;
    }else{
        ans[n - 2] = x;
        ans[n - 1] = 1;
        ans[n] = 2 * n - 1;
    }
    int cnt = 2;
    REP(i, 2*n-1){
        if(ans[i] != 0) continue;
        if(cnt == x) cnt++;
        ans[i] = cnt;
        cnt++;
    }
    REP(i, 2* n - 1){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);

  int n,d;

  cin>>n>>d;

  int cnt=0;

  while(n--){

    lli a, b;

    cin>>a>>b;

    if(sqrt(a*a+b*b)<=d)

    cnt++;

  }

  cout<<cnt<<endl;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
pair<int,int> max1,max2;
int main()
{
	int n,a[200];
	cin>>n;
	for(int i=0;i<n*2;i++)
	{
		cin>>a[i];
	}
	int ans=0;
    for(int i=0;i<n;i++)
    {
	  for(int i=0;i<n*2;i++)
	  {
		  if(a[i]>max1.second)
		  {
		  	max2.second=max1.second;
		  	max2.first=max1.first;
		    max1.second=a[i];
			max1.first=i;
			continue;
		  }
		  if(a[i]>max2.second)
		  {
			max2.first=i;
			max2.second=a[i];
		  }
	  }
	    //cout<<max1.first<<" "<<max1.second<<" "<<max2.first<<" "<<max2.second<<endl;
		ans+=max2.second;
		max1.second=0;
		max2.second=0;
		a[max1.first]=0;
		a[max2.first]=0;
    }
    //for(int i=0;i<n*2;i++)
    //cout<<a[i]<<" ";
    cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include<numeric>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0])
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;
typedef long long ll;



int main(void) {
	int c[3][3];
	int x[3],y[3];

	rep(i, 3) {
		rep(j, 3) {
			cin >> c[i][j];
		}
	}
	x[0] = 0;
	rep(i, 3) {
		y[i] = c[0][i] - x[0];
	}
	rep(i, 3) {
		x[i] = c[i][0] - y[0];
	}

	bool good = true;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (x[i] + y[j] != c[i][j]) {
				good = false;
			}
		}
	}
	if (good == 1) {
		cout << "Yes";
	}
	else
		cout << "No";




	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int a,b,c;cin>>a>>b>>c,a|b|c;){
		int n; cin>>n;
		vi as(n),bs(n),cs(n),rs(n);
		rep(i,n) cin>>as[i]>>bs[i]>>cs[i]>>rs[i];
		
		set<int> ok,ng;
		rep(i,n)
			if(rs[i]==1){
				ok.insert(as[i]);
				ok.insert(bs[i]);
				ok.insert(cs[i]);
			}
		rep(i,n){
			if(rs[i]==1) continue;
			else if(ok.count(as[i])&&ok.count(bs[i]))
				ng.insert(cs[i]);
			else if(ok.count(bs[i])&&ok.count(cs[i]))
				ng.insert(as[i]);
			else if(ok.count(cs[i])&&ok.count(as[i]))
				ng.insert(bs[i]);
		}
		rep(i,a+b+c)
			if(ng.count(i+1))
				cout<<0<<endl;
			else if(ok.count(i+1))
				cout<<1<<endl;
			else
				cout<<2<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, k;
vector<int> v;
int memo[60][60][110];
int dp(int l,int r, int num)
{
    if(l>r||num<0)   return -1000000007;
    if(num==0)  return 0;
    if(l==r)  return memo[l][r][num]=max(v[l],0);
    if(memo[l][r][num]!=-100000000)  return memo[l][r][num];
    int x=-99999999,y=-99999999,z,t;
    if(v[l]<0) x=dp(l+1,r,num-2);
    if(v[r]<0) y=dp(l,r-1,num-2);
    z=dp(l+1,r,num-1)+v[l];
    t=dp(l,r-1,num-1)+v[r];
    return memo[l][r][num]= max(max(max(x,y),max(z,t)),0);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp","r",stdin);
    cin>>n>>k;
    v.resize(n);
    for(int i=0;i<60;++i)
        for(int j=0;j<60;++j)
            for(int k=0;k<110;++k)  memo[i][j][k]=-100000000;
    for(int i=0;i<n;++i) cin>>v[i];
    printf("%d",dp(0,n-1,k));
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = [int(input()) for _ in range(N)]
k = 2
ans = A[0] - 1
for i in range(1, N):
    if A[i] == k:
        k += 1
    elif A[i] > k:
        ans += (A[i] - 1) // k
print(ans)


Measured memory_bytes: 7084
s = input()
cnt = 0
if s[0] == 'A' and s[1].islower() and s[-1].islower():
    for i in range(len(s)-3):
        if s[i+2] == 'C':
            cnt += 1
        elif s[i+2].islower():
            continue
        else:
            cnt = None
            break
if cnt == 1:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
  }
    sort(p.begin(),p.end());
    int ans=0;
    for(int i=0;i<k;i++){
      ans+=p.at(i);
    }
      cout<<ans<<endl;
      return 0;
}
  


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383
#define pb push_back
#define all(s) s.begin(),s.end()


int main (){
    fast;
    
    ll n, m = 1000000007;
    cin>>n;
    ll ten = 1,nine = 1,eight = 1;
    
    for(int i=0;i<n;i++){
        ten = (ten*(ll)10)%m;
        nine = (nine*(ll)9)%m;
        eight = (eight*(ll)8)%m;
    }
    
    ll ans = 0;
    ans = (((ans + (ten%m + eight%m)%m)%m - (nine%m + nine%m)%m)%m + m)%m;
    cout<<ans%m<<endl;


}

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

using namespace std;
int main(){
    int sx,sy,tx,ty;
    int tate,yoko;
    cin >> sx >> sy >> tx >> ty;
    tate = ty - sy;
    yoko = tx - sx; 
    //vector<string> way1(tate),way2(yoko),way3(tate),way4(yoko),way5(tate+2),way6(yoko+2),way7(tate+2),way8(yoko+2);
    for (int i=0;i<tate;i++){
        cout << "U";
        //way1.push_back("U");
        //way3.push_back("D");
    }
    for (int i=0;i<yoko;i++){
        cout << "R";
        //way2.push_back("R");
        //way4.push_back("L");
    }
    for (int i=0;i<tate;i++){
        cout << "D";
        //way1.push_back("U");
        //way3.push_back("D");
    }
    for (int i=0;i<yoko;i++){
        cout << "L";
        //way2.push_back("R");
        //way4.push_back("L");
    }
    cout << "L";
    //way5.at(0) = "L";
    //way7.at(0) = "R";
    for (int i=0;i<tate+1;i++){
        cout << "U";
        //way5.at(i+1) = "U";
        //way7.at(i+1) = "D";
    }
    for (int i=0;i<yoko+1;i++){
        cout << "R";
        //way6.at(i) = "R";
        //way8.at(i) = "L";
    }
    cout << "D";
    cout << "R";
    for (int i=0;i<tate+1;i++){
        cout << "D";
        //way5.at(i+1) = "U";
        //way7.at(i+1) = "D";
    }
    for (int i=0;i<yoko+1;i++){
        cout << "L";
        //way6.at(i) = "R";
        //way8.at(i) = "L";
    }
    cout << "U" << std::endl; //firstがキー，secondが値
    
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0

for x,y in zip(a,a[1:]):
  if y == x+1:
    ans += c[x-1]
    
print(sum(b)+ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    vector<int>P(N+1);
    P[0]=200000;
    int minimum=N;
    int count=0;
    for(int i=1;i<N+1;i++){
        cin>>P[i];
    }
    for(int i=1;i<N+1;i++){
        if(P[i]<=minimum){
            count++;
            minimum=min(minimum,P[i]);
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d) cout << "Left" << endl;
  else if(a+b == c+d) cout << "Balanced" << endl;
  else cout << "Right" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = in.next();
        String ans = (s.charAt(0) == '9' || s.charAt(1) == '9') ? "Yes": "No";
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int T, C, N, M, X, A[101];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d%d", &N, &M, &X);
	for(int i = 1; i <= M; i++){
		int a;
		scanf("%d", &a);
		A[a] = 1;
	}
	for(int i = X; i <= N; i++) T += A[i];
	for(int i = X; i >= 0; i--) C += A[i];
	if(C < T) T = C;
	printf("%d\n", T);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	ll N, M, ans=0;
	cin >> N >> M;
	if (N < M) swap(N, M);
	
	if (N == 1 && M == 1) {
		print(1);
	}
	else if (N == 2) {
		print(0);
	}
	else if (M == 1) {
		print(N -2);
	}
	else if (M == 2) {
		print(0);
	}
	else {
		print((N - 2ll) * (M - 2ll));
	}
	
}

Measured memory_bytes: 3600
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

k,x = inm()
mn = max(-1000000,x-k+1)
mx = min(1000000,x+k-1)
for i in range(mn,mx+1):
    printn(('' if i==mn else ' ') + str(i))
print("")


Measured memory_bytes: 3444
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(auto(it,(c).begin());it != (c).end();)
#define cx real()
#define cy imag()
#define px first
#define py second
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------


signed main()
{
	QUICK_CIN;
	//debug_input;

	int n;
	string s;
	string t[4];

	cin >> n >> s;
	s += s[0];

	t[0] = "SS";
	t[1] = "SW";
	t[2] = "WS";
	t[3] = "WW";

	map<char, string> rev;
	rev['W'] = "S";
	rev['S'] = "W";

	REPS(1,i,n+1) {
		REP(j, 4) {
			if (t[j][i] == 'S') {
				if (s[i] == 'o') {
					t[j] += t[j][i - 1];
				}
				else {
					t[j] += rev[t[j][i - 1]];
				}
			}
			else {
				if (s[i] == 'o') {
					t[j] += rev[t[j][i - 1]];
				}
				else {
					t[j] += t[j][i - 1];
				}
			}
		}
	}

	REP(i, 4) {
		if (t[i][0] == t[i][n] && t[i][1] == t[i][n+1]) {
			cout << t[i].substr(0, n) << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define INF 1234567890123456789
#define mod 1000000007
typedef long long ll;
using namespace std;
bool ok[100010];
int main(){
	string s;
	cin>>s;
	lol(i,s.size()+1)ok[i]=false;
	ok[0]=true;
	for(int i=0;i<s.size();i++){
		if(ok[i]==false)continue;
		string key[4]={"dream","dreamer","erase","eraser"};
		lol(j,4){
			bool tmp=true;
			if(key[j].size()+i>s.size())continue;
			lol(k,key[j].size()){
				if(s[i+k]!=key[j][k]){
					tmp=false;
				}
			}
			if(tmp==true){
				ok[i+key[j].size()]=true;
			}
		}
	}
	if(ok[s.size()]==true)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	//lol(i,s.size()+1)cout<<ok[i];cout<<endl;
	return 0;
}


Measured memory_bytes: 512
n,m = map(int,input().split())
a = set([int(input())for i in range(m)])
dp = [0]*(n+1)
dp[0] = 1
if 1 in a :
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2,n+1):
    if i in a:
        continue
    dp[i] = (dp[i-1]+dp[i-2])%1000000007
print(dp[n])

Measured memory_bytes: 13216
#include <stdio.h>

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

void DFS(void);
void DFS_Visit(int);

int u,k;
int color[N];
int time;
int d[N],f[N];
int n;
int G[N][N];

int main(){
  
  int i,j;
  int Adj[N];  

  scanf("%d",&n);

  if(n < 0 || N < n) return 0;
  
  for(i=0;i < n;i++) {
    for(j=0;j < n;j++){
      G[i][j] = 0;
    }
  }

  for(i=0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j < k;j++){
      scanf("%d",&Adj[j]);
      G[u-1][Adj[j]-1] = 1;
    }
  }
  
  DFS();

  for(i=0;i < n;i++) printf("%d %d %d\n",i+1,d[i],f[i]);
  
  return 0;
}

void DFS(void){
  int i;
  
  for(i=0;i < n;i++){
    color[i] = WHITE;
    time = 0;
  }
  
  for(i=0;i < n;i++){
    if(color[i] == WHITE) DFS_Visit(i);
  }
}

void DFS_Visit(int u){
  int i;
  
  color[u] = GRAY;
  time++;

  d[u] = time;
  
  for(i=0;i < n;i++){
    if(color[i] == WHITE && G[u][i] == GRAY) {
      DFS_Visit(i);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m,mx=0;
	cin>>n>>m;
	vector<int>a(n);
	for(auto&i:a){
		cin>>i;
		mx+=i;
	}
	int cnt=0;
	for(auto&i:a){
		if(i*4*m>=mx)++cnt;
	}
	cout<<(cnt>=m?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(all(a));

    vector<pair<int, int>> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i].second >> b[i].first;
    }
    sort(rall(b));

    int id = 0;
    for (int i = 0; i < m; i++) {
        while (id < n && a[id] < b[i].first && b[i].second) {
            b[i].second--;
            sum += (b[i].first - a[id]);
            id++;
        }
    }
    cout << sum;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    while (t--) solve();
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
LL mod=1000000007;
LL LINF=1LL<<52;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    LL L;
    int n,m;cin >> n >> m >> L;
    LL G[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            G[i][j] = LINF;
        }
        G[i][i] = 0;
    }
    for (int i = 0; i < m; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        LL c;cin >> c;
        G[x][y] = c;
        G[y][x] = c;
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if(G[i][j] <= L) G[i][j] = 0;
            else G[i][j] = LINF;
        }
        G[i][i] = 0;
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                G[i][j] = min(G[i][j],G[i][k] + G[k][j] + 1);
            }
        }
    }
    int q;cin >> q;
    for (int i = 0; i < q; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        if(G[x][y]==LINF) cout << -1 << endl;
        else cout << G[x][y] << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}


ll solve(ll a,ll b, ll tar){
  if(a<=0 && b<=0 && tar<=0)return 0;

  ll res=LINF;
  if(tar%2 != (a%2 ^ b%2)){
    res=LINF;
  }else{
    chmin(res,solve(a/2,b/2,tar/2)*2);
    chmin(res,solve((a-1)/2,(b+1)/2,tar/2)*2 +1);
  }

  return res;
}

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  ll a,b,tar=0;
  cin>>a>>b;
  rep(i,2,n){
    ll x;cin>>x;
    tar^=x;
  }

  ll tmp=solve(a,b,tar);
  if(tmp<LINF && tmp!=a)cout<<tmp<<ENDL;
  else cout<<-1<<ENDL;
  
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3636
MOD = 10**9 + 7
list_size = 100001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
	ans += a[i] * (comb(i, k-1) - comb(n-i-1, k-1))
	ans %= MOD
print(ans)

Measured memory_bytes: 22100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		long[] s1 = new long[n];

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

		long sum1 = 0;
		s1[0] = a[0];
		// - + - + となる場合
		if (s1[0] >= 0) {
			sum1 = sum1 + 1 + s1[0];
			s1[0] = -1;
		}
		for (int i = 1; i < n; i++) {
			s1[i] = s1[i-1] + a[i];
			// iが奇数の場合は正にする
			if (i % 2 != 0) {
				if (s1[i-1]*s1[i] >= 0) {
					sum1 = sum1 + 1 - s1[i];
					s1[i] = 1;
				}
			}
			// iが偶数の場合は負にする
			else {
				if (s1[i-1]*s1[i] >= 0) {
					sum1 = sum1 + 1 + s1[i];
					s1[i] = -1;
				}
			}
		}

		Arrays.fill(s1, 0);
		long sum2 = 0;
		s1[0] = a[0];
		// + - + - となる場合
		if (s1[0] <= 0) {
			sum2 = sum2 + 1 - s1[0];
			s1[0] = 1;
		}
		for (int i = 1; i < n; i++) {
			s1[i] = s1[i-1] + a[i];
			// iが奇数の場合は負にする
			if (i % 2 != 0) {
				if (s1[i-1]*s1[i] >= 0) {
					sum2 = sum2 + 1 + s1[i];
					s1[i] = -1;
				}
			}
			// iが偶数の場合は正にする
			else {
				if (s1[i-1]*s1[i] >= 0) {
					sum2 = sum2 + 1 - s1[i];
					s1[i] = 1;
				}
			}
		}

		System.out.println(Math.min(sum1, sum2));
	}

}

Measured memory_bytes: 57016
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,t;
  cin>>n>>x>>t;
  
  if(n<=x)cout<<t<<endl;
  else
  {
    if(n%x==0)cout<<(n/x)*t<<endl;
    else
     cout<<((n/x)+1)*t<<endl;
  }
}

Measured memory_bytes: 3584
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	min := 753
	for i := 0; i < len(s)-2; i++ {
		num,_ := strconv.Atoi(s[i:i+3])
    	if min > abs(753,num) {
			min = abs(753,num)
		}
	}
	fmt.Println(min)
}


func abs(a,b int)int {
	if a > b {
		return a - b
	} else {
		return b - a
	}
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
    char a,b;
    scanf(" %c %c",&a, &b);

    if(a=='1'&&b=='2'){
        printf("3\n");
    }else if(a=='2'&&b=='1'){
        printf("3\n");
    }else if(a=='2'&&b=='3'){
        printf("1\n");
    }else if(a=='3'&&b=='2'){
        printf("1\n");
    }else if(a=='3'&&b=='1'){
        printf("2\n");
    }else if(a=='1'&&b=='3'){
        printf("2\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, R;
  cin >> N >> R;
  int ans = 0;
  if (N >= 10) {
    ans = R;
  }
  else {
    ans = R + 100 * (10 - N);
  }
  cout << ans << endl;
}
    
  

Measured memory_bytes: 3632
H,W,K = map(int,input().split())

C = [list(map(lambda x:x=="#",input())) for _ in [0]*H]

ans = 0

for i in range(1<<H):
    for j in range(1<<W):
        cnt = 0
        for k in range(H):
            if i>>k &1 == 0: continue
            for l in range(W):
                if j>>l &1 ==0: continue
                cnt += int(C[k][l])
        if cnt == K: ans += 1

print(ans)

Measured memory_bytes: 9136
#include <iostream>
using namespace std;
int main(){
  int x, y, z;
  cin >> x >> y >> z;
  int t;
  t = x;
  x = y;
  y = t;
  t = x;
  x = z;
  z = t;
  cout << x << " " << y << " " << z;
  return 0;
}


Measured memory_bytes: 256
def abc(n):
    if n % 10 == 0:
        return n
    else:
        return n + 10 - (n%10)

ans = 0
mods = []

for _ in range(5):
    tmp = int(input())
    ans += abc(tmp)
    mods.append(tmp%10)

if not set(mods) == {0}:
    while 0 in mods:
        mods.remove(0)
    ans -= 10
    ans += min(mods)

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

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



Measured memory_bytes: 2064
k,a,b=map(int,input().split())

if k+1<=a:
    print(k+1)
    exit()

s=k+1-a
if a>=b-1:
    print(k+1)
else:
    n=s//2
    m=s%2
    print(a+n*(b-a)+m)
    

Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int ans=0;
  if(A < C){
    ans = min(B,D) - C;
  }else
    ans = min(B,D) - A;

  if(ans >= 0)
    cout << ans << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
//by The_One_Solver
#include<bits/stdc++.h>
using namespace std;
int n,m,c,arr[10001];
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  for(int i=0;i<n;i++)
  {
      for(int j=i+1;j<n;j++)
      {
          c+=arr[i]*arr[j];
      }
  }
  cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

string s; 
int main() {
  cin >> s;
  char c = s.at(0);
  int ans = 0;
  for(int i=1; i<s.size(); i++) {
    if (c != s.at(i)) {
      ans++;
    }
    c = s.at(i);
  }
  cout << ans << endl;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> cnt(n);
  rep(i, k){
    int d;
    cin >> d;

    rep(j, d){
      int a;
      cin >> a;
      cnt[a-1]++;
    }
  }
  int ans=0;
  rep(i, n){
    if(cnt[i]==0){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
S = input()
K = input()

cnt_1 = 0
cnt_aft_1 = None

for s in S:
  if s == '1':
    cnt_1 += 1
  else:
    cnt_aft_1 = s
    break

if len(S) == 1:
  print(S)
elif int(K) <= cnt_1:
  print('1')
else:
  print(cnt_aft_1)

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

using namespace std;

using ll = long long;

int main(void) {
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    for(auto &e: a) cin >> e;

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

    ll ng = 2e18, ok = -2e18;
    // ok譛ｪ貅縺ｮ遨阪′k蛟区悴貅
    while(ng - ok > 1) {
        ll m = (ok + ng)/2;
        
        ll s = 0;
        for(ll i=0; i<n; i++) {
            if(a[i] < 0) {
                // a[x] * a[i] < m
                ll j = partition_point(a.begin(), a.end(),
                        [&](auto &x) { return x * a[i] >= m; }) - a.begin();
                // >= >= [<] < <
                if(i >= j) j++;
                s += max(n-j, 0ll);
            }
            if(a[i] > 0) {
                // a[x] * a[i] < m
                ll j = partition_point(a.begin(), a.end(),
                        [&](auto &x) { return x * a[i] < m; }) - a.begin();
                // < < [>=] >= >=
                if(i < j) j--;
                s += max(j, 0ll);
            }
            if(a[i] == 0) {
                // a[x] * 0 < m
                s += m > 0 ? n-1 : 0;
            }
        }
        assert(s % 2 == 0);
        s /= 2;

        (s < k ? ok : ng) = m;
    }
    cout << ok << endl;
}



Measured memory_bytes: 1792
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

void solve(int x){
    int ans = 1;
    int num;
    bool isFst;
    for (int i=2; i<x; ++i){
        num = i;
        isFst = true;
        while(num <= x){
            if(isFst){
                isFst = false;
            }
            else {
                ans = max(ans, num);
            }
            num *= i;
        }
    }
    cout << ans << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int x;
    cin >> x;
    solve(x);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    Int a,b;
    cin>>a>>b;
    if((a+b) % 2 == 1) {
        cout<<"IMPOSSIBLE"<<endl;
    } else {
        cout<<(a+b)/2<<endl;
    }


    return 0;
}





Measured memory_bytes: 256