akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

char change_letter(char c) {
  if (c == 'L') {
    return 'U';
  }
  if (c == 'R') {
    return 'D';
  }
  return 'X';
}

bool solve(int h, int y, const string& s, const string& t) {
  pii range(0, h);

  rrep(i, s.size()) {
    if (t[i] == 'U') {
      range.sc = min(h, range.sc + 1);
    }
    if (t[i] == 'D') {
      range.fs = max(0, range.fs - 1);
    }

    if (s[i] == 'U') {
      range.fs = min(h, range.fs + 1);
    }
    if (s[i] == 'D') {
      range.sc = max(0, range.sc - 1);
    }
    if (range.fs >= range.sc) {
      return false;
    }
    //cerr << i << " " << range.fs << " " << range.sc << endl;
  }
  //cerr << y - 1 << endl;
  return in_range(y - 1, range.fs, range.sc);
}

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  int sy, sx;
  cin >> sy >> sx;
  string s, t;
  cin >> s >> t;

  bool in = true;
  in &= solve(h, sy, s, t);

  rep(i, n) {
    s[i] = change_letter(s[i]);
    t[i] = change_letter(t[i]);
  }
  in &= solve(w, sx, s, t);

  cout << (in ? "YES" : "NO") << endl;
}


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

int main() {

  double a, b, C;

  std::cin >> a >> b >> C;
  
  double pi = 3.141592653689793238462643383279;
  double S = a*b*sin(C*2*pi/360)/2;
  double c = sqrt(a*a+b*b-2*a*b*cos(C*2*pi/360));

  printf("%.10lf\n", S);
  printf("%.10lf\n", a+b+c);
  printf("%.10lf\n", S*2/a);
  
  return 0;
}

Measured memory_bytes: 1232
def count(k, cycle):
    k += 1
    tans = (k // cycle) * (cycle // 2)
    res = k % cycle
    if res >= cycle // 2:
        tans += res % (cycle // 2)
    return tans

def solve(A, B):
    cycle = 2
    ans = ""
    for _ in range(40):
        acount = count(A - 1, cycle)
        bcount = count(B, cycle)
        ans = str((bcount - acount) % 2) + ans
        cycle *= 2
    return int(ans, base=2)

if __name__ == "__main__":
    A, B = tuple(map(int, input().split(" ")))
    print(solve(A, B))

Measured memory_bytes: 3064
def get_list(str):
    str_list = str.split(" ")
    result_list = []
    for str in str_list:
        result_list.append(int(str))
    return result_list

n = input()
a_str = input()
b_str = input()
c_str = input()
a_list = get_list(a_str)
b_list = get_list(b_str)
c_list = get_list(c_str)

pre_index = -100
result = 0
for i in range(len(a_list)):
    index = a_list[i] - 1
    result += b_list[index]
    if pre_index+1 == index:
        result += c_list[pre_index]
    pre_index = index

print(result)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <numeric>
#include <queue>
#include <sstream>
#include <set>
using namespace std;



int main(){
    int sx, sy ,tx, ty ;
    cin >> sx >> sy >> tx >> ty ;
    int dx = tx -sx ;
    int dy = ty - sy ;
    for (size_t i = 0; i < tx - sx; i++)
    {
        cout << 'R' ;
    }
    for (size_t i = 0; i < ty - sy; i++)
    {
        cout << 'U' ;
    }
    for (size_t i = 0; i < dx ; i++)
    {
        cout << 'L' ;
    }
    for (size_t i = 0; i < dy + 1; i++)
    {
        cout << 'D' ;
    }
    for (size_t i = 0; i < dx + 1; i++)
    {
        cout << 'R' ;
    }
    for (size_t i = 0; i < dy + 1; i++)
    {
        cout << 'U' ;
    }
    cout << "LU" ;
    for (size_t i = 0; i < dx +1; i++)
    {
        cout << 'L' ;
    }
    for (size_t i = 0; i < dy + 1; i++)
    {
        cout << 'D' ;
    }
    cout << 'R' << endl ;
    
    
    
    
        
}


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

int main(){
  int tmp;
  vector<int> v(101,0);
    
  while(cin>>tmp){
    ++v[tmp];
  }

  int max_=0;

  for(int i=0;i<101;++i)
    max_ = max(max_,v[i]);

  for(int i=0;i<101;++i){
    if(v[i]==max_)
      cout<<i<<endl;
  }
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    s += s;
    if (s.find(t) != string::npos) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


template<class Type>
Type solve(Type res = Type()){
    int K; cin >> K;
    res = K/2 * (K-(K/2));
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //test();
    //solve<ll>();
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <sstream>
#include <vector>
#include <stdio.h>
#define ll              long long
#define fr(i,j,p)       for(int i=j; i<p ;i++)
#define frr(i,j,p)      for(int i=j; i>=p ;i--)
#define PI              3.14159265358979323846
#define print(m)        std::cout << std::fixed << std::setprecision(11) << m <<endl;
#define mkp             make_pair
#define pb              push_back
#define M               32
#define lbindex(a,x)    (int)(lower_bound(a.begin(), a.end(),x)-a.begin());
#define upindex(a,x)    (int)(upper_bound(a.begin(), a.end(),x)-a.begin());
#define all(a)          (a).begin(),(a).end()
#define mem(b,a,n)      memset(b,a,sizeof(b[0])*n);
#define meme(b,a,n,m)   memset(b,a,sizeof(b[0][0])*n*m);
#define ff              first
#define ss              second
#define endl            '\n'

//ll md=1000000007;
//ll mdd=998244353;

using namespace std;

typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);  cout.tie(NULL);
    int h,w,q,cnt=0;    cin>>h>>w>>q;
    char ch[h][w],ch1[h][w];
    fr(i,0,h)
    {
        fr(j,0,w)
        {
            cin>>ch[i][j];
            ch1[i][j]=ch[i][j];
        }
    }
    fr(i,0,pow(2,h))
    {
        int x=i,b[6];
        fr(j,0,6)
        {
            b[j]=x%2;   x/=2;
        }
        fr(j,0,pow(2,w))
        {
            int x1=j,a[6];
            fr(j1,0,6)
            {
                a[j1]=x1%2;   x1/=2;
            }
            fr(k,0,h)
            {
                fr(l,0,w)
                {
                    if(b[k]==1 || a[l]==1)  ch1[k][l]='r';
                }
            }
            int c=0;
            fr(k,0,h)
            {
                fr(l,0,w)
                {
                    if(ch1[k][l]=='#')  c++;
                    ch1[k][l]=ch[k][l];
                }
            }
            if(c==q)    cnt++;
        }
    }
    cout<<cnt;
    return 0;

}


Measured memory_bytes: 4112
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
   ll j=a*c-b;
    cout<<j<<spc;
    for(ll i=1;i<10;i++){
        j=a*j-b;
        cout<<j<<endl;

    }
return 0;
}


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if((a==b && a!=c) || (a==c && a!=b) || (b==c && a!=b)){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;		
	return 0;
}


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

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    int n; string s;
    cin >> n >> s;
    int cnt = 0;
    string k = s;
    sort(all(k));
    for(int i = 0; i < n; i++){
        if(s[i] != k[i])    cnt++;
    }
    cout << cnt/2 << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,ans=0,w,m=10000000;
  cin >> n;
  rep(i,n) {
    cin >> w;
    m=min(w,m);
    if(m>=w)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,bo=0;
    string n;
    cin>>n;
    for(int i=0;i<n.length();i++)
    {
        if(n[i]=='C'&&bo==0) bo++;
        if(bo==1&&n[i]=='F')
        {
            cout<<"Yes\n"; 
            return 0;
         } 
    }
    cout<<"No\n";
    return 0;
 } 

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	vi dp(n + 1, 0);
	REP(i, n) {
		dp[v[i]] = max(dp[v[i]], dp[v[i] - 1]+1);
	}
	cout << n - *max_element(ALL(dp)) << endl;
}


Measured memory_bytes: 1792
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

struct Mod {
	static ll BASE;
	ll value = 0;
	static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
	Mod(ll value)
	: value(residue(value)) {}
	Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
	void operator+=(const Mod& rhs) { *this = *this + rhs; }
	Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
	void operator-=(const Mod& rhs) { *this = *this - rhs; }
	Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
	void operator*=(const Mod& rhs) { *this = *this * rhs; }
};
ll Mod::BASE = 1000000007;

int main() {
	ll H, W, K;
	cin >> H >> W >> K;
	K--;
	vector<Mod> row_pats(W+1, 1);
	for (ll n = 2; n <= W; n++) {
		row_pats[n] = row_pats[n-1] + row_pats[n-2];
	}
	auto dp = make_vec_nd((Mod)0, H+1, W);
	for (ll h = 0; h <= H; h++) {
		for (ll w = 0; w < W; w++) {
			if (h == 0) {
				if (w == 0) {
					dp[h][w] = 1;
				} else {
					dp[h][w] = 0;
				}
			} else {
				dp[h][w] = dp[h-1][w] * row_pats[w] * row_pats[W-w-1];
				if (w >= 1) {
					dp[h][w] += dp[h-1][w-1] * row_pats[w-1] * row_pats[W-w-1];
				}
				if (w < W-1) {
					dp[h][w] += dp[h-1][w+1] * row_pats[w] * row_pats[W-w-2];
				}
			}
		}
	}
	cout << dp[H][K].value << endl;
}


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

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        int x[105];
        for(int i=0;i<n;i++)
            scanf("%d",&x[i]);
        sort(x,x+n);
        printf("%d\n",x[n-1]-x[0]);
    }
    return 0;
}


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

int main() {
  int alice, bob;

  cin >> alice >> bob;

  if (alice == bob) {
    cout << "Draw" << endl;
  }
  else if (alice == 1)
  {
    cout << "Alice" << endl;
  }
  else if (bob == 1)
  {
    cout << "Bob" << endl;
  }
  else if (alice > bob)
  {
    cout << "Alice" << endl;
  }
  else if (alice < bob)
  {
    cout << "Bob" << endl;
  }
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	ll n;
  cin >> n;
  
 ll c = 1,d = 1,e = 1;
  froop1(0,n){
    c *= 8;
    c %= 1000000007;
    d *= 9;
    d %= 1000000007;
    e *= 10;
    e %= 1000000007;
  }
  
  ll ans = (e - d - d + c ) % 1000000007;
  ans = (ans + 1000000007) % 1000000007;
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
while(cin>>n,n){
rep(i,n){
int a,b,c;
cin>>a>>b>>c;
if((a==100||b==100||c==100)||(a+b)/2>=90||a+b+c>=240)cout<<'A'<<endl;
else if(a+b+c>=210||(a+b+c>=150&&(a>=80||b>=80)))cout<<'B'<<endl;
else cout<<'C'<<endl;
}
}
}

Measured memory_bytes: 1152
// AOJ 2905: Colorful Drink
// 2019.2.23 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void ins(char *s)
{
	do *s = gc();
	while (*s++ > ' ');
	*(s - 1) = 0;
}


// 文字列のハッシュ関数
#define HASHSIZ 500009
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ + 2], *hashend = hash + HASHSIZ;

int insert(char *s, int id)
{
	unsigned long long i;
	int j;
	char *p;
	HASH *tp;

	i = 0, p = s;
	for (j = 0; *p && j < 12; j++) i = (i << 5) + *p++;
	tp = hash + (int)(i % HASHSIZ);
	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

int N, SZ;
char color[100005][22];
int idx[100005], hi[100005], *den[100005];

int cmp(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int main()
{
	int i, k, id, M;
	int *memo, sz;
	char buf[22];

	N = in();
	sz = 0, memo = malloc(N * 2 * sizeof(int));
	for (i = 0; i < N; i++) {
		ins(color[SZ]);
		if ((id = insert(color[SZ], SZ)) < 0) id = SZ++;
		hi[id]++;
		memo[sz++] = id, memo[sz++] = in();
	}

	for (id = 0; id < SZ; id++) if (hi[id])
		den[id] = malloc(hi[id] * sizeof(int));
	memset(hi, 0, SZ * sizeof(int));

	i = 0; while (i < sz) {
		id = memo[i++];
		den[id][hi[id]++] = memo[i++];
	}
	free(memo);

	for (id = 0; id < SZ; id++) qsort(den[id], hi[id], sizeof(int), cmp);

	k = 0, M = in();
	while (M--) {
		ins(buf);
		if ((id = insert(buf, SZ)) < 0) goto No;
		while (idx[id] < hi[id] && den[id][idx[id]] <= k) idx[id]++;
		if (idx[id] >= hi[id]) goto No;
		k = den[id][idx[id]++];
	}
	puts("Yes");
	return 0;
No:	puts("No");
	return 0;
}


Measured memory_bytes: 16428
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,m,a,b;
ll ret;
vi color;
vvi neigh;

int bfs(){
    deque<pi> q;
    q.eb(0,1);

    color[0] = 1;
    while(!q.empty()){
        pi tgt = q.front();
        q.pop_front();
        for(auto i: neigh[tgt.first]){
            if (color[i] == 0){
                q.eb(i,-tgt.second);
                color[i] = -tgt.second;
            } else if (color[i] == tgt.second){
                return 0;
            }
        }
    }
    return 1;
}

int main(){
    I(n);
    I(m);
    neigh.resize(n);
    color.resize(n,0);
    REP(i,m){
        I(a); I(b);
        a--; b--;
        neigh[a].pb(b);
        neigh[b].pb(a);
    }

    if(bfs()){
        ll whitenode = 0;
        ll blacknode = 0;
        ll crossedge = 0;
        REP(i,n){
            if (color[i] == 1){
                whitenode++;
                for (auto j: neigh[i]) crossedge += (color[j] == -1);
            } else {
                blacknode++;
                for (auto j: neigh[i]) crossedge += (color[j] == 1);
            }
        }
        crossedge /= 2;
        //cerr << whitenode << " " << blacknode << endl;
        ret = whitenode * blacknode - crossedge ;
   } else {
        ret = ll(n) * ll(n-1) / 2 - m;
   }
   cout << ret << endl;
}


Measured memory_bytes: 6272
#include<iostream>
using namespace std;
int main(){
	int n, cnt;	

	while(cin >> n){
		bool prime[n+1] = {false};
		prime[1] = true;
		
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] = true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}

Measured memory_bytes: 4036
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> par;
const int N=200010;
int ft[N],vis[N],tp[N],n,m,tot,s[5];
struct edge{int t,n;}E[N<<2];
void add(int x,int y){
	E[++tot]=(edge){y,ft[x]},ft[x]=tot;
}
int dfs(int u){
	if (!ft[u]) return 1;
	vis[u]=1;
	int tmp,ty=2;
	go(u) if (!vis[v]){
		tp[v]=tp[u]^1;
		tmp=dfs(v);
		if (tmp==3) ty=3;
	} else if (tp[v]==tp[u]) ty=3;
	return ty;
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	rep(i,1,n) if (!vis[i]) ++s[dfs(i)];
	LL s1=s[1],s2=s[2],s3=s[3],nn=n,ans;
	ans=(s2+s3)*(s2+s3)+s2*s2+nn*nn-(nn-s1)*(nn-s1);
	printf("%lld\n",ans);
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in(),M=in();
	vector<tuple<ll,ll,ll>> A(N);
	REP(i,N){
		std::get<0>(A[i]) = in<ll>();
		std::get<1>(A[i]) = in<ll>();
		std::get<2>(A[i]) = in<ll>();
	}
	auto func = [&](){
		ll esum[3]={0,0,0};
		for(ll i=0;i<M;i++){
			esum[0] += std::get<0>(A[i]);
			esum[1] += std::get<1>(A[i]);
			esum[2] += std::get<2>(A[i]);
		}
		return (abs(esum[0])+abs(esum[1])+abs(esum[2]));
	};
	vector<ll> sum(8,0);
	sort(ALL(A),[](tuple<ll,ll,ll>& lhs,tuple<ll,ll,ll>& rhs){return (std::get<0>(lhs)+std::get<1>(lhs)+std::get<2>(lhs))<(std::get<0>(rhs)+std::get<1>(rhs)+std::get<2>(rhs));});
	sum[0] = func();
	sort(ALL(A),[](tuple<ll,ll,ll>& lhs,tuple<ll,ll,ll>& rhs){return (std::get<0>(lhs)+std::get<1>(lhs)-std::get<2>(lhs))<(std::get<0>(rhs)+std::get<1>(rhs)-std::get<2>(rhs));});
	sum[1] = func();
	sort(ALL(A),[](tuple<ll,ll,ll>& lhs,tuple<ll,ll,ll>& rhs){return (std::get<0>(lhs)-std::get<1>(lhs)+std::get<2>(lhs))<(std::get<0>(rhs)-std::get<1>(rhs)+std::get<2>(rhs));});
	sum[2] = func();
	sort(ALL(A),[](tuple<ll,ll,ll>& lhs,tuple<ll,ll,ll>& rhs){return (std::get<0>(lhs)-std::get<1>(lhs)-std::get<2>(lhs))<(std::get<0>(rhs)-std::get<1>(rhs)-std::get<2>(rhs));});
	sum[3] = func();
	sort(ALL(A),[](tuple<ll,ll,ll>& lhs,tuple<ll,ll,ll>& rhs){return (-std::get<0>(lhs)+std::get<1>(lhs)+std::get<2>(lhs))<(-std::get<0>(rhs)+std::get<1>(rhs)+std::get<2>(rhs));});
	sum[4] = func();
	sort(ALL(A),[](tuple<ll,ll,ll>& lhs,tuple<ll,ll,ll>& rhs){return (-std::get<0>(lhs)+std::get<1>(lhs)-std::get<2>(lhs))<(-std::get<0>(rhs)+std::get<1>(rhs)-std::get<2>(rhs));});
	sum[5] = func();
	sort(ALL(A),[](tuple<ll,ll,ll>& lhs,tuple<ll,ll,ll>& rhs){return (-std::get<0>(lhs)-std::get<1>(lhs)+std::get<2>(lhs))<(-std::get<0>(rhs)-std::get<1>(rhs)+std::get<2>(rhs));});
	sum[6] = func();
	sort(ALL(A),[](tuple<ll,ll,ll>& lhs,tuple<ll,ll,ll>& rhs){return (-std::get<0>(lhs)-std::get<1>(lhs)-std::get<2>(lhs))<(-std::get<0>(rhs)-std::get<1>(rhs)-std::get<2>(rhs));});
	sum[7] = func();

	cout << *max_element(ALL(sum)) << endl;
	return 0;
}


Measured memory_bytes: 256
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
N=int(a[0])
A=int(a[1])
B=int(a[2])
X=min(A,B)
if A+B>N:
    Y=A+B-N
else:
    Y=0
print(X,Y)


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

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

	bool flag = false;

	while (A<=B) {
		if (A%K == 0) {
			flag = true;
			break;
		}
		A++;
	}
	if (flag) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
import java.util.*;

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

    long X = sc.nextLong();
    long Y = sc.nextLong();

    int count = 1;
    long tmp_x = X;

    while (true) {
      if (tmp_x * 2 > Y) {
        break;
      } else {
        tmp_x = tmp_x * 2;
        count++;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
using namespace std;
    
int main() {

    long long n,x,m; cin >> n >> x >> m;
    vector<long long> id(m,-1);
    vector<long long> ans;
    long long res;
    long long j = 0;
    long long len =0;
    while (id[x] == -1)
    {
        id[x] = len;
        ans.push_back(x);
        x = (x*x)%m;
        len++;
        j++;
    }
    long long loop; loop = len - id[x];
    long long count; count = (n-id[x])/loop;
    long long value=0;
    for(long long i = id[x] ; i < len ; i++){
        value += ans[i];
    }

////////////////ここまではできてるはず


    res = 0;
    if (n < len)
    {
        res = 0;
        for (long long i = 0; i < n; i++)
        {
            res += ans[i];
        }
        
    }
    else
    {
        for (long long i = 0; i < id[x]; i++)
        {
            res += ans[i];
        }
        res = res + count * value;
        long long amari = (n-id[x])%loop + id[x];
        for (long long i = id[x]; i < amari; i++)
        {
            res += ans[i];
        } 
    }
    



    
    cout << res << endl;
    

return 0;

}

Measured memory_bytes: 4560
N,K=map(int,input().split())
*A,=map(int,input().split())

point=[0]*N
count_X=0
count_Y=0
i=0
while point[i]!=3:
    if point[i]<2:
        count_X+=1
    point[i]+=1
    i=A[i]-1
    if point[i]>1:
        count_Y+=1
count_Y-=1

if K>=count_X:
    Z=count_X+(K-count_X)%count_Y
else:
    Z=K

i=0
ans=1
while i<Z:
    ans=A[ans-1]
    i+=1

print(ans)

Measured memory_bytes: 32300
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define out(i) cout<<i<<endl;

signed main(){
  str s;
  int k;
  cin>>s>>k;
  rep(i,s.length()){
    if(s[i]=='1'){
      if(k-1==i){
        cout<<1<<endl;
        return 0;
      }
    }
    else {
      cout<<s[i]<<endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input() for _ in range(h)]

dpl = [[1] * w for _ in range(h)]
dpr = [[1] * w for _ in range(h)]
dpu = [[1] * w for _ in range(h)]
dpd = [[1] * w for _ in range(h)]

for i, si in enumerate(s):
    for j, sij in enumerate(si):
        if sij == '#':
            dpl[i][j], dpu[i][j] = 0, 0
        elif sij == '.':
            if j - 1 >= 0:
                dpl[i][j] = dpl[i][j - 1] + 1
            if i - 1 >= 0:
                dpu[i][j] = dpu[i - 1][j] + 1
for i, si in enumerate(s[::-1]):
    i = h - i - 1
    for j, sij in enumerate(si[::-1]):
        j = w - j - 1
        if sij == '#':
            dpr[i][j], dpd[i][j] = 0, 0
        elif sij == '.':
            if j + 1 < w:
                dpr[i][j] = dpr[i][j + 1] + 1
            if i + 1 < h:
                dpd[i][j] = dpd[i + 1][j] + 1

ans = 0
for i in range(h):
    for j in range(w):
        cnt = dpl[i][j] + dpr[i][j] + dpu[i][j] + dpd[i][j]
        ans = max(ans, cnt)
print(ans - 3)


Measured memory_bytes: 205716
# ABC129C - Typical Stairs
def main():
    N, M, *A = map(int, open(0).read().split())
    A = set(A)
    MOD = 10 ** 9 + 7
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in A else 0
    for i in range(2, N + 1):
        if i not in A:
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
    print(dp[-1])


if __name__ == "__main__":
    main()

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

int main(){
  int k, a, b;
  cin >> k;
  if(k % 2 == 0){
  a = k / 2;
  b = k / 2;
    cout << a * b;
  }
  else {
    a = k / 2 + 1;
    b = k / 2;
    cout << a * b;
  }
}
  

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
int main(){
  int N;
  cin >> N;
  int cnt = 0;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    while(a%2==0){
      a /= 2;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int n,t,a;
    scanf("%d%d%d",&n,&t,&a);
    int tmp[n],i;
    for(i=0;i<n;i++){
        scanf("%d",&tmp[i]);
        tmp[i]=abs(a*1000-(t*1000-(tmp[i]*6)));
    }
    int min=tmp[0];
    int ans=0;
    for(i=1;i<n;i++){
        if(min>tmp[i]){min=tmp[i];ans=i;}
    }
    printf("%d\n",ans+1);
    return 0;    
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

using ll = long long;
const ll INF = 1e18 + 1;


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

    ll n, m, k;
    cin >> n >> m >> k;

    vector<ll> a(n), b(m);

    ll ai = -1, bi = -1;

    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
        if (i > 0) {
            a[i] += a[i-1];
        }

        if (a[i] <= k) {
            ai = i;
        }
    }

    for (ll i = 0; i < m; ++i) {
        cin >> b[i];
        if (i > 0) {
            b[i] += b[i-1];
        }

        if (b[i] <= k) {
            bi = i;
        }
    }
    ll ans = max(ai+1, bi+1);

    ll idx = 0, tai = ai;

    for (ll i = tai; i >= 0; i--) {
        while(idx < m && b[idx] + a[i] <= k) {
            idx++;
        }
        ans = max(ans, i + 1  + idx);
    }

    idx = 0;
    ll tbi = bi;

    for (ll i = tbi; i >= 0; i--) {
        while(idx < n && a[idx] + b[i] <= k) {
            idx++;
        }
        ans = max(ans, i + 1 + idx);
    }

    cout << ans << endl;




}

Measured memory_bytes: 5996
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
 
#include <iostream>
#include <string>
 
#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>
 
#define PB push_back
#define MP make_pair
 
#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)
 
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
 
typedef pair<int, int> PII;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;
 
const int MOD = 1000000007;
const int INF = 1e9;
 
const double EPS = 1e-9;
const double PI = acos(-1.0);
 
LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
 
int N, A[200001];
 
int main() {
    cin >> N;
    REP (i, N) {
        cin >> A[i];
    }
    VI B(A, A + N);
    sort(ALL(B), greater<int>());
    REP (i, N) {
        if (A[i] == B[0]) {
            cout << B[1];
        }
        else {
            cout << B[0];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
struct point{
	double x,y;
	point(){}
	point(double _x,double _y){
		x=_x;y=_y;
	}
	point operator +(const point &b) const{
		return point(x+b.x,y+b.y);
	}
	point operator -(const point &b) const{
		return point(x-b.x,y-b.y);
	}
	double operator ^(const point &b) const{
		return (x*b.x)+(y*b.y);
	}
	double operator *(const point &b) const{
		return x*b.y-y*b.x;
	}
	point operator *(const double &b) const{
		return point(x*b,y*b);
	}
};
struct matrix{
	int xmax,xmin,ymax,ymin;
}a[2];
double len(point p){
	return (p.x*p.x+p.y*p.y);
}
int main(){
	point p0,p1,p2,p3;
	int q;
	cin>>q;
	while(q--){
		cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
		a[0].xmax=max(p0.x,p1.x);
		a[0].xmin=min(p0.x,p1.x);
		a[0].ymax=max(p0.y,p1.y);
		a[0].ymin=min(p0.y,p1.y);
		a[1].xmax=max(p2.x,p3.x);
		a[1].xmin=min(p2.x,p3.x);
		a[1].ymax=max(p2.y,p3.y);
		a[1].ymin=min(p2.y,p3.y);
		if(!(a[0].xmax<a[1].xmin || a[1].xmax<a[0].xmin || a[0].ymax<a[1].ymin || a[1].ymax<a[0].ymin)){
			if(((p1-p0)*(p2-p0))*((p1-p0)*(p3-p0))<=0 &&
			   ((p3-p2)*(p1-p2))*((p3-p2)*(p0-p2))<=0) puts("1");
			else puts("0");
		}
		else puts("0");
	}
	return 0;
}


Measured memory_bytes: 3224
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a;
        int[] order = new int[n];
        for(int i = 0; i < n; i ++){
            a = scanner.nextInt();
            order[a-1] = i+1;
        }
        for(int syusseki : order){
            System.out.println(syusseki);
        }
    }
}

Measured memory_bytes: 60440
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

template <typename Type>
struct print_endl : public unary_function < const Type&, void >
{
	void operator()(const Type& n)
	{
		cout << n << endl;
	}
};


int main()
{
	stack<int> s;

	vector<int> Ans;

	int temp;

	while (cin >> temp)
	{
		if (temp != 0)
		{
			s.push(temp);
		}
		else
		{
			Ans.push_back(s.top());

			s.pop();
		}
	}

	for_each(Ans.begin(), Ans.end(), print_endl<int>());

	return 0;
}

Measured memory_bytes: 1220
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self,x):
        if(self.parents[x] < 0):
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def size(self, x):
        return self.parents[ self.find(x) ] * -1

    def same(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)
        return (x_root == y_root)

    def union(self,x,y):
        x_root = self.find(x)
        y_root = self.find(y)
        if(x_root == y_root):
            return

        if( self.parents[x_root] <= self.parents[y_root] ):
            self.parents[x_root] += self.parents[y_root]
            self.parents[y_root] = x_root
        else:
            self.parents[y_root] += self.parents[x_root]
            self.parents[x_root] = y_root

    def members(self,x):
        root = self.find(x)
        ret = [ i for i in range(self.n) if self.find(i) == root ]
        return ret

    def roots(self):
        ret = [ i for i in range(self.n) if self.parents[i] < 0]
        return ret

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n,m = map(int,readline().split())
if(m==0):
    print(1)
    exit()

data = list(map(int,read().split()))
uf = UnionFind(n+1)

it = iter(data)
for a,b in zip(it,it):
    uf.union(a,b)

ans = min(uf.parents) * -1
print(ans)

Measured memory_bytes: 108460
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static byte h,w,c;
	static int max;
	static byte[][] panel;
	static byte[] v1={0,1,0,-1};
	static byte[] v2={1,0,-1,0};
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			h=cin.nextByte();
			w=cin.nextByte();
			c=cin.nextByte();
			max=-1;
			if(h+w+c==0)break;
			panel=new byte[h][w];
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					panel[i][j]=cin.nextByte();
				}
			}
			bt(0);
			System.out.println(max);
		}
	}
	static void bt(int depth){
		if(depth==4){
			if(panel[0][0]==c){
				max=Math.max(count(),max);
				return;
			}
			byte[][] cp = new byte[h][w];
			for(int k=0;k<h;k++){
				for(int j=0;j<w;j++){
					cp[k][j]=panel[k][j];
				}
			}
			int color=panel[0][0];
			Queue<byte[]> q=new LinkedList<byte[]>();
			q.add(new byte[]{0,0});
			while(!q.isEmpty()){
				byte[] aaa=q.poll();
				byte x=aaa[0];
				byte y=aaa[1];
				if(panel[x][y]!=color)continue;
				panel[x][y]=c;
				for(int j=0;j<4;j++){
					byte xx=(byte) (x+v1[j]);
					byte  yy=(byte) (y+v2[j]);
					if(xx<0||yy<0||xx>=h||yy>=w)continue;
					if(panel[xx][yy]!=color)continue;
					q.add(new byte[]{xx,yy});
				}
			}
			max=Math.max(count(),max);
			for(int k=0;k<h;k++){
				for(int j=0;j<w;j++){
					panel[k][j]=cp[k][j];
				}
			}
			return;
			
		}
		for(byte i=1;i<=6;i++){
			if(panel[0][0]==i)continue;
			byte[][] cp = new byte[h][w];
			for(int k=0;k<h;k++){
				for(int j=0;j<w;j++){
					cp[k][j]=panel[k][j];
				}
			}
			int color=panel[0][0];
//			int count=count();
			Queue<byte[]> q=new LinkedList<byte[]>();
			q.add(new byte[]{0,0});
			while(!q.isEmpty()){
				byte[] aaa=q.poll();
				byte x=aaa[0];
				byte y=aaa[1];
				if(panel[x][y]!=color)continue;
				panel[x][y]=i;
				for(int j=0;j<4;j++){
					byte xx=(byte) (x+v1[j]);
					byte  yy=(byte) (y+v2[j]);
					if(xx<0||yy<0||xx>=h||yy>=w)continue;
					if(panel[xx][yy]!=color)continue;
					q.add(new byte[]{xx,yy});
				}
			}
//			if(count!=count())
				bt(depth+1);
			for(int k=0;k<h;k++){
				for(int j=0;j<w;j++){
					panel[k][j]=cp[k][j];
				}
			}
			
		}
	}
	static int count(){
		int ans=0;
		byte[][] cp = new byte[h][w];
		for(int k=0;k<h;k++){
			for(int j=0;j<w;j++){
				cp[k][j]=panel[k][j];
			}
		}
		Queue<byte[]> q=new LinkedList<byte[]>();
		q.add(new byte[]{0,0});
		while(!q.isEmpty()){
			
			byte[] aaa=q.poll();
			byte x=aaa[0];
			byte y=aaa[1];
			if(cp[x][y]==-1)continue;
			cp[x][y]=-1;
			ans++;
			for(int j=0;j<4;j++){
				byte xx=(byte) (x+v1[j]);
				byte yy=(byte) (y+v2[j]);
				if(xx<0||yy<0||xx>=h||yy>=w)continue;
				if(cp[xx][yy]!=c)continue;
				q.add(new byte[]{xx,yy});
			}
		}
		return ans;
	}
}

Measured memory_bytes: 159828
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;

int main(){
    int N; cin >> N;
    vector <ll> a(N);
    ll ans = 0;
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
        ans += a.at(i);
    }
    ans -= N;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n, k;
  cin >> n >> k;
  int at  = -1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a == 1) at = i;
  }
  int l = at;
  int r = n - 1 - at;
  int result = l / (k - 1) + r / (k - 1);
  l %= k - 1;
  r %= k - 1;
  if (l + r > 0) {
    result += l + r <= k ? 1 : 2;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://agc002.contest.atcoder.jp/tasks/agc002_c>
問題文============================================================
 N 本のロープがあります。 ロープは 1 から N まで番号が振られています。 ロープ i の長さは ai です。
 
 最初、1≤i≤N−1 について、ロープ i の右端とロープ i+1 の左端が結ばれています。
 高橋君は次の操作を N−1 回行い、すべての結び目をほどこうとしています。
 
 ひと繋がりのロープのうち、長さの総和が L 以上のものをひとつ選ぶ。
 選んだひと繋がりのロープに結び目があれば、結び目のうちどれかひとつをほどく。
 
 高橋君は結び目をほどく順番を工夫し、すべての結び目をほどくことができるでしょうか？
 可能か判定し、可能ならば結び目をほどく順番をひとつ求めてください。

=================================================================

解説=============================================================

================================================================
*/

struct sec{
    ll l,r,len;
    sec(){}
    sec(ll l,ll r,ll len):l(l),r(r),len(len){}
};
void solve(){
    int N,L; cin >> N >> L;
    vector<int> a(N);
    for(auto &in:a) cin >> in;
    for(int i = 0; i < N-1;i++){
        if(a[i] + a[i+1] >= L){
            cout << "Possible" << endl;
            for(int j = 1; j <= i;j++) cout << j << endl;
            for(int j = N - 1; j > i; j--) cout << j << endl;
            return;
        }
    }
    cout << "Impossible" << endl;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// THINK: INT vs LONG LONG?

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

    string s, t;
    cin >> s >> t;
    int T = t.size();
    int ans = 1e9;
    for (int i = 0; i + T <= (int) s.size(); ++i){
        string cur = s.substr(i, T);
        int cnt = 0;
        for (int j = 0; j < T; ++j){
            if (t[j] != cur[j])
                cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3648
import java.io.IOException;
import java.util.Scanner;

public class Main {
	private static int diceNum;
	private static int sideNum;
	private static int cutback;

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			diceNum = scanner.nextInt();
			sideNum = scanner.nextInt();
			cutback = scanner.nextInt();
			if (diceNum == 0) {
				scanner.close();
				break;
			}
			int dfs = dfs(0, 0);
			double ans = dfs / Math.pow(sideNum, diceNum);
			System.out.println(ans);

		}

	}

	static int dfs(int sum, int depth) {
		if (depth < diceNum) {
			int dfs = 0;
			for (int i = 1; i <= sideNum; i++) {
				dfs += dfs(sum + i, depth + 1);
			}
			return dfs;
		} else {
			if (sum - cutback < 1) {
				return 1;
			} else {
				return sum - cutback;
			}
		}
	}
}

Measured memory_bytes: 19980
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int n;
int a[100010];
int x;

int main() 
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&x);
		a[x] = i;
	}
	for(int j=1; j<=n; j++)
	{
		printf("%d",a[j]);
		if(j != n)
		{
			printf(" ");
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  vector<int>ans(n);
  for(int i=n-1;i>=0;i--){
    int idx=-1;
    for(int j=i;j>=0;j--){
      if(a[j]==j+1){
        idx=j;
        break;
      }
    }
    if(idx==-1){
      puts("-1");
      return 0;
    }
    ans[i]=idx+1;
    a.erase(a.begin()+idx);
  }
  for(int i=0;i<n;i++)printf("%d\n",ans[i]);
  return 0;
}


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
ab = []
cd = []
for i in range(n):
  ab.append([int(j) for j in input().split()])
for i in range(m):
  cd.append([int(j) for j in input().split()])
for ni in range(n):
  d = []
  for mi in range(m):
    d.append(abs(ab[ni][0]-cd[mi][0]) + abs(ab[ni][1]-cd[mi][1]))
  print(d.index(min(d))+1)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
Amax = max(A)
Amin = min(A)
outlis=[];

if Amin > 0:
    print(N-1)
    for i in range(N-1):
        print(i+1,i+2) 
elif Amax < 0:
    print(N-1)
    for i in range(N-1):
        print(N-i,N-i-1)
else:
    print(2*N-2)
    if abs(Amax) > abs(Amin):
        maxi = A.index(Amax)+1
        for i in range(N):
            if i == maxi-1:
                pass
            else:
                print(maxi,i+1)
        for i in range(N-1):
            print(i+1,i+2)
    else:
        mini = A.index(Amin)+1
        for i in range(N):
            if i == mini-1:
                pass
            else:
                print(mini,i+1)
        for i in range(N-1):
            print(N-i,N-i-1)


Measured memory_bytes: 38256
n, w = map(int, input().split())
INF = float('inf')
P = []
for _ in range(n):
    iw, iv = map(int, input().split())
    P.append([iw, iv])

dp = [[INF for i in range(10 ** 5 + 1)] for j in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    for j in range(10 ** 5 + 1):
        if j - P[i - 1][1] >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - P[i - 1][1]] + P[i - 1][0])
        else:
            dp[i][j] = dp[i - 1][j]

ans = 10 ** 5
while dp[n][ans] > w:
    ans -= 1
print(ans)


Measured memory_bytes: 243208
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void Solve(){
	string s;	cin >> s;
	if(s == "ABC"){
		cout << "ARC" << endl;
	}else{
		cout << "ABC" << endl;
	}
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	Solve();
	return 0;
}

Measured memory_bytes: 3596