akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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

	int N, K;
	cin >> N >> K;
	int saidai[100000] = {};
	int shurui = 0;
	int sonota[100001];
	int k = 0;
	rep(i, N) {
		int t, d;
		cin >> t >> d;
		t--;
		if (!saidai[t]) {
			shurui++;
			saidai[t] = d;
		}
		else {
			if (saidai[t] < d) {
				swap(saidai[t], d);
			}
			sonota[k++] = d;
		}
	}

	pakuri_sort(100000, saidai);
	pakuri_sort(k, sonota);

	vector<ll> ruiseki;
	ll kari = 0;
	for (int i = k - 1; i >= 0; i--) {
		kari += sonota[i];
		ruiseki.pb(kari);
	}

	ll kotae = 0;
	kari = 0;
	for (int i = 1; i <= min(K, shurui); i++) {
		kari += saidai[100000 - i];
		ll kari2 = kari;
		if (K - i - 1 >= 0 && K - i - 1 < k) kari2 += ruiseki[K - i - 1];
		kari2 += 1ll * i * i;
		kotae = max(kotae, kari2);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2552
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  ll k;cin>>k;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll dp[110][114514];
  dp[0][0]=1;
  rep(i,n){
    vl sum(k+1);
    sum[0]=dp[i][0];
    for(ll j=1;j<=k;j++)sum[j]=dp[i][j]+sum[j-1];
    rep(j,k+1){
      if(j>=a[i]+1)dp[i+1][j]=(sum[j]-sum[j-a[i]-1])%MOD;
      else dp[i+1][j]=sum[j]%MOD;
    }
  }
  cout<<dp[n][k]<<endl;
}
  

Measured memory_bytes: 91892
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;cin>>n;
  long long arr[n+1]={0};for(int i=1;i<=n;i++)cin>>arr[i];
  
  long long dp[n+1]={0};
  dp[2]=abs(arr[1]-arr[2]);
  for(int i=3;i<=n;i++)
  {
    dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
  }
  cout<<dp[n];
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int n, co = 0, ans = 0;
	string s, num;
	cin >> n >> s;
	for (int i = 0; i < 1000; i++) {
		num = to_string(i);
		if (i < 10) {
			num = "00" + num;
		}
		else if (i < 100) {
			num = "0" + num;
		}
		for (int j = 0; j < n; j++) {
			if (num[co] == s[j]) {
				co++;
			}
			if (co == 3) {
				ans++;
				break;
			}
		}
		co = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll x; cin >> x;
	if (x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

ll modinv(ll a, ll m)
{
  ll b = m, x = 1, y = 0;
  while (b > 0)
  {
    ll q = a / b, r = a - q * b, s = x - q * y;
    a = b, b = r;
    x = y, y = s;
  }
  return mod(x, m);
}

int main()
{
  ll N;
  cin >> N;
  ll M = N - 1;
  vector<ll> X(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> X.at(i);
  }

  vector<ll> P(N);
  P.at(0) = 0;
  for (ll i = 1; i < N; i++)
  {
    P.at(i) = (P.at(i - 1) + modinv(i, MOD)) % MOD;
  }

  ll ans = 0;
  for (ll i = 1; i < N; i++)
  {
    ll tmp = (X.at(i) - X.at(i - 1)) * P.at(i) % MOD;

    ans += tmp, ans %= MOD;
  }

  for (ll i = 1; i <= N - 1; i++)
  {
    ans *= i, ans %= MOD;
  }

  cout << ans << endl;
}

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

double dp[2001][2000];
int main() {
  int n,m;
  while(cin >> n >> m && n) {
    string s;
    cin >> s;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
        for(int k=1;k<=6;k++)dp[i+1][(j+k)%n]+=dp[i][j]/6;
    double ans=0;
    for(int j=0;j<n;j++) {
      rotate(s.begin(),s.begin()+1,s.end());
      double sum=0;
      for(int i=0;i<n;i++) {
        if(s[i]=='R') sum+=dp[m][i];
      }
      ans=max(ans,sum);
    }
    printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 34356
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
	int n, k;
	cin >> n >> k;
	int start = 1;
	rep(i, n){
		start = min(2 * start, start + k);
	}
	cout << start << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String subs;
		int ans = 0;
		for(int i = 0; i<S.length();i++) {
			for(int j=i;j<=S.length();j++) {
				subs=S.substring(i, j);
				for(int k=0;k<subs.length();k++) {
					if(subs.charAt(k)!='A'&&subs.charAt(k)!='C'&&subs.charAt(k)!='G'&&subs.charAt(k)!='T') {
						break;
					}
					if(k==subs.length()-1) {
						ans=Math.max(ans, subs.length());
					}
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22612
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def binary_search(series, key, i_left, i_right):
    if i_right == i_left:
        return int(series[i_right] == key)
    i_center = int((i_left + i_right)/2)
    if series[i_center] == key:
        return 1
    elif series[i_center] > key:
        return binary_search(series, key, i_left, i_center)
    else:
        return binary_search(series, key, i_center + 1, i_right)

cnt = 0
for t in T:
    cnt += binary_search(S, t, 0, n-1)
print(cnt)


Measured memory_bytes: 16712
#include <iostream>
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
using namespace std;
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> P;
struct bg{ll a,b,num;};			//num=aのソートでの順番
bool sorta(const bg& l, const bg& r){
	return l.a==r.a ? l.b<r.b : l.a<r.a;
}
bool sortbinv(const bg& l, const bg& r){
	return l.b==r.b ? l.a<r.a : l.b>r.b;
}
ll  segsum[1<<20];
int segcnt[1<<20];
vector<bg> bug;
void update(int id){
	int l=id*2+1,r=id*2+2;
	segsum[id]=segsum[l]+segsum[r];
	segcnt[id]=segcnt[l]+segcnt[r];
	if(id==0) return;
	update((id-1)/2);
}
ll sum(int x,int y,int l,int r,int id){
	if(y<=l || r<=x) return 0;
	if(x<=l && r<=y) return segsum[id];
	return sum(x,y,l,(l+r)/2,id*2+1)+sum(x,y,(l+r)/2,r,id*2+2);
}
int cnt(int x,int y,int l,int r,int id){
	if(y<=l || r<=x) return 0;
	if(x<=l && r<=y) return segcnt[id];
	return cnt(x,y,l,(l+r)/2,id*2+1)+cnt(x,y,(l+r)/2,r,id*2+2);
}
int main(){
	int n,p2=1,ans=-1;
	scanf("%d",&n);
	while(p2<n) p2*=2;
	REP0(i,n){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		bg hoge={a,b,0};
		bug.push_back(hoge);
	}
	sort(ALL(bug),sorta);
	REP0(i,n) bug[i].num=i;
	sort(ALL(bug),sortbinv);
	REP0(i,n){
		int p=p2-1+bug[i].num;
		segsum[p]=bug[i].a;
		segcnt[p]=1;
		update((p-1)/2);
		int ub=n+1,lb=0;
		while(ub-lb>1){
			int mid=(ub+lb)/2;
			if(sum(0,mid,0,p2,0)<=bug[i].b*cnt(0,mid,0,p2,0)) lb=mid;
			else ub=mid;
		}
		ans=max(ans,cnt(0,lb,0,p2,0));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 21660
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

bool compare(string a, string b) {
  if (a.size() > b.size()) return true;
  else if (a.size() < b.size()) return false;
  rep(i, a.size()) {
    if (a[i] > b[i]) return true;
    else if (a[i] < b[i]) return false;
  }
  return true;
}

string dp[10010];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, m;
  cin >> n >> m;
  rep(i, 10010) dp[i] = "0";
  vi32 a(m);
  rep(i, m) cin >> a[i];
  sort(all(a));
  map<int, char> mp;
  rep(i, m) {
    switch (a[i]) {
      case 1: mp[1] = 2; break;
      case 2: mp[2] = 5; break;
      case 3: mp[3] = 5; break;
      case 4: mp[4] = 4; break;
      case 5: mp[5] = 5; break;
      case 6: mp[6] = 6; break;
      case 7: mp[7] = 3; break;
      case 8: mp[8] = 7; break;
      case 9: mp[9] = 6; break;
    }
  }
  dp[0] = "";
  reps(i, n) {
    string str = dp[i];
    rep(j, m) {
      char c = a[j] + '0';
      if (i - mp[a[j]] >= 0 && dp[i - mp[a[j]]] != "0" && compare(dp[i - mp[a[j]]] + c, str)) {
        str = dp[i - mp[a[j]]] + c;
      }
    }
    dp[i] = str;
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 41728
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    char b;
    cin>>b;
    const string enki="ACGT";
    cout<<enki[3-enki.find(b)]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[4];
	int b[2];
	int i=0;
	for(i=0;i<4;i++){
		cin>>a[i];
	}
	b[0]=a[0]+a[1]+a[2]+a[3];
	b[1]=b[0]%60;
	b[0]=(b[0]-b[1])/60;
	cout<<b[0]<<endl<<b[1]<<endl;
}

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

void chmin(int& a, int b) {
  if (a > b) a = b;
}

int main() {
  int N, T;
  cin >> N >> T;
  
  int ans = 1010;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    
    if (t <= T) {
      chmin(ans, c);
    }
  }
  
  if (ans == 1010) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){ int n,a[10001],ans = 0; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) ans+=a[i]*a[j]; cout<<ans; }


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

int main(){
  string S;
  cin>>S;
  int N=S.size();
  map<int, int> henkan;
  for(int i=0; i<N; i++){
    henkan[(int)S.at(i)]=1; //小文字からintに変換して入れる
  }
  bool none=true;
  for(int i=97; i<=122; i++){
    if(henkan.count(i)){
      continue;
    }
    else{
      cout<<(char)i<<endl;
      none=false;
      break;
    }
  }  //i
  if(none) cout<<"None"<<endl;
} //a97 z122


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

int main(){
  string st[100010];
  int N;
  int a, w, t, r;
  a = 0, w = 0, t = 0, r = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> st[i];
  }
  for(int i = 0; i < N; i ++){
    if(st[i] == "AC") a++;
    else if(st[i] == "WA") w++;
    else if(st[i] == "TLE") t++;
    else if(st[i] == "RE") r++;
  }
 
  printf("AC x %d", a); cout << endl;
    printf("WA x %d", w); cout << endl;
    printf("TLE x %d", t); cout << endl;
    printf("RE x %d", r); cout << endl;
  
}

Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string n;
    cin>>n;
    rep(0,i,n.length()){
        if(n.substr(i,1)=="7"){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 3624
D,G=map(int,input().split())
p=[0]*D
c=[0]*D
ans=1000000000
for i in range(D):
    p[i],c[i]=map(int,input().split())
for i in range(1<<D):
    s=0
    cnt=0
    P=[0]*D
    for j in range(D):
        if ((i>>j)&1)==1:
            s+=c[j]+(j+1)*p[j]*100
            cnt+=p[j]
            P[j]=1
    m=-1
    for k in range(D):
        if m<0:
            if P[D-k-1]==0:
                m=D-k
        else:
            break
    if m>=0:
        for l in range(p[m-1]-1):
            if s<G:
                s+=m*100
                cnt+=1
    if s>=G and cnt<ans:
        ans=cnt
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)



int main(){
    int n;
    cin>>n;
    int d[n][2];
    bool a=false;
    rep(i,n) rep(j,2) cin>>d[i][j];

    for(int i=0;i+2<n;i++){
        if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1]){
            a=true;
            break;
        }
    }
    if(a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstdio>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();
constexpr ll I_MAX = numeric_limits<int>::max();
constexpr ull UI_MAX = numeric_limits<unsigned int>::max();

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)



int main() {

	int n;
	cin >> n;
	vector<int> init(n+1, 0);
	vector<vector<int>> cost(3, init);

	vector<vector<int>> dp(3, init);
	rep(i, 0, n) {
		cin >> cost[0][i+1] >> cost[1][i+1] >> cost[2][i+1];
	}
	dp[0][1] = cost[0][1];
	dp[1][1] = cost[1][1];
	dp[2][1] = cost[2][1];



	rep(i, 2, n + 1) {
		rep(k, 0, 3) {
			dp[k][i] = max(dp[(k+1)%3][i-1] + cost[(k)][i], dp[(k + 2) % 3][i - 1] + cost[(k)][i]);
		}
	}

	cout << max(dp[0][n], max(dp[1][n],dp[2][n])) << endl;

	return 0;
}

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

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

    int ans = min(a, b) + min(c, d);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;

int ans[2000][2000];

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  REP(i, H) cin >> S[i];
  REP(i, H) {
    int k = 0;
    REP(j, W) if (S[i][j] == '#') k = 0; else ans[i][j] += k, k++;
  }
  REP(i, H) {
    int k = 0;
    REPR(j, W) if (S[i][j] == '#') k = 0; else ans[i][j] += k, k++;
  }
  REP(j, W) {
    int k = 0;
    REP(i, H) if (S[i][j] == '#') k = 0; else ans[i][j] += k, k++;
  }
  REP(j, W) {
    int k = 0;
    REPR(i, H) if (S[i][j] == '#') k = 0; else ans[i][j] += k, k++;
  }
  int out = 0;
  REP(i, H) REP(j, W) out = max(out, ans[i][j]);
  cout << out+1 << endl;
}





Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    ll ans = 1;

    map<int,int> c;

    int z = 3;

    for(int i = 0; i < n; i++){
        if(a[i] == 0){
            ans *= z;
            ans %=mod;
            c[0+1]++;
            z--;
        } else {
            ans *= c[a[i]];
            c[a[i]]--;
            ans %= mod;
            c[a[i]+1]++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8232
use std::io;

fn solve_b(s: &str) -> String {
    let mut result = String::new();
    for c in s.chars() {
        match c {
            '0' => result.push('0'),
            '1' => result.push('1'),
            'B' => {
                result.pop();
            }
            _ => unreachable!(),
        }
    }

    result
}

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let s = s.trim();
    println!("{}", solve_b(&s));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


//---------------------------------------------------------------
// 高速コンビネーション計算
//---------------------------------------------------------------
/*使用例

	// 計算例
	cout << COM(100000, 50000) << endl;
*/

// テーブルを作る前処理
ll fac[100050], finv[100050], inv[100050];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 100005; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	ll N, K;
	cin >> N >> K;

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

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

	// 前処理
	COMinit();


	ll min_sum = 0;
	ll max_sum = 0;


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

		// A[i]が最小になる集合の個数を数える
		// iより大きいのN-i-1個からK-1個を選ぶ
		if (N - i >= K) {
			min_sum += COM(N - i- 1, K - 1) * A[i];
		}

		min_sum %= MOD;

		// A[i]が最大になる集合の個数を数える
		// iより小さいのi個からK-1個を選ぶ
		if (i + 1 >= K) {
			max_sum += COM(i, K - 1) * A[i];
		}

		max_sum %= MOD;

	}


	if ((max_sum - min_sum) % MOD >= 0) {
		cout << (max_sum - min_sum) % MOD;
	}
	else {
		cout << (max_sum - min_sum) % MOD + MOD;
	}
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,i,j;
    cin>>n>>k;
    int arr[n+1];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(i=1;i<=k;i++)
    {
        dp[0][i]=0;
    } 
    int pref[n+1];
    for(i=1;i<=n;i++)
    {
        pref[0]=dp[i-1][0];
        for(j=1;j<=k;j++)
        {
            pref[j]=(pref[j-1]+dp[i-1][j])%mod;
        }
        for(j=0;j<=k;j++)
        {
            int x = pref[j];
            int rem = j-arr[i-1]-1;
            if(rem>=0)
            {
                x=(x-pref[rem]+mod)%mod;
            }
            dp[i][j]=x;
        }
    }
    /*for(i=1;i<=n;i++)
    {
        for(j=0;j<=k;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[n][k]<<endl;
}

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

int count_black(int H, int W, vector<string> cells)
{
    // 黒いマスの数を数える
    int black = 0;
    for (int row = 0; row < H; row++)
    {
        for (int col = 0; col < W; col++)
        {
            if (cells.at(row).at(col) == '#')
            {
                black++;
            }
        }
    }

    return black;
}

bool check(int row_pattern, int col_pattern, vector<string> cells, int H, int W, int K)
{
    // row_patternで表される行とcol_patternで表される列を赤で塗りつぶす
    for (int row = 0; row < H; row++)
    {
        for (int col = 0; col < W; col++)
        {
            // row_pattern の 下から row番目の bit が 1 (立っている) かどうか
            // row番目の行を赤で塗りつぶすというパターンかどうか
            if (row_pattern & (1 << row))
            {
                cells.at(row).at(col) = '$';
            }
            // col_pattern の 下から col番目の bit が 1 (立っている) かどうか
            // col番目の列を赤で塗りつぶすというパターンかどうか
            if (col_pattern & (1 << col))
            {
                cells.at(row).at(col) = '$';
            }
        }
    }

    return count_black(H, W, cells) == K;
}

void solve(std::istream &ist, std::ostream &ost)
{
    // 変数の読み込み
    int H, W, K;
    ist >> H >> W >> K;
    vector<string> c(H);
    for (int i = 0; i < H; i++)
    {
        ist >> c.at(i);
    }

    int ans = 0;

    // bit 全探索。高さHの各行について、塗りつぶす場合はその行のbitを立てるようなパターンとしてrow_patternを表す
    // そのパターンの数は、2^Hある
    for (int row_pattern = 0; row_pattern < (1 << H); row_pattern++)
    {
        // bit 全探索。幅Wの各列について、塗りつぶす場合はその列のbitを立てるようなパターンとしてcol_patternを表す
        // そのパターンの数は、2^Wある
        for (int col_pattern = 0; col_pattern < (1 << W); col_pattern++)
        {
            // 黒いマスがちょうどK個残るようなパターンであるかどうか
            if (check(row_pattern, col_pattern, c, H, W, K))
            {
                ans++;
            }
        }
    }
    ost << ans << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<tuple>

using namespace std;
const long long INF = (long long)1e18;
vector<vector<tuple<int, long long>>> e;
vector<long long> d;

void dfs(int now){
	for(int i = 0; i < e[now].size(); i++){
		int to;
		long long cost;
		tie(to, cost) = e[now][i];
		if(d[now] + cost < d[to]){
			d[to] = d[now] + cost;
			dfs(to);
		}
	}
}

int main(){
	int n, ans = 0;
	cin >> n;
	e = vector<vector<tuple<int, long long>>>(n + 1, vector<tuple<int, long long>>());
	for(int i = 0; i < n - 1; i++){
		int a, b;
		long long c;
		cin >> a >> b >> c;
		e[a].emplace_back(b, c);
		e[b].emplace_back(a, c);
	}
	d = vector<long long>(n + 1, INF);
	int q, k;
	cin >> q >> k;
	d[k] = 0;
	dfs(k);
	for(int i = 0; i < q; i++){
		int x, y;
		cin >> x >> y;
		cout << d[x] + d[y] << endl;
	}
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    ll n;
    cin >> n;

    vector<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    if( *min_element( all(v) ) != 1 ){
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    ll tmp = 0;
    for(int i = 0; i < n; i++){
        if(v[i] == tmp + 1){
            tmp = v[i];
        }
        else{
            ans ++;
        }
    }
    cout << ans << endl;
}

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

int main(){
    ios_base::sync_with_stdio( false );

	int q;
	cin >> q;
	vector<int> a;

	for( int i = 0; i < q; ++i ) {
		int c, x;
		cin >> c;

		if( c == 0 ) {
			cin >> x;
			a.push_back( x );
		}
		else if( c == 1 ) {
			cin >> x;
			cout << a.at( x ) << '\n';
		}
		else if( c == 2 ) {
			a.pop_back();
		}
	}
}


Measured memory_bytes: 3944
#include <iostream>

using namespace std;

int main() {
 int a, b;
 char op;

 cin >> a >> op >> b;

 int ans;

 while(op != '?') {
  switch(op) {
   case '+':
    ans = a + b;
    break;
   case '-':
    ans = a - b;
    break;
   case '*':
    ans = a * b;
    break;
   case '/':
    ans = a / b;
    break;
  }
  
  cout << ans << endl;

  cin >> a >> op >> b;
 }
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int K, N; cin >> K >> N;
    vector<int> A(N);
    for(auto &it:A){
        cin >> it;
    }

    int sol = K-A.at(N-1)+A.at(0);

    for(int i=1; i<N-1; i++){
        sol = max(sol,A.at(i+1)-A.at(i));
    }
    cout << K-sol << endl;
}

Measured memory_bytes: 1024
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();
    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let A = (0..N).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<Vec<_>>();

    let mut ans = false;
    for a in A{
        ans = ans || a%2==1;
    }
    println!("{}",if ans {"first"} else {"second"});

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,Y;cin>>N>>Y;

    Y/=1000;

    for(int x=0;x*10<=Y;x++){
        for(int y=0;x*10+y*5<=Y;y++){
            int z=Y-x*10-y*5;
            if(x+y+z==N){
                cout<<x<<" "<<y<<" "<<z<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    string s; cin >> s;

    rep1(i,s.length() / 2) {
        int a = (s.length()-2*i ) / 2 ;
        if(s.substr(0,a) == s.substr(a,a)){
            cout << s.length() - 2*i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public int[] C;
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }

            C = new int[N];
            for (int i = 0; i < M; i++)
            {
                var line = Input.ReadIntArray();
                int a = line[0] - 1;
                int b = line[1] - 1;
                C[a]++;
                C[b]++;
            }

            Console.WriteLine(Solve()? "YES" : "NO");
            

        }

        public bool Solve()
        {
            for (int i = 0; i < N; i++)
            {
                if (C[i] % 2 == 1) return false;
            }

            return true;
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 17632
N,L = map(int, input().split())

ajiabs = [abs(i) for i in (range(L,L+N))]
ajiabssort = sorted(ajiabs)
min_idx = ajiabs.index(ajiabssort[0])

aji = [i for i in (range(L,L+N))]
aji.pop(min_idx)

print(sum(aji))



Measured memory_bytes: 3060
from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
events = []
for iR in range(N):
    S, T, X = map(int, input().split())
    events.append((S-X, T-X, X))
events.sort()

iE = 0
anss = []
PQ = []
for _ in range(Q):
    D = int(input())
    while iE < N and events[iE][0] <= D:
        tmSt, tmEn, x = events[iE]
        heappush(PQ, (x, tmEn))
        iE += 1

    xMin = -1
    while PQ:
        x, tmEn = heappop(PQ)
        if tmEn > D:
            xMin = x
            heappush(PQ, (x, tmEn))
            break
    anss.append(xMin)

print('\n'.join(map(str, anss)))


Measured memory_bytes: 59920
import sys
from bisect import bisect_left,bisect,bisect_right

icase=0
if icase==0:
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    d=[]
    cb=[[0]*2 for i in range(m)]
    for i in range(m):
        bi,ci=map(int,input().split())
        cb[i]=[ci,bi]
elif icase==2:
    n,m=10,3
    a=[1, 4, 5, 5, 7, 8, 13, 33, 52, 100]
    cb=[[30, 4], [10, 3], [4, 1]]

a.sort()
cb.sort(reverse=True)

#if cb[0][0]<=a[0]:
#    print(sum(a))
#    sys.exit()
    
asum=0
isum=0
isumm=0
for i in range(m):
    isum+=cb[i][1]
    if isum>n:
        if a[-1]<=cb[i][0]:
            asum+=cb[i][0]*(n-isumm)
            print(asum)
            sys.exit()
        else:
            ii=bisect_right(a,cb[i][0])
            asum+=cb[i][0]*(ii-isumm)
            asum+=sum(a[ii:])
            print(asum)
            sys.exit()
    if a[isum-1]<=cb[i][0]:
        asum+=cb[i][0]*cb[i][1]
        isumm=isum
        continue
    else:
        ii=bisect_right(a,cb[i][0])
        asum+=cb[i][0]*(ii-isumm)
        asum+=sum(a[ii:])
        print(asum)
        sys.exit()
#    isumm=isum
    
asum+=sum(a[isum:])
        
print(asum)


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

int main() {
  string s;
  cin >> s;
  
  for (int i=0; i<(1<<3); i++) {
    bitset<3> b = i;
    int sum = s.at(0)-'0';
    for(int j=0;j<3;j++){
      if(b.test(j))
        sum += s.at(j+1)-'0';
      else
        sum -= s.at(j+1)-'0';
    }
    if (sum == 7) {
      cout << s.at(0);
      for (int j=0;j<3;j++) {
        if(b.test(j))
          cout << '+';
        else
          cout << '-';
        cout << s.at(j+1);
      }
      cout << "=7" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
H = list(map(int, input().split()))

if N==1:
    print("Yes")
    sys.exit()
else:
    for i in range(N-1):
        if H[i] < H[i+1]:
            H[i+1] = (H[i+1] - 1)
        if H[i] > H[i+1]:
            print("No")
            sys.exit()  


print("Yes")

Measured memory_bytes: 14396
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L, R, d;
    cin >> L >> R >> d;
    ll ans = 0;
    REP(i, L, R + 1) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        // スペース区切りの整数の入力
        int b = sc.nextInt();
        int c = sc.nextInt();
        // 文字列の入力
        int m=a+b;
      
      if(m>=c){
        System.out.println("Yes");
    }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

int n,m,k,a[15],p,ans=0;

int main(){
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> k;
    for(int j=0; j<k; j++){
      int x;
      cin >> x;
      a[x-1] += 1<<i;	//bit 1:switch valid
    }
  }
  for(int i=0; i<m; i++){
    int x;
    cin >> x;
    p += x*(1<<i);
  }

  for(int bit=0; bit<(1<<n); bit++){
    int ret=0;
    for(int i=0; i<n; i++){
      if((1<<i)&bit){ret ^= a[i];}	//if valid switch? : count
    }
    if(ret==p){ans++;}
  }
  cout << ans << endl;
  return 0;
}

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

int mod = 1e9 + 7;

ll powmod(ll x, ll y) {
    ll res = 1;
    rep(i, y) {
        res = res*x%mod;
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    ll ans = powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N);
    ans %= mod;
    ans = (ans+mod)%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}
bool bitcheck(ll x, ll y) { return (x >> y) & 1; }

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
struct SegmentTree {
    vector<ll> ar;
    ll size = 1;
    SegmentTree(int n) {
        ar.resize(4 * n - 1, 0);
        while (size < n) {
            size *= 2;
        }
    }
    void update(ll idx, ll x) {
        ll k = size + idx;
        ar[k] = x;
        while (k != 1) {
            k /= 2;
            ar[k] = max(ar[k * 2], ar[k * 2 + 1]);
        }
    }
    ll findinner(ll s, ll t, ll idx, ll be, ll en) {
        ll mid = (be + en) / 2;
        if (be == s && t == en) {
            return ar[idx];
        }
        ll two = 0;
        ll one = 0;
        if (s < mid) {
            two = findinner(s, min(t, mid), 2 * idx, be, mid);
        }
        if (t > mid) {
            one = findinner(max(s, mid), t, 2 * idx + 1, mid, en);
        }
        return max(one, two);
    }
    ll find(ll s, ll t) { return findinner(s, t, 1, 0, size); }
};
int main() {
    ll n;
    cin >> n;
    vector<ll> as(n);
    REP(i, n) { cin >> as[i]; }
    vector<ll> bs(as);
    sort(as.begin(), as.end());
    map<ll, ll> cnt;
    as.erase(unique(as.begin(), as.end()), as.end());
    REP(i, as.size()) { cnt[as[i]] = i; }
    SegmentTree sg(n + 1);
    REP(i, n) { bs[i] = cnt[bs[i]]; }
    for (int i = n - 1; i >= 0; i--) {
        sg.update(bs[i], sg.find(bs[i] + 1, n) + 1);
    }
    cout << sg.find(0, n) << endl;
}


Measured memory_bytes: 13980
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int p[200000];
int n,m;
int cnt=0;

int main() 
{

    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll go=max(a,max(b,c));
    ll bo=go;
    for(int i=0;i<k;++i) bo*=2;

    cout<<a+b+c-go+bo<<endl;
    
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a;
  int cnt;
  int ma = 0;
  int ans = 1;
  for(int i=1; i<=n; i++){
    a = i;
    cnt = 0;
    while(a%2 == 0){
      a /= 2;
      cnt++;
    }
    if(ma < cnt){
      ma = cnt;
      ans = i;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)

int main()
{
    int n,k; cin>>n>>k;
    if((n-2)*(n-1)/2<k){
        cout<<-1<<endl;
        return 0;
    }

    int m = (n-2)*(n-1)/2 - k;
    cout<<n-1+m<<endl;
    for(int i=2;i<=n;i++){
        cout<<"1 "<<i<<endl;
    }
    int src = 2;
    int dst = 3;
    for(int i=0;i<m;i++){
        cout<<src<<" "<<dst<<endl;
        dst++;
        if(dst>n){
            src++; dst=src+1;
        }
    }

    return 0;
}


Measured memory_bytes: 256
h,w,d=map(int,input().split())
p=[0]*(h*w)
for i in range(h):
  a=list(map(int,input().split()))
  for j in range(w):p[a[j]-1]=(i,j)
x=[0]*d
calc=lambda x1,y1,x2,y2:abs(x1-x2)+abs(y1-y2)
for i in range(d,h*w):
  x.append(x[i-d]+calc(p[i][0],p[i][1],p[i-d][0],p[i-d][1]))
for i in range(int(input())):
  l,r=map(int,input().split())
  print(x[r-1]-x[l-1])

Measured memory_bytes: 15980
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int N, M;
    cin >> N >> M;
    if (N == M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int N;

	cin >> N;
  vector<int> A(N);
  unordered_set<int> num;
  
  for (auto& i : A) {
    cin >> i;
  }
  
  for (int i = N; i >= 1; i--) {
    int count = 0;
  	for (int j = i * 2; j <= N; j += i) {
    	if (num.count(j) >= 1)
          count++;
    }
    
    if (A[i-1] != count % 2)
      num.insert(i);
  }

	cout << num.size() << endl;
  
  bool space = false;
  for (auto&& i : num) {
    cout << (space ? " " : "") << i;
    space = true;
  }
  
  cout << endl;

	return 0;
}


Measured memory_bytes: 7844