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

void solve(long long A, long long B, long long C){
	cout << 9 * max(A, max(B,C)) + A + B + C << endl;
}

int main(){	
	long long C;
	long long B;
	long long A;
	scanf("%lld",&A);
	scanf("%lld",&B);
	scanf("%lld",&C);
	solve(A, B, C);
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int n;
  cin>>n;
  long long ans=1;
  REP(i,n){
    ans = mod(ans * (i+1));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[200200];

int main() {
	ll n;
	cin>>n;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		d[a] = i;
	}
	ll mx = 1;
	ll ans = 1;
 	rep(i,1,n){
 		if(d[i]<d[i+1]){
 			ans++;
 			mx = max(mx,ans);
 		}
 		else{
 			ans = 1;
 		}
 	}
 	cout << n-mx << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define Mid ((l+r)>>1)
#define lson rt<<1,l,Mid
#define rson rt<<1|1,Mid+1,r
const int maxn= 100000+5;
int arr[maxn<<2];

void build(int rt,int l,int r){
    if(l==r)arr[rt] = 2147483647;
    else{
        build(lson);
        build(rson);
        arr[rt] = min(arr[rt<<1], arr[rt<<1|1]);
    }
}

void updata(int rt,int l,int r,int pos,int num){
    if(l == r && r == pos)
        arr[rt] = num;
    else{
        if( pos <= Mid)
            updata(lson,pos,num);
        else
            updata(rson,pos,num);
        arr[rt] = min(arr[rt<<1], arr[rt<<1|1]);
    }
}

int query(int rt,int l,int r,int L,int R){
    if(L <= l && r <= R)
        return arr[rt];
    else{
        int tmp = 2147483647;
        if( L <= Mid)
            tmp = min(query(lson,L,R), tmp);
        if( R > Mid)
            tmp = min(query(rson,L,R), tmp);
        return tmp;
    }
}

int main(){
    int n, q, ch, x, y;
    scanf("%d %d", &n, &q);
    build(1,1,n);
	while (q--){
	    scanf("%d%d%d", &ch, &x, &y);
	    if (ch)printf("%d\n", query(1, 1, n, x + 1, y + 1));
	    else updata(1, 1, n, x + 1, y);
	}
    return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  vector<string> N(4); REP(i, 4) cin >> N[i];
  string ans = "NO";
  sort(all(N));
  do {
    string tmp = "";
    REP(i, 4) tmp += N[i];
    if(tmp == "1974") ans = "YES";
  } while (next_permutation(all(N)));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int d;

vector<int> c;
vector<vector<int>> s;
vector<int> t;

int last(int d, int i) {
  int j;

  for (j=d; j>=0; j--) {
    if (t[j] == i) return d-j;
  }
  return d+1;
}

int main()
{
  int i, j;
  int conf=0;

  void print_conf();

  c.resize(26);
  cin >> d;
  for(i=0; i<26; i++) {
    cin >> c[i];
  }

  s.resize(d);
  for (i=0; i<d; i++) {
    s[i].resize(26);
    for (j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }

  t.resize(d);
  for (i=0; i<d; i++) {
    int tx;
    cin >> tx;
    tx--;
    t[i] = tx;
    conf += s[i][tx];
//printf("+ %d\n", s[i][tx]);
    for (j=0; j<26; j++) {
      int cm;
      cm = c[j] * last(i, j);
      conf -= cm;
//printf("- %d\n", cm);
    }
//printf("conf = %d\n", conf);
  }

//  print_conf();


  int m;
  
  cin >> m;
  for (i=0; i<m; i++) {
    int xd, xq;
    int oq;
    cin >> xd >> xq;
    xd--; xq--;
    oq = t[xd];

    conf += s[xd][xq] - s[xd][oq];
//printf("s[%d][%d] = %d -> s[%d][%d] = %d\n", xd ,oq, s[xd][oq], xd, xq, s[xd][xq]);

    for (j=xd; j<d; j++) {
      if (j>xd && t[j]==oq) break;
      conf += c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
    }
    for (j=xd; j<d; j++) {
      if (j>xd && t[j]==xq) break;
      conf += c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
    }

    t[xd] = xq;
    for (j=xd; j<d; j++) {
      if (j>xd && t[j]==oq) break;
      conf -= c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
    }
    for (j=xd; j<d; j++) {
      if (j>xd && t[j]==xq) break;
      conf -= c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
    }

//printf("%d: \n", i);
    printf("%d\n", conf);
//print_conf();
  }


  return 0;
}

void print_conf() {
  int conf=0;
  int i,j ;
  for (i=0; i<d; i++) {
printf("s[%d][%d]=%d\n", i, t[i], s[i][t[i]]);
    conf += s[i][t[i]];
    for (j=0; j<26; j++) {
      int x;
      x = c[j] * last(i, j);
printf("c[%d] * last(%d, %d) = %d\n", j, i, j, x);
      conf -= x;
    }
  }
  printf("%d\n", conf);
}


Measured memory_bytes: 3828
/*
	Author: Ritik Patel
*/
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
// #define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
// #pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#include <bits/stdc++.h>
using namespace std;
 
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
//find_by_order()->returns an iterator to the k-th largest element(0-based indexing)
//order_of_key()->Number of items that are strictly smaller than our item
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define int long long int
// #define ll long long int
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
// #define ld long double
// const ld PI  = 3.141592;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&


void solve(){
    int K; cin >> K;
    for(int i = 0; i < K; ++i){
        cout << "ACL";
    }
    cout << '\n';
}

int32_t main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout); 
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int T = 1; 
    // cin >> T;
    for(int i = 1; i <= T; ++i){
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}
 
/*
Sample inp
*/

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int maxn=12+10;
int n,m,cnt[maxn][26],other[maxn];
char a[maxn][maxn];
bool cmp[maxn][maxn],cmpp[maxn],done[maxn];

void dfs2(int rest){
	if(!rest){
		puts("YES");
		exit(0);
	}
	if(rest&1){
		for(int i=0;i<m;++i){
			for(int j=0;j<n;++j)
				if(a[j][i]!=a[other[j]][i])
					goto door1;
			done[i]=true;
			dfs2(rest-1);
door1:
			;
		}
	}
	else{
		for(int i=0;i<m;++i)
			if(!done[i]){
				for(int j=i+1;j<m;++j)
					if(!done[j]){
						for(int k=0;k<n;++k)
							if(a[k][i]!=a[other[k]][j])
								goto door2;
						done[i]=done[j]=true;
						dfs2(rest-2);
						done[i]=done[j]=false;
door2:
						;
					}
				return;
			}
	}
}
void dfs1(int rest){
	if(!rest){
		dfs2(m);
		return;
	}
	if(rest&1){
		for(int i=0;i<n;++i)
			if(cmpp[i]){
				other[i]=i;
				dfs1(rest-1);
				other[i]=-1;
			}
	}
	else{
		for(int i=0;i<n;++i)
			if(other[i]==-1){
				for(int j=i+1;j<n;++j)
					if(other[j]==-1&&cmp[i][j]){
						other[i]=j;other[j]=i;
						dfs1(rest-2);
						other[i]=other[j]=-1;
					}
				return;
			}
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i<n;++i){
		cin>>a[i];
		for(int j=0;j<m;++j)
			++cnt[i][a[i][j]-'a'];
	}
	for(int i=0;i<n;++i)
		for(int j=i+1;j<n;++j){
			cmp[i][j]=cmp[j][i]=true;
			for(int k=0;k<26;++k)
				if(cnt[i][k]!=cnt[j][k]){
					cmp[i][j]=cmp[j][i]=false;
					break;
				}
		}
	for(int i=0;i<n;++i){
		int x=0;
		for(int j=0;j<26;++j)
			if(cnt[i][j]&1)
				++x;
		if(x!=m%2)
			cmpp[i]=false;
		else
			cmpp[i]=true;
		other[i]=-1;
	}
	dfs1(n);
	puts("NO");
	return 0;
}

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

#define llong long long 
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define rand __rand
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
template<class T = int> T rand(T range = numeric_limits<T>::max()) { return (T)(rng() % range); }

#define CONCAT_(x, y) x##y/*{{{*/
#define CONCAT(x, y) CONCAT_(x, y)
#define SPEC(name) CONCAT(name, __LINE__)
#ifdef LOCAL_DEBUG   
int __db_level = 0;
#define clog cerr << string(__db_level * 2, ' ')
struct debug_block {
    string msg;
    debug_block(const string& s): msg(s) { clog << "{ " << msg << endl; ++__db_level; }
    ~debug_block() { --__db_level; clog << "} " << msg << endl; }
};
#define DB(args...) stringstream SPEC(ss); SPEC(ss)<< args; debug_block SPEC(dbbl)(SPEC(ss).str())
#else
#define clog if (0) cerr
#define DB(...)
#endif
#define db(val) "[" #val " = " << val << "]; "
template<class U, class V> ostream& operator<<(ostream& out, const pair<U, V>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<size_t i, class T> ostream& print_tuple_utils(ostream& out, const T& tup) {
    if constexpr(i == tuple_size<T>::value) return out << ")";
    else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup);
}
template<class ...U>
ostream& operator<<(ostream& out, const tuple<U...>& tup) { return print_tuple_utils<0, tuple<U...>>(out, tup); }
template<class, typename = void> struct has_const_iterator : false_type {};
template<class T> struct has_const_iterator<T, void_t<typename T::const_iterator>> : true_type {};
template<class T>
typename enable_if<has_const_iterator<T>::value && !is_same<T, string>::value, ostream&>::type
operator<<(ostream& out, const T& container) { 
    auto beg = container.begin(), end = container.end();
    out << "(" << container.size() << ") {";
    if (beg != end) out << *(beg++);
    while (beg != end) out << ", " << *(beg++);
    return out << "}";
}
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION BELOW ////////////////////////////////////////////////////////////

const int maxn = 2020;
const llong mod = (llong)1e9 + 7;
int s;
llong dp[maxn];

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    dp[0] = 1;
    rep(i, s) {
        for (int num = 3; num + i <= s; ++num) {
            (dp[i + num] += dp[i]) %= mod;
        }
    }
    cout << dp[s];

    return 0;
}

// Remember:
// - Multitest? REFRESHING the data!!!
// - Constrains for each set of data may differs. Should NOT USE the same max constant (maxn)
//   for all of them.
// vim: foldmethod=marker



Measured memory_bytes: 3668
class Main{
  public static void main(String[] args) throws Exception{
    int a = System.in.read();
    int b = System.in.read();
    int c = 0;
    int count = 1;

    do {
      c = System.in.read();
      if(a==b && c!=-1) {
        System.out.println(count+" "+(count+1));
        return;
      }else if(a==c) {
        System.out.println(count+" "+(count+2));
        return;
      }
      count++;
      a = b;
      b = c;
    } while(c != -1);
    System.out.println("-1 -1");
  }
}


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

int main(){
    long N,K;
    long amari;
    cin >> N >> K;
    amari = N % K;
    if (amari<K-amari){
        cout << amari <<endl;
    }else{
        cout << K-amari <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int r, g, b, n;
    scanf("%d %d %d %d", &r, &g, &b, &n);
    
    long long ans=0;
    for(int i=0; i<=n/r; i++){
        for(int j=0; j<=n/g; j++){
            if(n-i*r-j*g>=0 && (n-i*r-j*g)%b==0)ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1704
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAX 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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



int main() {
  ll N,W;
  ll n,w;
  cin >> N>>W;
  cin>>n>>w;

  ll ans=0;
 

  cout<<(N-n)*(W-w)<<endl;
 

 
}
 


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i,b)   for(int i=0;i<(b);i++)
#define f1(i,b)   for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define forr(i,n)    for(i=0; i<n; i++)
#define whilee(i,t)  while(i!=t)
#define pb(x) push_back(x);
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld",a)

//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//accumulate(A.begin(), A.end(), 0);//add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//scanf("%d",&x);
//printf("%d\n",x);

//vector <int> A;
//deque <int> A;
//queue <int> A;
//stack <int> A;
//set <int> A;
//map <int,int> A;
//pair <int,int> A ;
//vector <pair <int,int>> A ;
//char ch;
//string S, T;
ll i, j, k, a, b, c, d, f, g, h, l, m, n, p, q, r, s, t, w, x, y, z, maxx=0, minn=0, ans=0, sum=0, cnt=0;

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

    cin>>n;
    if(n==7 || n==5 || n==3)
    {
       cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long n, k;
    long long graph[105][105];
    long long maxv;
    long long edge = 0;

    scanf("%d %d", &n, &k);

    maxv = (n - 1) * (n - 2) / 2;

    if (maxv < k) {
        printf("-1\n");
        return 0;
    }

    for (long long i = 2; i <= n; i++) {
        graph[1][i] = 1;
        edge++;
    }

    long long i = 2;
    while (maxv > k) {
        for (long long j = i + 1; j <= n && maxv > k; j++) {
            graph[i][j] = 1;
            edge++;
            maxv--;
        }
        i++;
    }

    printf("%d\n", edge);
    for (long long i = 1; i <= n; i++) {
        for (long long j = 1; j <= n; j++) {
            if (graph[i][j]) {
                printf("%d %d\n", i, j);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    d = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}

    print(d[gete()])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	nfs_mw;
	ll i,j;
	cin>>i>>j;
	cout<<((i*j)/__gcd(i,j));

}

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

#define rep(i, e) for( int i = 0; i < e; i++ )
typedef vector<int> vec;

struct log{
    int t, s, d, v;
    bool operator<( const log& log ) const{
        return t < log.t;
    }
};

int main(){
    int N, M;
    while( cin >> N >> M, N ){
        vec com(N);
        com[0] = 1;
        int count = 1;
        vector<log> data(M);
        rep(i, M){
            cin >> data[i].t >> data[i].s >> data[i].d;
        }
        sort(data.begin(), data.end() );
        rep(i, M){
            if( com[data[i].s-1] && !com[data[i].d-1] ){
                com[data[i].d-1]++;
                count++;
            }
        }
        //rep(i, M) cout << data[i].t << ' ' << data[i].s << ' ' << data[i].d << ' ' << data[i].v << endl;
        cout << count << endl;
    }
}

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

int main()
{
    int n;
    cin >> n;
    int cost[n - 1];
    int start[n - 1];
    int freq[n - 1];
    rep(i, 0, n - 1)
        cin >> cost[i] >> start[i] >> freq[i];
    
    rep(i, 0, n)
    {
        int now = 0;
        rep(j, i, n - 1)
        {
            if (now < start[j])
                now = start[j] + cost[j];
            else
            {
                int idx = (now - start[j] + freq[j] - 1) / freq[j];
                now = start[j] + freq[j] * idx + cost[j]; 
                // cout << j << ' ' << i << ' ' << idx << ' ' << start[j] << ' '  << endl;
            }
            // cout << now << endl;
        }
        cout << now << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    vector<string> s(3);
    vector<int> len(3);
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
        len[i] = s[i].length();
    }

    char winner;
    int state = 0;
    vector<int> idx(3, -1);
    while (1) {
        if (++idx[state] == len[state]) {
            winner = state + 'A';
            break;
        }
        state = (s[state][idx[state]] - 'a');
    }

    cout << winner << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
//#include"big_integers.h"

using namespace std;

const int MAX_N = 100001;

int memo[MAX_N];

int rec(int n)
{
	if (n == 0)
		return 0;
	if (memo[n] != -1)
		return memo[n];

	int res = n;
	for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
		res = min(res, rec(n - pow6) + 1);
	}
	for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
		res = min(res, rec(n - pow9) + 1);
	}
	return memo[n] = res;

}

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

	for (int i = 0; i <= n; i++) {
		memo[i] = -1;
	}
	cout << rec(n) << endl;
}

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

using ll = long long;

template <int Mod, bool IsPrime = false>
class mod_int {
    using ll = long long;

public:
    constexpr mod_int() : n(0) {}
    constexpr mod_int(int n_) : n(n_) {
        if(n >= Mod)     n %= Mod;
        else if(n < 0) n = (n % Mod + Mod) % Mod;
    }
    constexpr mod_int(ll n_) : n(n_) { n = (n + Mod) % Mod; }

    constexpr operator int() const { return n; }
    constexpr operator ll() const  { return n; }

    constexpr bool operator==(mod_int const& other) const { return n == other.n; }
    constexpr mod_int& operator+=(mod_int const& other) {
        if((n += other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator-=(mod_int const& other) {
        if((n += Mod - other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator*=(mod_int const& other) {
        n = (unsigned long long)n * other.n % Mod;
        return *this;
    }
    constexpr typename std::enable_if<IsPrime, mod_int>::type& operator/=(mod_int const& other) {
        return *this *= other.inverse();
    }
    constexpr mod_int operator+(mod_int other) const { return mod_int(*this) += other; }
    constexpr mod_int operator-(mod_int other) const { return mod_int(*this) -= other; }
    constexpr mod_int operator*(mod_int other) const { return mod_int(*this) *= other; }
    constexpr mod_int operator/(mod_int other) const { return mod_int(*this) /= other; }

    constexpr typename std::enable_if<IsPrime, mod_int>::type inverse() const {
        ll a = n, b = Mod, u = 1, v = 0;
        while(b) {
            ll t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        return mod_int(u);
    }

private:
    ll n;
};

template <int Mod, bool IsPrime>
std::ostream& operator<<(std::ostream& os, mod_int<Mod, IsPrime> const& n) {
    os << (int)n;
    return os;
}

constexpr int default_mod = 1000000007;

using mint = mod_int<default_mod, true>; // default

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(auto& x : a) cin >> x;

    mint prod_as = 1;
    vector<int> maxi(1 << 20);
    for(int i = 0; i < n; ++i) {
        prod_as *= a[i];
        int tmp = a[i];
        for(int x = 2; x * x <= tmp; ++x) {
            int c = 0;
            while(tmp % x == 0) {
                tmp /= x;
                c += 1;
            }
            maxi[x] = max(maxi[x], c);
        }
        if(tmp > 1) {
            maxi[tmp] = max(maxi[tmp], 1);
        }
    }

    mint lcm = 1;
    for(int i = 2; i < 1 << 20; ++i) {
        for(int lp = 0; lp < maxi[i]; ++lp) {
            lcm *= i;
        }
    }

    mint ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += lcm * (prod_as / mint(a[i]));
    }
    ans /= prod_as;

    cout << ans << endl;
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a[10];
    int b;
    for(int i = 0; i< 10; i++)
    {
        scanf("%d", &a[i]);

    }

    //排序部分。????排序。
    for(int i = 0; i < 3 ; i++) //?出前三名
    {
        int max = i;
        for(int j = i; j < 10; j++)
        {
            if(a[j] > a[max])
            {
                max = j;
            }
        }
        int temp = a[max];
        a[max] = a[i];
        a[i] = temp;
        printf("%d\n", a[i]);
    }

    return 0;
}

Measured memory_bytes: 3192
import math

n,m = map(int,input().split())

rev = 10**9+7

if n-m==0:
    ans = 2 * math.factorial(n) * math.factorial(m)
elif (abs(n-m)==1):
    ans = 1 * math.factorial(n) * math.factorial(m)
else:
    ans = 0
print(ans%rev)


Measured memory_bytes: 5108
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		
		double r = scan.nextDouble();
		final double pi = Math.PI;
		System.out.printf("%.6f %.6f\n", pi*r*r, 2*pi*r);

	}

}

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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] a = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
				sum += a[i];
			}
			Arrays.sort(a);
			sum -= a[0];
			sum -= a[n - 1];
			System.out.println(sum / (n - 2));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20944
#include <string>
#include <vector>
#include <string.h>
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <random>
using namespace std;
typedef long long ll;
const int INF = 987654321;
const int MAX_N = 3e5 + 2, MAX_X = 1e6 + 2;

int main()
{
	int N;
	cin >> N;
	vector<pair<int,int>>v(N);
	for (auto&i : v)cin >> i.first >> i.second;

	for (int i = 0; i < N - 2; i++)
	{
		bool flag = true;
		for (int j = 0; j < 3; j++)
			if (v[i + j].first != v[i + j].second)flag = false;
		if (flag) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);

    const double PI=acos(-1);
    auto A=(h*60+m)*0.5*PI/180;
    auto B=m*6*PI/180;

    auto px=a*sin(A), py=a*cos(A);
    auto qx=b*sin(B), qy=b*cos(B);
    printf("%.10f\n", hypot(px-qx, py-qy));
}


Measured memory_bytes: 2476
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

        if(a <= b) {
			for(int i=1 ; i<=b ; i++) {
				System.out.print(a);
			}
		}
		else {
			for(int i=1 ; i<=a ; i++) {
				System.out.print(b);
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 21716
n = gets.chomp.to_i

h0 = 0
h1 = 0
ary = Array.new(n)
n.times do |i|
  x = gets.chomp.to_i
  if h0 < x
    h1 = h0
    h0 = x
  elsif h1 < x
    h1 = x
  end
  
  ary[i] = x
end

ary.each do |x|
  if x == h0
    puts h1
  else
    puts h0
  end
end


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

int main() {
  int n;
  cin>>n;
  int b=0;
  for(int i=1;i<=n;i+=2){
    int a=0;
    for(int j=1;j<=n;j++){
      if(i%j==0) a++;
    }
    if(a==8) b++;
  }
  cout<<b<<endl;
}

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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{

int a, b, c;
cin >> a >> b >> c;

vector<int>vec = {a,b,c};
sort(vec.begin(), vec.end());

cout << vec.at(2) * 10 + vec.at(1) + vec.at(0) << endl;

return 0;
}

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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

V d;
int N;
ll dfs(string n){
	if(n.size()==N-1){
		ll res=0;
		ll c = d[0];
		REP(i,N-1){
			if(n[i] == '0')
				c = c*10 + d[i+1];
			else{
				res += c;
				c = d[i+1];
			}
		}
		return res+c;
	}
	return dfs(n+'0') + dfs(n+'1');
}

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

	N = S.size();
	d.resize(N);
	REP(i,N)d[i] = S[i]-'0';

	cout << dfs("") << endl;

	return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> ppiii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> query;

ll facs[205];
ll ifacs[205];
const int MOD = 1000000007;

ll modpow(ll b, ll e, ll m) {
  ll r = 1;
  while(e) {
    if(e%2) {
      r *= b;
      r %= m;
    }
    b *= b;
    b %= m;
    e /= 2;
  }
  return r;
}

int l[205];
bool found[205][100005];
ll dp[205][100005];

int n;
ll solve(int k, int x) {
  if(k == 0) return x;
  if(found[k][x]) return dp[k][x];
  found[k][x] = true;
  dp[k][x] = solve(k-1, x%l[k-1]) + (k-1) * solve(k-1, x);
  dp[k][x] %= MOD;
  dp[k][x] *= modpow(k, MOD-2, MOD);
  dp[k][x] %= MOD;
  return dp[k][x];
}

void solve() {
  int m;
  cin >> n >> m;
  facs[0] = 1;
  for(int i = 1; i <= n; i++) {
    facs[i] = facs[i-1] * i;
    facs[i] %= MOD;
  }
  ifacs[n] = modpow(facs[n], MOD-2, MOD);
  for(int i = n-1; i >= 0; i--) {
    ifacs[i] = ifacs[i+1] * (i+1);
    ifacs[i] %= MOD;
  }
  for(int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l, l+n);
  ll ret = solve(n, m);
  ret *= facs[n];
  ret %= MOD;
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 175232
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

int q[256];
char s[64];
int qq[256];

int main(){
	fore(i,'a','z'+1)q[i]=10000;
	int n;
	scanf("%d",&n);
	fore(i,0,n){
		memset(qq,0,sizeof(qq));
		scanf("%s",s);
		for(int j=0;s[j];++j){
			qq[s[j]]++;
		}
		fore(j,'a','z'+1)q[j]=min(q[j],qq[j]);
	}
	fore(i,'a','z'+1)while(q[i]--)putchar(i);
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main()
{
	int a[6];
	int i,j;
	for (i = 0;i < 6;i++)scanf("%d", &a[i]);
	for(j=0;j<5;j++)
	{
		for (i = 1;i<5;i++)
		{
			if ((a[i] - a[j]) > a[5])
			{
				printf(":(\n");
				return 0;
			}
		}
	}
	printf("Yay!\n");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
l = list(map(int,input().split()))
min = l[0]
max = l[0]
sum = l[0]
for num in range(1,n):
    if min > l[num]:
        min = l[num]
    if max < l[num]:
        max = l[num]
    sum += l[num]

ans = [min,max,sum]
print(ans[0],ans[1],ans[2])


Measured memory_bytes: 6600
#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) << " "

int main(void){
    int a, b;cin>>a>>b;
    string ans="";
    if(a<b){
        for(int i=0;i<b;i++)ans.append(to_string(a));
    }
    else{for(int i=0;i<a;i++)ans.append(to_string(b));}
    co(ans);
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
s1 = sum(A)

for i in reversed(range(N)):
    if B[i] >= A[i+1]:
        B[i] -= A[i+1]
        A[i+1] = 0
        if B[i] >= A[i]:
            B[i] -= A[i]
            A[i] = 0
        else:
            A[i] -= B[i]
            B[i] = 0
    else:
        A[i+1] -= B[i]
        B[i] = 0

if B[0] >= A[0]:
    A[0] = 0
else:
    A[0] -= B[0]

print(s1 - sum(A))


Measured memory_bytes: 19004
import java.util.Scanner;

public class Main {

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

        // 変数の読み込み
        int w_x = sc.nextInt(); // 長方形の右上のx座標
        int h_y = sc.nextInt(); // 長方形の右上のy座標
        int circle_x = sc.nextInt(); // 円の中心のx座業
        int circle_y = sc.nextInt(); // 円の中心のy座業
        int circle_r = sc.nextInt(); // 円の半径

        // 判定に使用する変数
        boolean containsCircle = false;
        int circle_d = 2 * circle_r;

        // 円の内側の判定
        if (circle_x <= 0 || circle_y <= 0) {
            containsCircle = false;
        } else if (circle_x >= w_x || circle_y >= h_y) {
            containsCircle = false;
        } else if (w_x - circle_d >= 0 && h_y - circle_d >= 0) {
            containsCircle = true;
        }

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

    }
}

Measured memory_bytes: 17328
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0; i<s.size()-t.size()+1; i++) {
        int cnt = 0;
        string res = s.substr(i,t.size());
        debug(res);
        for (int a=0; a<t.size(); a++) {
            if(res[a] == t[a]) cnt++;
        }
        debug(cnt);
        if(cnt > ans) ans = cnt;
    }
    ans = t.size() - ans;
    cout << ans << endl;
}

Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	float ans = 0;
	vector<int>A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ans += (float)1 / A[i];
	}
	cout << (float)1 / ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

const ll M = 1e9 + 7;

ll sigma(ll n)
{
	return n*(n+1)/2;
}

void solve()
{
	ll n, k;
	cin>>n>>k;
	ll answer = 1;
	for(ll i=k; i<=n; i++)
	{
		ll temp = sigma(n) +1 - sigma(i-1) - sigma(n-i);
		answer = (answer + temp)%M;
	}
	cout<<answer <<"\n";
	
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	t = 1;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 10000000000000000

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<int>> X(100020,vector<int>(0));
	
	for(int i=0;i<N;i++){
		int A,B;
		cin>>A>>B;
		A--;
		X[A].push_back(B);
	}
	long long ans = 0;
	priority_queue<int> que;
	for(int i=0;i<M;i++){
		for(int j=0;j<X[i].size();j++){
			que.push(X[i][j]);
		}
		if(que.size()==0)continue;
		ans += (long long)que.top();
		que.pop();
	}
	
	
	cout<<ans<<endl;
		
	
	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c;
    int sum1=0,sum2=0,sum3=0;
    int sum;
    int n,m;
    cin>>a>>b>>c>>n>>m;
    sum1=a*n+b*m;
    if(n>m){
        sum2=c*2*m+a*(n-m);
        sum3=c*2*n;
    }
    else{
        sum2=c*2*n+b*(m-n);
        sum3=c*2*m;
    }
    sum=min(sum1,sum2);
    sum=min(sum,sum3);
    cout<<sum<<endl;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int n=sz(s);
	
	VL  dp(4), np(4);
	dp[0]=1;
	
	rep(i, n){
		fill(all(np), 0);
		char cr = s[i];
		rep(j, 4){
			if(cr == '?') (np[j] += dp[j] * 3)%=MD;
			else (np[j] += dp[j] )%=MD;
		}
		rep(j, 3){
			if(cr == 'A'+j || cr=='?') (np[j+1] += dp[j] )%=MD;
		}
		swap(dp, np);
	}
	cout << dp[3] <<"\n";
	return 0;
}


Measured memory_bytes: 512
n,m,x = gets.split.map(&:to_i)
c = n.times.map{gets.split.map(&:to_i)}

min = 10**9

(2**n).times{|i|
  s = (2**n+i).to_s(2)[1..-1]
  sum = 0
  und = [0]*m
  s.each_char.with_index{|z,i|
    if z=='1'
      sum += c[i][0]
      m.times{|j|
        und[j] += c[i][1+j]
      }
    end
  }
  if sum<min && und.all?{|t| t>=x}
    min = sum
  end
}

if min!=10**9
  p min
else
  p -1
end

Measured memory_bytes: 14300
#include <iostream>

using namespace std;

int main()
{
    string color1 , color2;
    cin>>color1;
    cin>>color2;
    int x,y;
    cin>>x;
    cin>>y;
    string answer;
    cin>>answer;
    if(answer==color1){
        x=x-1;
        cout<<x<<" "<<y;
    }
    if(answer==color2){
        y=y-1;
        cout<<x<<" "<<y;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char c[7]={32,32,32,32,32,32,32};
inline void pl(int n){
    int i=5;
    do{ c[i]=n%10+48; n/=10; i--; }while(n>0);
    for(i++;i<7;i++){ putchar_unlocked(c[i]); }
}

static void solve(const int n, const int a, const int b, int mask, const int common){
    if(n==1){
        pl(common|a);
        pl(common|b);
    }else{
        const int t = a^b;
        const int d = t&(-t);
        mask ^= d;
        const int aa = a & mask, ab = aa ^ (mask&(-mask));
        solve(n-1, aa, ab, mask, common|(a&d));
        solve(n-1, ab, b&mask, mask, common|(b&d));
    }
}

int main(void){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if(__builtin_parity(a)==__builtin_parity(b)){
        puts("NO");
    }else{
        puts("YES");
        solve(n, a, b, -1, 0);
    }
    return 0;
}


Measured memory_bytes: 896
input()

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

lenB=len(b)
count=0
for i in range(lenB):
    if b[i]>a[i]:
        count+=a[i]
        b[i]-=a[i]
        a[i]=0
        if b[i]>a[i+1]:
            count+=a[i+1]
            b[i]-=a[i+1]
            a[i+1]=0
        else:
            count+=b[i]
            a[i+1]-=b[i]
            b[i]=0
    else:
        count+=b[i]
        a[i]-=b[i]
        b[i]=0


print(count)


Measured memory_bytes: 19004
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> in[n], out[n];
    vector<vector<bool>> roads(n, vector<bool>(n, false));
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        in[b - 1].push_back(a - 1);
        out[a - 1].push_back(b - 1);
        roads[a - 1][b - 1] = true;
    }
    queue<int> nodes;
    for(int i = 0; i < n; i++){
        if(in[i].empty()){
            nodes.push(i);
        }
    }
    int topological[n], degree[n];
    for(int i = 0; i < n; i++){
        degree[i] = int(in[i].size());
    }
    int now = 0;
    while(!nodes.empty()){
        topological[nodes.front()] = now;
        now++;
        for(int i: out[nodes.front()]){
            degree[i]--;
            if(!degree[i]){
                nodes.push(i);
            }
        }
        nodes.pop();
    }
    int rank[n];
    for(int i = 0; i < n; i++){
        rank[topological[i]] = i;
    }
    for(int i = 0; i < n; i++){
        cout << rank[i] + 1 << endl;
    }
    for(int i = 0; i < n - 1; i++){
        if(!roads[rank[i]][rank[i + 1]]){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}



Measured memory_bytes: 7916
#include<iostream>
#include <string>
#include<vector>
typedef long long ll;

using namespace std;
int main()
{
	int n;
	int kotae = 0;
	cin >> n;
	vector<int> as(n);
	for (int i = 0; i < n; i++) {
		cin >> as[i];
	}
	while (1) {
		for (int i = 0; i < n; i++) {
			if (as[i] % 2 == 0) {
				as[i] = as[i] / 2;
			}
			else {
				cout << kotae;
				return 0;
			}
		}
		kotae++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 A, B, M, i;
  cin >> A >> B >> M;
  vi a(A), b(B);
  REP(0, A, i) {
    cin >> a[i];
  }
  REP(0, B, i) {
    cin >> b[i];
  }

  vector<unordered_map<i64, i64>> C(A);
  REP(0, M, i) {
    i64 x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    if(C[x].find(y) == C[x].end())
      C[x][y] = c;
    else
      C[x][y] = max(c, C[x][y]);
  }

  set<pi> Bs;
  REP(0, B, i) {
    Bs.insert(pi(b[i], i));
  }
  
  i64 ans = 1000000;
  REP(0, A, i) {
    //set<pi> Bss = Bs;
    for(auto &p: C[i]) {
      i64 y = p.first;
      i64 c = p.second;
      Bs.erase(Bs.find(pi(b[y], y)));
      Bs.insert(pi(b[y] - c, y));
    }
    ans = min(ans, a[i] + Bs.begin()->first);
    for(auto &p: C[i]) {
      i64 y = p.first;
      i64 c = p.second;
      Bs.erase(Bs.find(pi(b[y] - c, y)));
      Bs.insert(pi(b[y], y));
    }
  }
  cout << ans << endl;

  return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const ll MAXN = 100010;
ll N, M;
ll f[MAXN], sum[MAXN];

ll Find(ll x)
{
	if (x == f[x]) return x;
	ll tmp = Find(f[x]);
	sum[x] += sum[f[x]];
	return f[x] = tmp;
}

int main(int argc, char **argv)
{
	cin >> N >> M;
	REP(i, N) f[i] = i, sum[i] = 0;

	REP(i, M)
	{
		ll l, r, d; cin >> l >> r >> d;
		--l, --r;

		ll a = Find(l);
		ll b = Find(r);

		if (a == b)
		{
			if (sum[l]-sum[r] != d)
			{
				std::cout << "No" << std::endl;
				return 0;
			}
		}
		else
		{
			f[a] = b;
			sum[a] = sum[r]-sum[l]+d;
		}
	}

	std::cout << "Yes" << std::endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b) cout << "a < b" << endl;
    if(a==b) cout << "a == b" << endl;
    if(a>b) cout << "a > b" << endl;
    
    return 0;
}


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

using namespace std;

int main(void){
    int N;cin>>N;
    int cnt = 0;
    for(int i = 1;i <= N; i++ ){
        if((1 <= i&&i <= 9 )|| (100<= i&&i <= 999) || (10000 <= i&&i <= 99999))cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256