akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const long long INF=4000000000000000000LL;
typedef pair<long long,int> P;
int N,a,b,c,d;

int main(){
	cin>>N;
	a=N/1000;
	N%=1000;
	b=N/100;
	N%=100;
	c=N/10;
	N%=10;
	d=N;
	
	if((a==b&&b==c)||(b==c&&c==d)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

bool ok(string s) {
   int n = (int)s.size() / 2;
   for (int i = 0; i < n; i++) {
      if (s[i] != s[i + n]) return false;
   }
   return true;
}

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

   int N = (int)S.size();
   for (int i = N - 1; i >= 0; i++) {
      S.pop_back();
      if ((int)S.size() % 2 != 0) continue;
      if (ok(S)) {
         cout << (int)S.size() << endl;
         return 0;
      }
   }
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		int count = 0;
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			count+= (d-1)/a[i] + 1;
		}
		
		System.out.println(count+x);
	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,i,j=0;
   cin>>n;
   int a[n];
   for(i=0;i<n;i++) cin>>a[i];
   sort(a,a+n);
   n/=2;
   cout << a[n]-a[n-1]<<endl;

   return 0;
}


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

void Input(vector<long long> &, int);
long long SumProduct(vector<long long> &, int);

int main()
{
  long long sum; //積の合計
  
  /* 入力 */
  int n;
  cin >> n;
  vector<long long> a(n);
  Input(a, n);
  
  /* 積の合計を計算 */
  sum = SumProduct(a, n);
  
  //出力
  cout << sum << endl;
  
  return 0;
}

void Input(vector<long long> &a, int n)
{
  /* 数列A取得 */
  for(int i=0 ; i < n ; i++)
  {
    cin >> a[i];
  }
  
}

long long SumProduct(vector<long long> &a, int n)
{
  int i;
  vector<long long> s(n+1);
  long long sum = 0;
  long long temp;
  long long mod = 1000000007;
  
  /* 累積和の計算 */
  s[0]=0;
  for(i=0 ; i < n ; i++)
  {
    s[i+1] = (s[i] + a[i])%mod;
  }
  
  /* 積の合計を計算 */
  for(i=0 ; i < n-1 ; i++)
  {
    temp = (s[n] - s[i+1]) % mod;
    if(temp < 0) temp += mod;
    temp = (a[i] * temp) % mod;
    sum = (sum + temp) % mod;
  }
  
  return sum;
}

Measured memory_bytes: 5964
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
  d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

int main(){
  double count=0;
  int N;
  cin>>N;
  vector<pair<double,string>>eko(N);
  rep(i,N){
    cin>>eko[i].first>>eko[i].second;
  }
  rep(i,N){
    if(eko[i].second=="JPY"){
    count+=eko[i].first;
    }
    else{
      count+=eko[i].first*380000;
    }
  }
  cout<<count;
}


Measured memory_bytes: 256
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    string S;
    cin >>S;

    ll X=0;
    rep(i,S.size()){
        X+=S[i]-'0';
        X%=9;
    }

    cout << ((X%9==0) ? "Yes" : "No") <<'\n';


    return (0);
}

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

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

constexpr int MAX_NUM = 20000;


int main() {
    string s;
    cin >> s;

    stack<int> s1;
    stack<pair<int, int>> s2;
    int sum = 0;

    for (auto itr = s.begin(); itr != s.end(); ++itr) {
        char c = *itr;

        if (c == '\\') {
            s1.push(itr - s.begin());
        } else if (c == '/') {
            if (!s1.empty()) {
                int left = s1.top(); s1.pop();

                int area = (itr - s.begin()) - left;
                sum += area;

                while (!s2.empty() && left < s2.top().first) {
                    area += s2.top().second; s2.pop();
                }
                s2.emplace(left, area);
            }
        }
    }

    vi ans;
    while(!s2.empty()) { ans.push_back(s2.top().second); s2.pop(); }
    reverse(ans.begin(), ans.end());

    cout << sum << endl;
    cout << ans.size();
    rep(i, 0, ans.size()) {
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main()
{
  string s;
  cin >> s;
  int x = 0, y = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      x = i;
      break;
    }
  }

  for (int i = s.size(); i >0; i--) {
    if (s[i] == 'Z') {
      y = i;
      break;
    }
  }

  cout << y - x + 1 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;

int main() {
	int a, b;
	char op;
	while (1) {
		cin >> a >> op >> b;
		if (op == '?') break;
		if (op == '+') cout << a + b << endl;
		else if (op == '-') cout << a - b << endl;
		else if (op == '*') cout << a*b << endl;
		else cout << a / b << endl;
	}
}

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

int main() {
    ll n,m,a[200],sum=0;
    cin >> n >> m;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);
    for(int i=0;i<m;i++){
        if(a[i]<((double)sum/(4 * m))){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed dp[1 << 26];
signed main() {
    REP(i, 1 << 26) {
        dp[i] = INF_;
    }

    string s;
    cin >> s;
    int N = SZ(s);
    vector<int> X(N);
    REP(i, N) {
        X[i] = 1LL << (s[i] - 'a');
        if (i) X[i] ^= X[i - 1];
    }

    dp[0] = 0;
    REP(i, N) {
        REP(k, 26) {
            if (dp[X[i] ^ (1LL << k)] != INF_) {
                chmin(dp[X[i]], dp[X[i] ^ (1LL << k)] + 1);
            }
        }
    }
    int ans = dp[X[N - 1]];
    if (ans == 0) ans++;
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 264340
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import heapq

def main():
    A=[]
    B=[]
    M=[]
    values=[]
    a,b,m = map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    M=[list(map(int,input().split())) for _ in range(m)]

# #割引した組み合わせ
    for m in M:
        values.append(A[m[0]-1]+B[m[1]-1]-m[2])

    heapq.heapify(A)
    heapq.heapify(B)

#最も安い組み合わせ
    cheap=heapq.heappop(A)+heapq.heappop(B)

    print(min(cheap,min(values)))

if __name__=="__main__":
    main()

Measured memory_bytes: 42528
//ex3_2
//TKC001
 
#include<stdio.h>
 
int main(void){
    int num, units;
 
    scanf("%d", &num);
    //一の位を求める
    units = num % 10;
 
    switch (units)
    {
    //bonを出力
    case 3:
        printf("bon");
        break;
    
    //ponを出力
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon");
        break;
 
    //honを出力
    default:
        printf("hon");
        break;
    }
 
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    int n,ans;
    ans =0;
    string a,b,c;
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; i++)
    {
        if (a[i] == b[i] && b[i] == c[i]){
            ans +=0;
        }else if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) {
            ans +=1;
        }else{
            ans +=2;
        }
        
        
    }
    cout << ans << endl;
    

}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 8
i64 G[MAX_N][MAX_N];

int main() {
    i64 N, M; cin >> N >> M;
    REP(i, M) REP(j, M) G[i][j] = 0;
    REP(i, M) {
        i64 u, v; cin >> u >> v;
        u--, v--;
        G[u][v] = 1;
        G[v][u] = 1;
    }

    vector<i64> A(N - 1);
    REP(i, N - 1) A[i] = i + 1;

    i64 cnt = 0;
    do {
        bool ok = true;
        i64 v = 0;
        REP(i, A.size()) {
            if (G[v][A[i]] == 0) {
                ok = false;
                break;
            }
            v = A[i];
        }
        if (ok) cnt++;
    } while (next_permutation(A.begin(), A.end()));

    cout << cnt << endl;

    return 0;
}

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

int main() {
    ll x;
    cin>>x;
    ll ans=0;
    ans=ans+(x/500)*1000;
    x=x%500;
    ans=ans+(x/5)*5;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=[['' for i in range(3)] for j in range(N)]
S3=[['' for i in range(3)] for j in range(N)]
for i in range(N):
  a=input().split()
  S[i][0]=(int(a[1]))
  S[i][1]=(a[0])
  S[i][2]=(i+1)
S2=sorted(S, reverse=True, )
for i in range(N):
  S3[i][0]=S2[i][1]
  S3[i][1]=S2[i][0]
  S3[i][2]=S2[i][2]
S4=sorted(S3, key = lambda x:x[0])
for i in range(N):
  print(S4[i][2])


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<int> ng(10, 0);
	for(int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		ng[d] = 1;
	}
	
	int ans = 0;
	for(int i = n; ; ++i) {
		int a = i;
		bool ok = true;
		
		while( a ) {
			if( ng[a % 10] ) {
				ok = false;
				break;
			}				
			
			a /= 10;
		}
		
		if( ok ) {
			ans = i;
			break;
		}
	}

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


Measured memory_bytes: 256
s=list(input())
id_1=['1' if i%2 else '0' for i in range(len(s))]
id_2=['0' if i%2 else '1' for i in range(len(s))]
cnt=[0,0]
for si,id1,id2 in zip(s,id_1,id_2):
  cnt[0] += si!=id1
  cnt[1] += si!=id2
print(min(cnt))

Measured memory_bytes: 11308
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def solve(N: int):
    ans = 0
    d = collections.Counter(prime_factorize(N))
    for p, count in d.items():
        tmp = 1
        while count > 0:
            count -= tmp
            if count >= 0:
                ans += 1
            tmp += 1

    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto&& V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

int main(void) {
  int n, k;
  string s;
  cin >> n >> k >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s << endl;
  return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int h,w,n;cin>>h>>w>>n&&h|w|n;){
		vvi grid(h,vi(w));
		int i=0;
		rep(k,n){
			int x; cin>>x;
			rep(_,x){
				grid[i/w][i%w]=k+1;
				i++;
			}
		}
		for(int i=1;i<h;i+=2)
			reverse(all(grid[i]));
		rep(i,h)
			rep(j,w)
				cout<<grid[i][j]<<"\n "[j+1<w];
	}
}


Measured memory_bytes: 384
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

function readline() {
    return inputString[currentLine++];
}


function main() {

    var r = Number(readline())
    if(r < 1200) console.log('ABC');
    else if(r < 2800) console.log('ARC');
    else console.log('AGC');
}

//


Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int A,B;
  cin >> A >> B;
  
  int o = 0;
  
  for(int i = A ; i <= B ; i++){
    if((i / 10000) == (i % 10)){
      if(((i / 1000) % 10) == ((i % 100) / 10)){
        o++;
      }
    }
  }
  
  cout << o << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  long long n; std::cin >> n;
  long long mod = 1e9+7;
  long long sum = 1; // 0~9
  long long not_a = 1; // 1~9
  long long not_b = 0; // 0~8
  long long not_a_not_b = 1; // 1~8
  for (int i = 0; i < n; ++i) {
      sum *= 10;
      sum %= mod;

      not_a *= 9;
      not_a %= mod;

      not_a_not_b *= 8;
      not_a_not_b %= mod;
  }
  not_b = not_a;
  // std::cout << "not_a: " << not_a << std::endl;
  // std::cout << "not_b: " << not_b << std::endl;
  // std::cout << "not_a_not_b: " << not_a_not_b << std::endl;
  long long ans = (sum - not_a - not_b + not_a_not_b) % mod;
  if (ans < 0) ans += mod;
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
i64 s[11];
i64 p[11];

i64 cnt(i64 x) {
  i64 c = 0;
  for (i64 i = 0; i < 20; ++i) {
    if ((1 << i) & x) ++c;
  }
  return c;
}

int main() {
  cin >> n >> m;
  for (i64 i = 0; i < m; ++i) {
    i64 k; cin >> k;
    while (k--) {
      i64 t; cin >> t;
      s[i] |= 1 << (t - 1);
    }
  }
  read_n(p, m);

  i64 ans = 0;
  for (i64 a = 0; a < (1 << n); ++a) {
    i64 f = true;
    for (i64 i = 0; i < m; ++i) {
      if (cnt(a & s[i]) % 2 != p[i]) f = false;
    }
    if (f) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
from math import floor,ceil,sqrt
# import bisect
# from collections import deque

# from types import GeneratorType
# def bootstrap(func, stack=[]):
#     def wrapped_function(*args, **kwargs):
#         if stack:
#             return func(*args, **kwargs)
#         else:
#             call = func(*args, **kwargs)
#             while True:
#                 if type(call) is GeneratorType:
#                     stack.append(call)
#                     call = next(call)
#                 else:
#                     stack.pop()
#                     if not stack:
#                         break
#                     call = stack[-1].send(call)
#             return call
#     return wrapped_function

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

x,n = Ri()
a = Ri()

s =  set([i for i in range(0,102)])
for i in a:
    if i in s:
        s.remove(i)

val = -1
dif = INF
for i in s:
    if abs(x - i) < dif:
        dif = abs(x-i)
        val = i
print(val)

Measured memory_bytes: 64692
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 2e5 + 4 , M = 1e6 + 3;
const int MOD = 998244353;
int a[N] , inv[M] , n , cnt[M] , f[M];

int mul(int a , int b , int m = MOD){
   return (1LL * (a % m) * (b % m)) % m;
}

int add(int a , int b , int m = MOD){
   return (1LL * (a % m) + (b % m) + MOD) % m;
}

int powMOD(int x , int n , int m = MOD){
   if(!n)return 1;
   int ret = 1;
   if(n & 1)ret = mul(x , powMOD(x , n - 1 , m) , m);
   else{
      int y = powMOD(x , n / 2 , m);
      ret = mul(y , y , m);
   }
   return ret;
}

void pre() {
   inv[0] = inv[1] = 1;
   for (int i = 2; i < M; i++) {
      inv[i] = (MOD - 1ll * (MOD / i) * inv[MOD % i] % MOD) % MOD;
   }
}

int solve(int g){
   int sum = 0;
   for(int i = g ; i < M ; i += g)
      sum = add(sum , mul(cnt[i] , i));
   int res = 0;
   for(int i = g ; i < M ; i += g)
      res = add(res , mul(mul(cnt[i] , i) , sum));
   for(int i = 2 * g ; i < M ; i += g)
      res = (res - f[i] + MOD) % MOD;
   return f[g] = res;
}

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> n;
   for(int i = 0 ; i < n ; ++i)
      cin >> a[i] , cnt[a[i]]++;
   pre();
   int ans = 0;
   for(int i = M - 1 ; i >= 1 ; --i){
      int cur = (1ll * solve(i) * inv[i]) % MOD;
      ans += cur;
      ans %= MOD;
   }

   for(int i = 0 ; i < n ; ++i)
      ans = (ans - a[i] + MOD) % MOD;
   ans = (1ll * ans * inv[2]) % MOD;
   cout << ans << "\n";
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long a[n],m=1,mn=1e18;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mn=min(mn,a[i]);
	}
	if(mn==0)
	{
		cout<<0;
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		if(1000000000000000000/m<a[i])
		{
			cout<<-1;
			return 0;
		}
		m*=a[i];
	}
	cout<<m;
	return 0;
}


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

int main(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N);
    vector<int> w(N);
    for(int i = 0; i < N; i++) cin >> v[i] >> w[i];

    int dp[W+1];
    fill_n(dp, W+1, 0);

    for(int i = 1; i <= W; i++){
        for(int j = 0; j < N; j++){
            if(i >= w[j]) dp[i] = max(dp[i], dp[i-w[j]]+v[j]);
        }
    }

    cout << *max_element(dp, dp+W+1) << endl;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	int n, h;
	std::cin >> n >> h;
	std::vector<int>a(n);
	std::vector<int>b(n);
	int ans = 0;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i] >> b[i];
	}
	std::sort(a.rbegin(), a.rend());
	std::sort(b.rbegin(), b.rend());
	for (int i = 0;i < n;i++) {
		if (b[i] >= a[0]) {
			h -= b[i];
			ans += 1;
		}
		if (h <= 0)
			break;
	}
	if (h > 0) {
		ans += h / a[0];
		if (h%a[0] != 0) {
			ans += 1;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}




Measured memory_bytes: 1024
import sys
N, K = map(int, input().split())
A = list(map(int, input().split()))

now = 1
temp_l = [0]*N
temp_count = [-1]*N
temp_count[0] = 0
for i in range(N):
    pre = now
    now = A[pre-1]
    if temp_l[now-1] == 1:
        end = now
        temp = i+1
        break
    else:
        temp_l[now-1] = 1
        temp_count[now-1] = i+1

s_index = temp_count[end-1]
repeat = temp - s_index
if K <= s_index:
    print(temp_count.index(K)+1)
else:
    K -= s_index
    K = K % repeat
    print(temp_count.index(K+s_index)+1)

Measured memory_bytes: 32384
# include <cstdio>
# include <iostream>
# define R register int
# define ll long long

using namespace std;

const int N=2004;
int n,h,x,y;
int a[N],firs[N],f[N],s[N],siz[N];
struct edge { int too,nex; }g[N<<1];

void add (int x,int y)
{
    g[++h].nex=firs[x];
    firs[x]=h;
    g[h].too=y;
}

void update (int &a,int b)
{
    if(b==-1) return;
    if(a==-1) a=b;
    else a=min(a,b);
}

void dfs (int x,int fa)
{
    int j,ms=-1,pos;
    siz[x]=a[x];
    for (R i=firs[x];i;i=g[i].nex)
    {
        j=g[i].too;
        if(j==fa) continue;
        dfs(j,x);
        s[x]+=s[j]+siz[j];
        siz[x]+=siz[j];
		s[j]+=siz[j];
        if(s[j]>ms) ms=s[j],pos=j;
    }
    if(ms==-1) return;
    if(ms*2<=s[x]) f[x]=s[x]/2;
    else f[x]=s[x]-ms+min(f[pos],(2*ms-s[x])/2);
}

int solve (int x)
{
    for (R i=1;i<=n;++i) f[i]=0,s[i]=0,siz[i]=0;
    dfs(x,-1);
    if(s[x]%2) return -1;
    if(f[x]!=s[x]/2) return -1;
    return s[x]/2;
}

int main()
{
    scanf("%d",&n);
    for (R i=1;i<=n;++i)
        scanf("%1d",&a[i]);
    for (R i=1;i<n;++i)
    {
        scanf("%d%d",&x,&y);
        add(x,y); add(y,x);
    }
    int ans=-1;
    for (R i=1;i<=n;++i) update(ans,solve(i));
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PA;
#define MAXN 10004
#define MAXK 100005
#define INF 1000000009
#define pb push_back

int n, a[MAXN], ans = 0;

int ni(int c)
{
    int cnt = 0;
    while(c != 1 && c % 2 == 0){
        c /= 2;
        //printf("%d\n", c);
        cnt++;
    }
    //printf("%d\n", cnt);
    return cnt;
}

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] % 2 == 0){
            ans += ni(a[i]);
        }
    }
    printf("%d\n", ans);


    return 0;
}



Measured memory_bytes: 256
'use strict'

const main = (arg) => {
    const nums = arg.split(" ");
    const X = nums[0];
    const Y = nums[1];

    var isYes = true;
    for(var i = 0 ; i <= X ; i++){
        if(i*2 + (X-i)*4 == Y){
            console.log('Yes');
            isYes = false;
            break;
        }
    }
    if(isYes) console.log('No');
}

main(require('fs').readFileSync('/dev/stdin','utf8'));

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

N, M = map(int, input().split())
W = [list(map(int, input().split())) for i in range(N)]
W.sort()
  
ans = 0
C = []

for i in range(1,M+1):
  j = -i
  while W != [] and W[0][0] <= i:
    a,b = heappop(W)
    heappush(C,-b)
  if C != []:
    ans += -heappop(C)
print(ans)

Measured memory_bytes: 28104
n = gets.to_i
$stores = []
n.times { $stores << gets.split.map(&:to_i) }
$profits = []
n.times { $profits << gets.split.map(&:to_i) }
$answers = []

def dfs(decided, openings)
  if decided == 10
    profit_sum = 0
    $stores.each_with_index do |store, s_index|
      count = 0
      openings.each_with_index do |opening, o_index|
        next if opening == 0
        count += 1 if store[o_index] == 1
      end
      profit_sum += $profits[s_index][count]
    end
    $answers << profit_sum
    return
  end
  
  dfs(decided + 1, [*openings, 0])
  dfs(decided + 1, [*openings, 1])
end

dfs(0, [])

$answers.shift
puts $answers.max


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORR(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = b - 1; i >= a; i--)
#define FORI(i, a, b, inc) for (int i = a; i <= b; i += inc)
#define FORRI(i, a, b, inc) for (int i = a; i < b; i += inc)
#define REPD(i, a, b, dec) for (int i = b - 1; i >= a; i -= dec)
#define SORT(a, n) sort(a, a + n, greater<int>())
#define PREC(n) cout << fixed << setprecision(n)
#define ULL unsigned long long
#define FT first
#define SN second
#define Vsort(v) sort(v.begin(), v.end())
#define FORV(it, l) for (auto it : l)
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define RESET(a, b) memset(a, b, sizeof(a))
#define PI acos(-1)
#define S " "
typedef vector<int> VC;
typedef vector<VC> VCC;
typedef pair<int, int> PR;
typedef vector<PR> VPR;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef set<PR> STP;
void solve()
{
    /*Md. Bokhtiar Nadeem Shawon
    Institute of Information Technology
    Jahangirnagar University
    */
    string s, t;
    int sum=0, x;
    cin >> s >> t;
    x = s.size();
    FOR(i, 0, x)
    {
        if(s[i]!=t[i])
            sum++;
    }
    cout << sum << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*int t;
    cin >> t;
    while (t--)*/
        solve();

    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
struct cat{
  int x,y;
};
int main(){
  int x,y,w,h,c;
  int n;
  cat map[101];
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>x>>y>>w>>h;
    cin>>c;
    for(int j=0;j<c;++j){
      cin>>map[j].x>>map[j].y;
    }
    int cnt=0;
    for(int j=0;j<c;++j){
      if(map[j].x>=x && map[j].x<=x+w && map[j].y>=y && map[j].y<=y+h) ++cnt;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

ll dp[2002][2002];
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];

    dp[0][0] = 1;
    rep(i, N + 1) {
        rep(j, M + 1) {
            if (i >= 1 && j >= 1 && (S[i - 1] == T[j - 1])) {
                dp[i][j] += dp[i - 1][j - 1];
                dp[i][j] %= MOD;
            }
            if (i >= 1) {
                dp[i][j] += dp[i - 1][j];
                dp[i][j] %= MOD;
            }
            if (j >= 1) {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
            if (i >= 1 && j >= 1) {
                dp[i][j] -= dp[i - 1][j - 1];
                dp[i][j] %= MOD;
            }
            if (dp[i][j] < 0) dp[i][j] += MOD;
        }
    }

    cout << dp[N][M] << endl;
    return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,a[111111];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int cnt=0,sum=a[0];
  if(!a[0])sum=cnt=1;
  for(int i=1;i<n;i++){
    if(sum>0&&sum+a[i]>0){
      cnt+=sum+a[i]+1;
      sum=-1;
    }else if(sum<0&&sum+a[i]<0){
      cnt+=(-1*(sum+a[i]))+1;
      sum=1;
    }else if(sum+a[i]==0){
      if(sum>0)sum=-1;
      else sum=1;
      cnt++;
    }else{
      sum+=a[i];
    }
  }
  int ans=cnt;
  if(!a[0]){
    cnt=1;
    sum=-1;
  }else {
    cnt=abs(a[0])+1;
    if(a[0]>0)sum=-1;
    else sum=1;
  }
  for(int i=1;i<n;i++){
    if(sum>0&&sum+a[i]>0){
      cnt+=sum+a[i]+1;
      sum=-1;
    }else if(sum<0&&sum+a[i]<0){
      cnt+=(-1*(sum+a[i]))+1;
      sum=1;
    }else if(sum+a[i]==0){
      if(sum>0)sum=-1;
      else sum=1;
      cnt++;
    }else{
      sum+=a[i];
    }
  }
  
  cout<<min(ans,cnt)<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    
    int all[n];
    
    for(int i = 0; i < n; ++i){
    	cin >> all[i];
	}
	
	sort(all, all + n);
	
	bool check = true;
	
	for(int i = 0; i < n - 1; ++i){
		if(all[i] == all[i + 1]) check = false;
	}
	
	if(check == true){
		cout << "YES";
	}
	else{
		cout << "NO";
	}

	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n, l; cin >> n >> l;
    vector<string> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    
    for(int i = 0; i < n; i++) {
        cout << v[i];
    }
    cout << endl;
}


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

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

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

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

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}



struct edge {
	int from;
	int to;
	int cost=1;
};


auto dijkstra(vector<vector<edge>> &g, int start = 0) {
	vector<int> d(g.size(), I_MAX);
	d[start] = 0;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int,int>>> nodes;//first dist, second edgenum
	nodes.push(pair<int, int>(0, start));


	while (!nodes.empty()) {
		pair<int, int> n = nodes.top();
		int s_node = n.second;
		nodes.pop();
		if (n.first > d[n.second])continue;
		rep(i, 0, g[s_node].size()) {
			int new_dist = d[s_node] + g[s_node][i].cost;
			int n_num = g[s_node][i].to;
			if (new_dist < d[n_num]) {
				nodes.push(make_pair(new_dist, n_num));
				d[n_num] = new_dist;
			}
		}
	}
	return d;
}

int main() {

	string s, t, u;
	int a, b;

	cin >> s >> t;
	cin >> a >> b;

	cin >> u;
	if (u == s) {
		a -= 1;
	}
	if (u == t) {
		b -= 1;
	}

	cout << a << " "<< b << endl;


	return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
WV = [list(map(int,input().split())) for _ in range(N)]

vmax = N*(10**3)
# dp[i][j]:i番目までの品物で、価値がjとなる最小の重さ。
dp = [[W+1 for _ in range(vmax+1)] for _ in range(N+1)]
for i in range(N+1):
  dp[i][0] = 0
for i in range(1,N+1):
  for j in range(vmax+1):
    if j >= WV[i-1][1]:
      dp[i][j] = min(dp[i-1][j],dp[i-1][j-WV[i-1][1]] + WV[i-1][0])
    else:
      dp[i][j] = dp[i-1][j]
#print(dp)
ans = 0
for i in range(vmax+1):
  if dp[N][i] <= W:
    ans = i
print(ans)

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

const long long INF = 1e18;

struct RMinQ{
private:
  int n;
  vector<long long> data;
public:
  RMinQ(vector<long long> V){
    int sz = V.size();
    n = 1;
    while(n < sz) n *= 2;
    data.resize(2*n-1,INF);
    for(int i = 0; i < sz; ++i) data[n-1+i] = V[i];
    for(int i = n-2; i >= 0; --i) data[i] = min(data[2*i+1],data[2*i+2]);
  }
  void update(int idx, long long val){//0-indexed
    idx += n-1;
    if(data[idx] <= val) return;
    data[idx] = val;
    while(idx > 0){
      idx = (idx-1)/2;
      data[idx] = min(data[2*idx+1],data[2*idx+2]);
    }
  }
  long long get_min(int l, int r){//[l,r)の区間の最小値
    long long ret = INF;
    l += n-1, r += n-1;
    while(l < r){
      if((l&1) == 0){
        ret = min(ret,data[l]);
      }
      if((r&1) == 0){
        ret = min(ret,data[r-1]);
      }
      l /= 2;
      r = (r-1)/2;
    }
    return ret;
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<long long> L(M), R(M), C(M);
  vector<int> I(M);
  for(int i = 0; i < M; ++i){
    I[i] = i;
    cin >> L[i] >> R[i] >> C[i];
    --L[i],--R[i];
  }
  sort(I.begin(), I.end(), [&](int a, int b){ return R[a] < R[b]; });
  vector<long long> init(N,INF);
  init[0] = 0;
  RMinQ rmq(init);
  for(auto idx : I){
    int l = L[idx], r = R[idx];
    long long d = rmq.get_min(l,r+1) + C[idx];
    rmq.update(r,d);
  }
  long long ans = rmq.get_min(N-1,N);
  if(ans >= INF) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 6528
sx, sy, tx, ty = map(int, input().split())

ans = "U"*(ty-sy)
ans += "R"*(tx-sx)
ans += "D"*(ty-sy)
ans += "L"*(tx-sx)

ans += "L"
ans += "U"*(ty-sy+1)
ans += "R"*(tx-sx+1)
ans += "DR"
ans += "D"*(ty-sy+1)
ans += "L"*(tx-sx+1)
ans += "U"

print(ans)

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

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

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

  int one;
  rep(i,n){
    int a;
    cin >> a;
    if(a==1) one = i;
  }

  int ans=n;
  rep(i, k){
    double left = max(0, one-k+1+i);
    double right = max(0, n-one-i-1);
    int step = ceil(left/(k-1)) + ceil(right/(k-1));
    ans = min(ans, step+1);
    //cout << left << " "  << right << endl;
  }

  cout << ans;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{
	int h,m,s,t;
	scanf("%d",&t);
	h=t/3600;
	t=t%3600;
	m=t/60;
	s=t%60;
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
	}

Measured memory_bytes: 592
def main():
    S = input()
    for j in range(len(S) - 1, 0, -1):
        if len(S[:j]) % 2 == 1:
            continue
        i = len(S[:j]) // 2
        if S[:i] == S[i:j]:
            print(len(S[:j]))
            break


main()


Measured memory_bytes: 2940
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    vector<vector<ll>> next(n+1,vector<ll>(n+1,0));
    dp[1][1]=1;
    for(int i=0;i<m;i++){
        for(auto &I:next){for(auto &T:I){T=0;}}
        for(int t=1;t<=n;t++){
            for(int h=1;h<=t;h++){
                if(t==h){
                    next[t][h]+=dp[t][h]*h%MOD; next[t][h]%=MOD;
                    if(t!=n){next[t+1][h]+=dp[t][h]*(n-t)%MOD; next[t+1][h]%=MOD;}
                }
                else{
                    next[t][h]+=dp[t][h]*(t-h)%MOD; next[t][h]%=MOD;
                    next[t][t]+=dp[t][h]*h%MOD; next[t][t]%=MOD;
                    if(t!=n){next[t+1][h]+=dp[t][h]*(n-t)%MOD; next[t+1][h]%=MOD;}
                }
            }
        }
        dp=next;
    }
    cout<<dp[n][n]<<endl;
    
    return 0;
}


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

signed main() {
  int64_t a, b, x;
  cin >> a >> b >> x;
  int64_t ans = b / x - max(a - 1, int64_t(0)) / x; 
  if (!a)
    ++ans;
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
	if (n == 0) return 1;
	mint x = f(n / 2);
	x *= x;
	if (n%2 == 1) x *= 2;
	return x;
}

mint choose(int n, int a) {
	mint x = 1, y = 1;
	rep(i, a) {
		x *= n - i;
		y *= i + 1;
	}
	return x / y;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	mint ans = f(n);
	ans -= 1;
	ans -= choose(n, a);
	ans -= choose(n, b);
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
int f[N];
int main(){
	int n;
	scanf("%d",&n);
	for(int a=1;a<=100;a++){
		for(int b=1;b<=100;b++){
			for(int c=1;c<=100;c++){
				int sum=a*a+b*b+c*c+a*b+b*c+c*a;
				if(sum<=n) f[sum]++; 
			}
		}
	}
	for(int i=1;i<=n;i++) printf("%d\n",f[i]);
	return 0;
}

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

using ll=long long;
const ll z=0;

int main() {
  ll N,C;
  cin >> N >> C;
  vector<ll> x(N+2,0),v(N+2,0);
  x[N+1]=C;
  for(int i=1;i<N+1;i++){
    cin >> x[i] >> v[i];
  }
  vector<ll> R(N+2,0),r(N+2,0);//右回り
  R[0]=z;
  for(ll i=1;i<=N+1;i++){
    R[i]=R[i-1]+v[i]-x[i]+x[i-1];
    r[i]=max(r[i-1],R[i]);
  }
  vector<ll> L(N+2,0),l(N+2,0);//左回り
  L[N+1]=z;
  for(ll i=N;i>=0;i--){
    L[i]=L[i+1]+v[i]+x[i]-x[i+1];
    l[i]=max(l[i+1],L[i]);
  }
  //往復右回り
  vector<ll> RD(N+2,0);
  RD[0]=z;
  for(ll i=1;i<=N;i++){
    RD[i]=max(RD[i-1],R[i]-x[i]);
  }
  //往復左回り
  vector<ll>LD(N+2,0);
  LD[N+1]=z;
  for(ll i=N;i>=1;i--){
    LD[i]=max(LD[i+1],L[i]-C+x[i]);
  }
  ll ans=z;
  ans=max(l[N+1],r[N+1]);
  for(ll i=1;i<N;i++){
    ans=max(ans,r[i]+LD[i+1]);
  }
  for(ll i=1;i<N;i++){
    ans=max(ans,RD[i-1]+l[i]);
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 6528