akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
void upd(pii& p, int x){
    p.ff = min(p.ff, x);
    p.ss = max(p.ss, x);
}
pii v, h, u, d, l, r;
lld calc(int t){
    if(t<0)return LLONG_MAX;
    //cout << t << endl;
    int L = min({r.ff+t, h.ff, l.ff-t}),
        R = max({r.ss+t, h.ss, l.ss-t}),
        U = max({u.ss+t, v.ss, d.ss-t}),
        D = min({u.ff+t, v.ff, d.ff-t});
    return (lld)(R-L)*(U-D);
}
signed main(){
    int n;
    v = h = u = d = l = r = {5e8, -5e8};
    cin >> n;
    for(int i = 0; i < n; i++){
        int a, b; char c;
        cin >> a >> b >> c;a*=2;b*=2;
        switch (c) {
            case 'L': upd(v, b);upd(l, a);break;
            case 'R': upd(v, b);upd(r, a);break;
            case 'U': upd(h, a);upd(u, b);break;
            case 'D': upd(h, a);upd(d, b);break;
        }
    }
    //cout <<v<<h<<u<<d<<l<<r<<endl;
    cout << setprecision(20) <<
        min({ calc(d.ss-v.ss), calc(v.ss-u.ss), calc((d.ss-u.ss)/2),
              calc(d.ff-v.ff), calc(v.ff-u.ff), calc((d.ff-u.ff)/2),
              calc(l.ss-h.ss), calc(h.ss-r.ss), calc((l.ss-r.ss)/2),
              calc(l.ff-h.ff), calc(h.ff-r.ff), calc((l.ff-r.ff)/2),
              calc(0) })/4.0 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, k; cin >> n >> k;
    map<ll, ll> mp;

    rep(i, n){
        ll a; cin >> a;
        mp[a]++;
    }

    vector<pair<ll, ll>> ans;
    for(auto p: mp) ans.push_back(make_pair(p.second, p.first));
    sort(all(ans), greater<pair<ll, ll>>());

    ll sum = 0;
    for(ll i=k; i<ans.size(); i++){
        sum += ans[i].first;
    }

    cout << sum << endl;

}

Measured memory_bytes: 17776
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;


public  class Main 
{

	   
	   static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 

  

	  // Complete the hurdleRace function below.
//    public static void solve() {
//    	FastReader s=new FastReader();

   
    public static void main(String[] args) throws IOException {
    	FastReader s=new FastReader();
    	int n = s.nextInt();
    	int a = s.nextInt();
    	int[] ar = new int[a];
    	int sum=0;
    	for(int i=0;i<a;i++) {
    		ar[i] = s.nextInt();
    		sum+=ar[i];
    	}
    	if(sum>=n)System.out.println("Yes");
    	else System.out.println("No");
    	
    	
    	
    	
    }	
}



Measured memory_bytes: 43416
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

string S;
int ans;

signed main(){

    in(S);
    for(auto c:S) if(c=='1') ans++;

    out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int n,a,b,c;
    string A,B,C;
      cin >> a>>b>>c;
  if(c-(a-b)>0){
     cout<<c-(a-b);
  }else{
   cout<<0;
  }
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j] and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                ans += 1

print(ans)

Measured memory_bytes: 73848
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 N;
  cin >> N;
  vector<i64> p(N);
  for(int i = 0;i < N;i++) cin >> p[i];
  auto f = []( vector<i64> p ) -> i64 {
    i64 sum = 0;
    for(int i = 0;i + 1 < p.size();i++) {
      p[i] = max(p[i], 0ll);
      sum += p[i] * 2;
      p[i + 1] -= p[i];
    }
    p.back() = max(p.back(), 0ll);
    sum += p.back();
    return sum;
  };
  i64 ans = f(p);
  for(int i = 0;i <= 3;i++) {
    auto q = p;
    q[0] -= i;
    ans = min(ans, i + f(q));
  }
  cout << ans << endl;
}



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

int main(){
  string a;
  cin >> a;
  int n;
  n = a.size();
  rep(i,n) {
    cout << "x" ;
  }
  cout << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>

#define TIMES 5

int main(void) {
  int64_t N, X[TIMES];
  scanf("%ld", &N);
  for(int i = 0; i < TIMES; i++) {
    scanf("%ld", &X[i]);
  }

  int64_t T[TIMES];
  int64_t T_MAX = 0;
  for(int i = 0; i < TIMES; i++) {
    T[i] = (N + X[i] - 1) / X[i];
    if(T_MAX < T[i]) {
      T_MAX = T[i];
    }
  }

  int64_t SUM = T_MAX;
  SUM += (TIMES - 1);

  printf("%ld\n", SUM);
  return 0;
}


Measured memory_bytes: 128
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,t,n,j,ans=0;
    string s;
    cin>>n;
    ll a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        a[i]-=(i+1);
    }
    sort(a,a+n);
    ll subt=(n%2==0)?a[n/2-1]:a[n/2];
    for(i=0; i<n; i++)
    {
        ans+=abs(a[i]-subt);
    }


    cout<<ans<<endl;

    return 0;
}





Measured memory_bytes: 5224
while 1:
    C = list(map(int,input().split()))
    if(C == [0]):
        break
    ans = [False]*22
    ans[0] = True
    for c in C:
        l = [min(c,10)]
        if(c == 1):
            l.append(11)
        ans_ = [False]*22
        for i in range(21,-1,-1):
            if not ans[i]:
                continue
            for a in l:
                if i+a > 21:
                    continue
                ans_[i+a] = True
        ans = ans_
    A = 0
    for i in range(22):
        if not ans[i]:
            continue
        A = max(A,i)
    print(A)



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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
//dfsによる解法
string s;
char ope[4];
bool flag=false;
void dfs(int,int);
int main(){
    cin>>s;
    int sum=s[0]-'0';
    dfs(0,sum);
}
void dfs(int depth,int sum){
    //printf("depth=%d,sum=%d\n",depth,sum);
    if(depth==3){
        if(sum==7&&!flag){
            cout<<s[0];
            for(int i=1;i<=3;i++){
                cout<<ope[i]<<s[i];
            }
            cout<<"=7"<<endl;
            flag=true;
            return;
        }
        return;
    }
    //+ or -を試す
    ope[depth+1]='+';
    dfs(depth+1,sum+s[depth+1]-'0');
    ope[depth+1]='-';
    dfs(depth+1,sum-(s[depth+1]-'0'));
}

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

using namespace std;

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

    vector<uint32_t> Li(N);

    for (size_t i = 0; i < N; ++i)
    {
        cin >> Li[i];
    }
    sort(Li.begin(), Li.end());

    uint32_t ans = 0;
    for (size_t i = 0; i < N; ++i)
    {
        uint32_t a = Li[i];
        for (size_t j = 0; j < i; ++j)
        {
            uint32_t b = Li[j];
            for (size_t k = 0; k < j; ++k)
            {
                uint32_t c = Li[k];
                if (a != c and b != c and a != b and c + b > a)
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define str string
#define vl vector<ll>
#define vs vector<string>

#define mapll map<ll,ll>
#define mapss map<string,string>
#define mapsl map<string,ll>
#define mapls map<ll,string>

#define pll pair<ll,ll>
#define pss pair<string,string>
#define psl pair<ll,string>
#define pls pair<string,ll>

#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll> ,greater<ll>>

#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
const ll mod=1e9 + 7;


ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}



signed main() 
{
    fast_cin();
    ll n;
    cin>>n;
    ll arr1[n];
    ll arr2[n];
    For(i,0,n)
    {
        cin>>arr1[i];
    }

    For(i,0,n)
    {
        cin>>arr2[i];
    }
    ll diff1=0;
    ll diff2=0;
    ll indexes=0;
    vector<pair<int,int>>v1;
    For(i,0,n)
    {
        if(arr1[i]>arr2[i])
        {
            v1.pb(mp(arr1[i]-arr2[i],i));
            diff1+=arr1[i]-arr2[i];
        }
        else if(arr1[i]<arr2[i])
        {
            diff2+=(arr2[i]-arr1[i]);
            indexes++;
        }
    }
    if(diff1<diff2)
        cout<<-1<<endl;
    else
    {
        sort(v1.begin(),v1.end());
        ll index=v1.size()-1;
        while(index>=0 and diff2>0)
        {
            diff2-=v1[index].fi;
            indexes++;
            index--;
        }
        cout<<indexes<<endl;

    }
}

Measured memory_bytes: 2428
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const ll MOD = 1000000007;

//#define __DBG__


void solve(void){

  string S;
  
  cin >> S;
  
  
	if(S=="AAA" || S=="BBB"){
      cout << "No" << endl;
    }
  else
  {
    cout << "Yes" << endl;
  }

  return;
}

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



    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}



Measured memory_bytes: 256
a = int(input())
b = int(input())

if a == 1:
  if b == 2:
    print(3)
  else:
    print(2)

if a == 2:
  if b == 1:
    print(3)
  else:
    print(1)

if a == 3:
  if b == 1:
    print(2)
  else:
    print(1)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(int(1e9))
mod = int((1e9) + 7)

S = input()
N = len(S)

mem = [[0] * 4 for _ in range(N)]
used = [[0] * 4 for _ in range(N)]
ch = ['A', 'B', 'C']

def dfs(idx, num):
    
    if idx == N:
        return (num == 3)
    
    if used[idx][num]:
        return mem[idx][num]
    used[idx][num] = 1

    a, b = (0, 0);
    if S[idx] == '?':
        if(num < 3):
            a = dfs(idx + 1, num + 1)    
        b = 3 * dfs(idx + 1, num)
    else:
        if num < 3 and S[idx] == ch[num]:
            a = dfs(idx + 1, num + 1)
        b = dfs(idx + 1, num)
        
    res = (a + b) % mod
    mem[idx][num] = res
    return res

ans = dfs(0, 0)
print (ans)
    


Measured memory_bytes: 122216
n=int(input())
a=list(map(int,input().split()))

a.sort()
amax=max(a)
dp=[True]*(amax+1)

import collections
c = collections.Counter(a)

d=[]
for ck,cv in c.items():
    if cv>=2:
       d.append(ck) 
dset=set(d)
    
aa=set()
for ai in a:
    if dp[ai]:
        aa.add(ai)
        for aj in range(ai*2,amax+1,ai):
            dp[aj]=False

aa=aa-dset    
print(len(aa))


Measured memory_bytes: 156752
n=int(input())

sum=0
for i in range(n+1):
  sum=sum+i

fizzbuzz=0
m=n//15
for i in range(m+1):
  fizzbuzz=fizzbuzz+15*i

fizz=0
l=n//3
for i in range(l+1):
  fizz=fizz+3*i

buzz=0
o=n//5
for i in range(o+1):
  buzz=buzz+5*i

print(sum-fizz-buzz+fizzbuzz)

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

const int N = 100 + 5;
const int M = 1e5 + 5;
int n, we;
ll w[N], v[N];
ll dp[N][M];

ll solve(int idx, int val) {
    if (val == 0)
        return 0;
    if (idx == n)
        return 1e17;
    if (dp[idx][val] != -1)
        return dp[idx][val];
    return dp[idx][val] = min(solve(idx + 1, val), w[idx] + solve(idx + 1, val - v[idx]));
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> we;
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    memset(dp, -1, sizeof dp);
    for (int i = 1e5; i >= 1; i--) {
        if (solve(0, i) <= we)
            return cout << i, 0;
    }
    return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string a, b, c;
cin >> a >> b >> c;
char d, e, f;
d = a.at(0);
e = b.at(0);
f = c.at(0);
d = toupper(d);
e = toupper(e);
f = toupper(f);
cout << d << e << f << endl;
}

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

int main() {
  ll X;cin >> X;
  ll y = 0;
  ll m = 100;
  while (m < X) {
    m += m / 100;
    y++;
  }
  cout << y << endl;
}

Measured memory_bytes: 3632
s = list(map(int, input().split()))
s.sort()
if((3 * s[2]) % 2 == sum(s) % 2):
  print(((2 * s[2]) - s[0] - s[1]) // 2) 
else:
  print(((2 * s[2]+1) - s[0] - s[1]) // 2 + 1)

Measured memory_bytes: 3060
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[0] * 2501 for _ in range(51)]

dp[0][0] = 1
for i in range(N):
    x = X[i]
    for j in range(i, -1, -1):
        for k in range(2501):
            if k < x:
                continue
            dp[j + 1][k] += dp[j][k - x]
ans = 0
for i in range(1, 51):
    ans += dp[i][i * A]
print(ans)



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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    unordered_map<string, int> mp;
    for(int i=0;i<n;i++){
        string str; cin >> str;
        mp[str]++;
    }
    int max_n = 0;
    for(auto m: mp){
        // cout << m.first << " " << m.second << endl;
        max_n = max(max_n, m.second);
    }
    vector<string> ans;
    for(auto m: mp){
        if(m.second == max_n){
            ans.push_back(m.first);
        }
    }
    sort(ans.begin(), ans.end());
    for(string a: ans) cout << a << endl;
}

Measured memory_bytes: 25284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
vector<int> v;
int turn(int x,int y){
    if(x>=y) return y;
    else return x;
}
int main(){
    cin>>n;
    int x; cin>>x;
    v.push_back(x);
    int last=x;
    if(n==2){
        cout<<2*x<<endl; return 0;
    }
    for(int i=2;i<n;i++){
         cin>>x;
         v.push_back(turn(last,x));
         last=x;
         if(i==n-1){
            v.push_back(x);
         }
    }
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=v[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
int s[105];
int main()
{
    int n;
    while (scanf ("%d",&n) != EOF)
    {
        for (int i = 0;i < n;i++)
            scanf ("%d",&s[i]);
        int cnt = 0;
        /*for (int i = 0;i < n-1;i++)
        {
            int key = s[i];
            for (int j = i+1;j < n;j++)
            {
                if (key > s[j])
                {
                    swap(s[j],s[j-1]);
                    cnt++;
                }
            }
        }*/
        for (int i = 1;i < n;i++)
        {
            for (int j = 1;j < n;j++)
            {
                if (s[j-1] > s[j])
                {
                    swap(s[j-1],s[j]);
                    cnt++;
                }

            }
        }
        for (int i = 0;i < n;i++)
        {
            if (i == n-1)
                printf ("%d\n",s[n-1]);
            else
                printf ("%d ",s[i]);
        }
        printf ("%d\n",cnt);
    }
    return 0;
}



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

int main(){
    string s;
    cin >> s ;
    if(s == "ABC") cout << "ARC" <<endl;
    else cout << "ABC" << endl;


    return 0;
}

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

class UnionFind {
public:
	vector <int> par;  // 各元の親を表す配列
	vector <int> rank; // 素集合のランクを表す配列(0 で初期化)

	UnionFind(int n) : par(n), rank(n) {
		init(n);
	}

	void init(int n) {
		par.resize(n); for (int i = 0; i < n; ++i) par[i] = i;
		rank.assign(n, 0);
	}

	int root(int x) {
		if (par[x] == x) return x;
		else return root(par[x]);
	}

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else { // rank[y] < rank[x]
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
		return true;
	}

	bool isSame(int x, int y) { // 連結判定
		return root(x) == root(y);
	}

	int getRank(int x) {        // 素集合のランク
		return rank[root(x)];
	}
};

int main() {

	int n, m; cin >> n >> m;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}
	UnionFind tree(n);

	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		x--;
		y--;
		tree.unite(x, y);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (tree.isSame(i, p[i])) ans++;
	}	
	cout << ans << endl;
	return 0;
}

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

int r; cin>>r;
  int rr;
  rr=2*r;
  
  double ans;
  ans=rr*3.1415926535;
  cout<<ans<<endl;
  

}


Measured memory_bytes: 3792
h, w = map(int, input().split())
l = []

for i in range(h-1, -1, -1):
    s = list(input())
    if s!=["."]*w:
        l.append(s)

for j in range(w-1, -1, -1):
    cnt = 0
    for k in range(len(l)):
        if l[k][j]==".":
            cnt += 1
    if cnt ==len(l):
        for k in range(len(l)):
            l[k].pop(j)

for i in range(len(l)):
    print("".join(l[i]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,s,len;
inline bool check(ll x,ll tmp){
	if(tmp==1)return true;
	ll cnt=0;
	while(x)cnt+=x%tmp,x/=tmp;
	return cnt==s;
}
int main(){
	cin>>n>>s,len=(ll)sqrt(n)+1;
	for(ll i=2;i<=len;++i)if(check(n,i)){cout<<i;return 0;}
	if(n<=s){cout<<(n<s?-1:n+1);return 0;}
	ll tmp=n-s,ttmp=tmp/len+1;
	for(int i=ttmp;i;--i)if((tmp%i==0)&&(s-i>=0)&&(s-i<tmp/i+1&&i<tmp/i+1)){cout<<tmp/i+1;return 0;}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 256
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int col[100005];
vector<int> v[100005];
int n,m;
int __d,_col;
int use[100005];
int _v[100005],d[100005],c[100005];
inline void dfs(int x,int d){
	if(use[x]>=d) return;
	if(!col[x]) col[x]=_col;
	use[x]=d;
	for(int i=0;i<v[x].size();i++){
		int e=v[x][i];
		if(d) dfs(e,d-1);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int i,j,q;
	cin>>n>>m;
    int x,y,z;
    for(i=1;i<=m;++i){
    	cin>>x>>y;
    	v[x].push_back(y);
    	v[y].push_back(x);
	}
	cin>>q;
	memset(use,-1,sizeof(use));
	for(j=1;j<=q;++j) cin>>_v[j]>>d[j]>>c[j];
	for(i=q;i;--i){
		_col=c[i];
		dfs(_v[i],d[i]);
	}
	for(i=1;i<=n;++i) cout<<col[i]<<endl;
	
	return 0;
}


Measured memory_bytes: 8440
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad


main :: IO ()
main = breads >>= main'
    where
        main' [n, m] = replicateM n breads >>= print . solve m 

solve :: Int -> [[Int]] -> Int 
solve m xs = maximum [calc (map f xs) | f <- mfs]
    where
        calc = sum . take m . sortBy (flip compare)
        mfs =
            [ (\[x, y, z] -> x + y + z)
            , (\[x, y, z] -> - x + y + z)
            , (\[x, y, z] -> x - y + z)
            , (\[x, y, z] -> - x - y + z)
            , (\[x, y, z] -> x + y - z)
            , (\[x, y, z] -> -x + y - z)
            , (\[x, y, z] -> x - y - z)
            , (\[x, y, z] -> - x - y - z)
            ]

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string s, t;
ll ans = 0;

int main() {
	cin >> s >> t;
	rep(i, sz(s)) {
		if (s[i] != t[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3888
x, y = (int(x) for x in input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if ((x in a) and (y in a)) or ((x in b) and (y in b)) or ((x in c) and(y in c)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
n = int(input())
V = list(map(int, input().split()))

V.sort(reverse=True)

for _ in range(n-1):
    v1 = V.pop(-1)
    v2 = V.pop(-1)
    v = (v1 + v2) / 2
    V.append(v)

print(V[0])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N, M, P;
    while(cin>>N>>M>>P&&N){
        vector<int> line(N);
        int sum = 0;
        foreach(i, line){
            cin>>i;
            sum+=i * 100;
        }
        --M;
        if(line[M]){
            cout << sum * (100-P) / 100 / line[M] << endl; 
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 2984
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> a;

bool comp(int i, int j) {
  return a[i] > a[j];
}


int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  a.reserve(N);
  vector<int> indices(N);
  for (int i = 0; i < N; ++i) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
    indices[i] = i;
  }

  sort(indices.begin(), indices.end(), comp);

  for (int i = 0; i < N; ++i) {
    if (i != indices[0]) {
      cout << a[indices[0]] << endl;
    } else {
      cout << a[indices[1]] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



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

	vector<ll> v(n);
	rep(i, 0, n) {
		cin >> v[i];
	}


	vector<ll> s;
	ll left = 0;
	ll right = k - 1;
	

	while (right <= n-1) {
		if (v[right] <= 0) {
			s.push_back(-v[left]);
		}
		else if (0 < v[right] && v[left] < 0) {
			s.push_back(min(2*(-v[left])+v[right],2*v[right]-v[left]));
		}
		else {
			s.push_back(v[right]);
		}
		left++; right++;
	}

	ll ans = inf;
	rep(i, 0, s.size()) {
		ans= min(ans, s[i]);
	}


	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr.begin(),arr.end());
	cout << (arr[n/2]-arr[n/2-1]) << endl;
}


Measured memory_bytes: 640
import collections 

n=int(input())
a=[]
for i in range(n):
    s=input()
    a.append(s)

b=collections.Counter(a) 
mx=max(b.values())
ans=[]

for word,counts in b.items():
    if counts==mx:
        ans.append(word)
        
ans=sorted(ans)
for i in ans:
    print(i)


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<(x)<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n;

    cin>>n;

    li a[n],b[n];

    f(i,0,n-1)
    {
        cin>>a[i]>>b[i];
    }

    sort(a,a+n);
    sort(b,b+n);

    li l,r;
    
    if(n&1)
    {
        l=a[n/2];
        r=b[n/2];
    }
    else
    {
        l=a[n/2-1]+a[n/2];
        r=b[n/2-1]+b[n/2];
    }

    cout<<r-l+1;
}

int main()
{    
    

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, ans = 0;
    string S;
    cin >> N >> S;
    for (int i = 0; i < N - 2; i++) {
        if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C'){
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n, m;
  cin >> n >> m;
  if (n == 1 && m == 1)
    cout << 1 << endl;
  else if (n == 1)
    cout << m - 2 << endl;
  else if (m == 1)
    cout << n - 2 << endl;
  else
    cout << (n - 2) * (m - 2) << endl;
}


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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    int N;
    cin >> N;
    vector<ll> H(1000000);
    rep(i,N){
        cin >> H[i];
    }
    bool ans = true;
    for(int i=N-1; i>0; i--){
        if(H[i-1]<=H[i]){
            continue;
        }else if(H[i-1]>H[i] && (H[i-1] - H[i])==1){
            H[i-1] = H[i-1] - 1;
            continue;
        }else{
            ans = false;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 8064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	int N, a;
	scanf("%d", &N);
	vector<int> v(N+1,0);
	int num = sqrt(N);
		for (int x = 1; x <= num; x++) for (int y = 1; y <= num; y++) for (int z = 1; z <= num; z++) {
			a = x * x + y * y + z * z + x * y + y * z + z * x;
			if (a > N)break;
			v[a]++;
		}
		for (int i = 1; i <= N; i++) {
			printf("%d\n", v[i]);
		}
}


Measured memory_bytes: 3160
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  p=LI()
  q=LI()

  a=[i+1 for i in range(n)]
  ansa=0
  ansb=0
  for j,x in enumerate(itertools.permutations(a)):
    f1=True
    f2=True
    for i in range(n):
      if x[i]!=p[i]:
        f1=False
      if x[i]!=q[i]:
        f2=False
    if f1:
      ansa=j+1
    if f2:
      ansb=j+1

  # print(ansa,ansb)
  return abs(ansa-ansb)

# main()
print(main())


Measured memory_bytes: 6348
class RotN:
    def __init__(self):
        self.alphabet = [a for a in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']

    def calculate(self, N, S):
        result_list =[]
        for s in S:
            num = self.alphabet.index(s)
            #  アルファベットがZより大きくなる場合
            if num + N > 25:
                tmp = 25 - (num + N)
                result_list.append(self.alphabet[abs(tmp)-1])
            #  アルファベットがZより大きくならない場合
            else:
                tmp = num + N
                result_list.append(self.alphabet[tmp]) 
        return result_list

if __name__ == '__main__':
    N = int(input())
    S = [s for s in input()]
    rn = RotN()
    result_list = rn.calculate(N, S)
    result = ''
    for x in result_list:
        result += x
    print(result)

Measured memory_bytes: 3188
import sys, bisect, math, itertools, string, queue, copy
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
al = inpl()
rui = []
for i in range(n):
    if(i == 0):
        rui.append(al[i])
    else:
        rui.append(rui[i - 1] + al[i])

ans = 0
for i in range(n):
    ans += al[i] * (rui[n - 1] - rui[i])
    ans %= mod
print(ans)


Measured memory_bytes: 111880
// AtCoder ABC109: C - Skip
// 2019.9.12 bal4u

#include <stdio.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int N, X;
int x[100005];
inline static void chmax(int *r, int a) { if (*r < a) *r = a; }

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

void Qsort(int *a, int l, int r) {
	int i, j, m, t;
	
	i = l, j = r, m = a[(l+r) >> 1];
	while (1) {
		while (a[i] < m) i++;
		while (m < a[j]) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

int main()
{
	int i, N, ans;
	
	N = in(), x[0] = in();
	for (i = 1; i <= N; i++) x[i] = in();
	Qsort(x, 0, N);
	ans = x[1]-x[0]; for (i = 2; i <= N; i++) ans = gcd(ans, x[i]-x[i-1]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
        for(int i = 0;i < 3;i ++)
        cin >> a[i];
        sort(a,a + 3);
        if(a[0] == 5 && a[1] == 5 && a[2] == 7)
        cout << "YES" << endl;
        else
        cout << "NO" << endl;
    return 0;
}


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

using namespace std;

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

    string S; cin>>S;
    int loses = 0;
    for (auto c : S) {
        if (c == 'x')
            loses++;
    }
    cout << (loses > 7 ? "NO" : "YES") << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int n = 0;
		double minc = 0;
		double manh = 0;
		double sank = 0;
		double cheb = 0;
		double keisan = 0;
		String str = "";
		
		double xve[];
		double yve[];
		
		
		n = as.nextInt();
		
		xve = new double[n];
		yve = new double[n];
		
		for(int i=0;i<n;i++){
			
			xve[i] = as.nextDouble();
			
		}
		
		for(int i=0;i<n;i++){
			
			yve[i] = as.nextDouble();
			
		}
		
		for(int i=0;i<n;i++){
			
			minc += Math.abs(xve[i]-yve[i]);
			
		}
		
		for(int i=0;i<n;i++){
			
			keisan = Math.pow((Math.abs(xve[i]-yve[i])),2);
			manh += keisan;
			
		}
		
		for(int i=0;i<n;i++){
			
			keisan = Math.pow((Math.abs(xve[i]-yve[i])),3);
			sank += keisan;
			
		}
		
		for(int i=0;i<n;i++){
			
			keisan = Math.abs(xve[i]-yve[i]);
			if(cheb < keisan){
				
				cheb = keisan;
				
			}
			
		}
		
		manh = Math.sqrt(manh);
		//System.out.println(sank);
		sank = Math.cbrt(sank);
		//System.out.println(sank);
		
		
		str = String.valueOf(minc);
		System.out.println(str);
		str = String.valueOf(manh);
		System.out.println(str);
		str = String.valueOf(sank);
		System.out.println(str);
		str = String.valueOf(cheb);
		System.out.println(str);

	}

}

Measured memory_bytes: 29012
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
a_list = [[int(elem) for elem in fin().split()][0] for _ in range(N)]

sorted_a = sorted(a_list)
all_max = sorted_a[-1]
all_second = sorted_a[-2]

for i in range(N):
    if a_list[i] == all_max:
        print(all_second)
    else:
        print(all_max)


Measured memory_bytes: 65244
#include <stdio.h>
#include <math.h>

int a[8],N;

int next(){

	/*
	13245の次は、13254
	13254の次は、13425
	15243の次は、15324
	35421の次は、41235
	右から見ていって、単調増加が崩れた最初の桁から右が変わる。
	最初の桁は、それよりの左で使われていないものの中でもとより大きいものに
	変わる。残りは、昇順に並ぶ。*/

	int i,j,p,b[8],c[8];

	for(i = N-1; i>0;i--){
		if(a[i-1]<a[i]){
			p = i-1;
			break;
		}
	}

	/*使った数字チェック*/
	for(i=0;i<N;i++){
		b[i] = 0;
	}
	for(i=0;i<p;i++){
		b[a[i]-1] = 1;
		c[i] = a[i];
	}

	/*c[p]を決める*/

	for(i=a[p];i<N;i++){
		if(b[i]==0){c[p] = i+1; b[i]=1; break;}
	}

	/*c[p+1]以降を決める*/
	for(i=p+1;i<N;i++){
		for(j=0;j<N;j++){
			if(b[j]==0){
				b[j]=1; c[i] = j+1; break;
			}
		}
	}

	for(i=0;i<N;i++){
		a[i] = c[i];
	}
	return 0;
}

int main() {
	int i,j,M,p[8][8],p1,p2,ans,pp;
	scanf("%d %d",&N,&M);

	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			p[i][j] = 0;
		}
	}

	for(i=0;i<M;i++){
		scanf("%d %d",&p1,&p2);
		p[p1-1][p2-1] = 1;
		p[p2-1][p1-1] = 1;
	}
	
	for(i=0;i<N;i++){
		a[i] = i+1;
	}

	ans = 0;

	while(a[0]==1){
		pp = 1;
		for(i=0;i<N-1;i++){
			if(p[a[i]-1][a[i+1]-1] == 0){
				pp = 0;
			}
		}
		if(pp == 1){ans++;}
		next();
	}

	printf("%d\n",ans);

}


Measured memory_bytes: 128
# B Subtring

S = input()
T = input()

ans = 10000
for s in range(len(S) - len(T) + 1):
  cnt = 0
  for t in range(len(T)):
    if S[s+t] != T[t]:
      cnt += 1
  ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 9112
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int N=100010;
const int mod=1000000007;

int a[N],b[N],c[N],d[N];

int main()
{
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	for (int i=1;i<=n;i++) if (a[i]!=a[i-1]) c[i]=a[i];
	for (int i=1;i<=n;i++) if (b[i]!=b[i+1]) d[i]=b[i];
	for (int i=1;i<n;i++) if (a[i]>a[i+1]) {puts("0");return 0;}
	for (int i=1;i<n;i++) if (b[i]<b[i+1]) {puts("0");return 0;}
	for (int i=1;i<=n;i++) if (c[i]&&d[i]&&c[i]!=d[i]) {puts("0");return 0;}
	for (int i=1;i<=n;i++)
		if (c[i]&&c[i]>b[i]) {puts("0");return 0;}
	for (int i=1;i<=n;i++)
		if (d[i]&&d[i]>a[i]) {puts("0");return 0;}
	int ans=1;
	for (int i=1;i<=n;i++)
		if (!(c[i]||d[i]))
			ans=ll(ans)*min(a[i],b[i])%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&a!=c)
        printf("Yes");
    else if(a==c&&a!=b)
         printf("Yes");
    else if(b==c&&b!=a)
         printf("Yes");
    else
        printf("No");
    return 0;

}


Measured memory_bytes: 128