akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <ctype.h>

int main(void)
{
  char s[1200];
  int i;

  gets(s);

  for(i = 0; i < 1200; i++){
    if(s[i] != toupper(s[i]))
      s[i] = toupper(s[i]);
    else
      s[i] = tolower(s[i]);
  }
   
    printf("%s\n", s);

  return 0;
}

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

int main() {
  string s;
  int n, k;
  cin >> n >> k >> s;
    if (s[k-1] == 'A')s[k-1] = s[k-1] - 'A' + 'a';
    if (s[k-1] == 'B')s[k-1] = s[k-1] - 'B' + 'b';
    if (s[k-1] == 'C')s[k-1] = s[k-1] - 'C' + 'c';
  cout << s << endl;
return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long
#define pb push_back

int dp[200000][12];
vec<vec<int>> x;

void change(int v, int d, int q)
{
	if (dp[v][d + 1] >= q) return;
	for (int i = d + 1; i >= 0; i--) {
		if (dp[v][i] < q) dp[v][i] = q;
		else break;
	}
	if (d == 0) return;
	rep(i, x[v].size()) change(x[v][i], d - 1, q);
}

int main(void)
{
	int n, m, q;
	cin >> n >> m;
	x.resize(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		x[a].pb(b);
		x[b].pb(a);
	}
	cin >> q;
	vec<int> v(q + 1), d(q + 1), c(q + 1);
	c[0] = 0;
	rep(i, q) cin >> v[i + 1] >> d[i + 1] >> c[i + 1];

	for (int i = q; i >= 1; i--) change(v[i] - 1, d[i], i);
	rep(i, n) cout << c[dp[i][0]] << endl;
	return 0;
}

Measured memory_bytes: 13816
#include <stdio.h>

int main(void)
{
	long long k, n;
	int i;

	scanf("%lld", &k);

	if (k % 2 == 0 || k % 5 == 0) {printf("-1\n"); return 0;}

	n = 7;
	for (i = 1; ; i++)
	{
		if ((n %= k) == 0) break;
		n = 10*n + 7;
	}

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

	return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  string ans = "Yes";
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) ans = "No";
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    int l;
    int sum = 0;
    int f[300];
    cin >> n >> l;
    for(int i = 1;i<=n;i++){
        f[i] = l+i-1;
        sum += f[i];
    }
    int ans = 0;
    int diff = 200; 
    for(int i = 1;i<=n;i++){
        int tmp = sum-f[i];
        if(diff > abs(sum-tmp)){
            diff = abs(sum-tmp);
            ans = tmp;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n;
	int ans=0;
	cin>>n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	for(int i=0;i<29;i++){
//		cout<<"i="<<i<<endl;
		vector<int> b2(n),a2(n);
		for(int j=0;j<n;j++){
			b2[j]=b[j]%(1<<(i+1));
			a2[j]=a[j]%(1<<(i+1));
//			cout<<b2[j];
		}
//		cout<<endl;
		sort(b2.begin(),b2.end());

		int count=0;
		for(int k=0;k<n;k++){
//			cout<<"k="<<k<<endl;
			int pos[4];
			for(int m=0;m<4;m++){
				pos[m]=lower_bound(b2.begin(),b2.end(),(m+1)*(1<<i)-a2[k])-b2.begin();
//				cout<<pos[m];
			}
//			cout<<endl;
			count+=(pos[3]-pos[2]+pos[1]-pos[0]);
		}



		if(count%2) ans|=(1<<i);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3432
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    map<char, char> mp;
    REP(i,n){
        mp[s[i]] = t[i];
    }

    for (char c = 'a'; c <= 'z'; c++){
        for (char d = 'a'; d <= 'z'; d++){
            if (mp.count(c) == 0 || mp.count(d) == 0 || c == d) continue;
            if (mp[c] == mp[d]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    REP(i,n){
        s[i] = mp[s[i]];
    }
    cout << (s == t ? "Yes" : "No") << endl;

    return 0;
}


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

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

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

    cout << v[n/2] - v[n/2 - 1] << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
using namespace std;

char str[10000000];

int main()
{
	long long N;
	scanf("%lld",&N);
	int a=0,tmp;
	while(N)
	{
		tmp=N%26;
		if(tmp==0)	str[a++]='z';
		else		str[a++]=N%26+'a'-1;
		N=(N-tmp)/26-!tmp;
	}
	for(int i=a-1;i>=0;--i)
		printf("%c",str[i]);
	puts("");
return 0;
}

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

int main() {
	// your code goes here
	string s, t;
	cin >> s >> t;
	int n=s.size(), m=t.size();
	vector<vector<int> > dp(n+1, vector<int>(m+1, INT_MIN));
	dp[0][0]=0;
	for(int i=0; i<=n; i++){
		for(int j=0; j<=m; j++){
			if(i+1<=n)
				dp[i+1][j]=max(dp[i][j], dp[i+1][j]);
			if(j+1<=m)
				dp[i][j+1]=max(dp[i][j], dp[i][j+1]);
			if(s[i]==t[j] && i+1<=n && j+1<=m)
				dp[i+1][j+1]=max(dp[i+1][j+1], 1+dp[i][j]);
		}
	}
	int cri=n, crj=m;
	string ans="";
	while(cri>0 && crj>0){
		if(s[cri-1]==t[crj-1]){
			ans = ans + s[cri-1];
			cri--;
			crj--;
		}
		else if(dp[cri-1][crj]<dp[cri][crj-1]) crj--;
    	else cri--;
		
	}
	if(ans.length()==0) cout<<" "<<endl;
	else for(int i=ans.length()-1;i>=0;i--) cout<<ans[i];
	
	return 0;
}

Measured memory_bytes: 35584
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        char A = sc.next().charAt(0), B = sc.next().charAt(0);
                        if (A == 'H' && B == 'H') {
                                System.out.println('H');
                        } else
                        if (A == 'D' && B == 'H') {
                                System.out.println('D');
                        } else
                        if (A == 'D' && B == 'D') {
                                System.out.println('H');
                        } else {
                                System.out.println('D');
                        }
                }
        }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2+9;
const double pi = acos(-1.0);
#define ll long long
ll dp[N];
ll a[N];
ll n,m,d,x;
int _,__,___;
int main()
{
   // freopen("in.txt","r",stdin);
   cin>>n;
   for(int i = 0; i < n; i++)
   {
       int t;
       cin>>t;
       if(t%4==0) _++;
       else if(t%2==0) __++;
       else ___++;
   }
   if(_>=(n>>1) || _ >= ___) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  if (N % 2 == 0 && S.substr(0, N / 2) == S.substr(N / 2, N / 2)) {
    print("Yes");
  } else {
    print("No");
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

new_h = [0] + h + [0]
# print(zero_h)
new_N = N + 2

zero_h = [0 for _ in range(new_N)]
counter = 0
flag = False
while_counter = 0
while(new_h != zero_h):
    # while_counter += 1
    # if while_counter > 15:
    #     break
    # print(new_h)
    for i in range(new_N):
        if flag == False:
            if new_h[i] == 0:
                start = i + 1
                flag = True
        elif flag == True:
            if new_h[i] == 0:
                end = i
                if new_h[start:end] == []:
                    start = i + 1
                    flag = True
                    pass
                else:
                    flag = False
                    new_h[start:end] = [new_h[i]-1 for i in range(start,end)]
                    counter += 1

print(counter)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll a,b,c;
    cin >> a >> b >> c;
    string res = "No";
    if(a<b){
        if(a<c && c<b) res = "Yes";
    }else{
        if(b<c && c<a) res = "Yes";
    }
    cout << res << endl;
}

Measured memory_bytes: 3652
from sys import stdin
a = int(stdin.readline())
b = int(stdin.readline())
c = int(stdin.readline())
n = int(stdin.readline())
ans = 0
for i in xrange(a+1):
 for j in xrange(b+1):
  for k in xrange(c+1):
   if i * 500 + j*100 + k*50 ==n:
    ans+=1
print ans

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;
typedef long long ll;
const ll INF=1e+7;
const ll MAX=206005;
char s[MAX];
ll n,cnt[26],ans;
int main(){
    scanf("%s",s);
    n=strlen(s);
    for(ll i=0;i<n;i++) cnt[s[i]-'a']++;
    ans=n*(n+1)/2+1;
    for(ll i=0;i<26;i++) ans-=cnt[i]*(cnt[i]+1)/2;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<queue>
using namespace std;

int main(){
    map<string,int> dp;
    string g = "123456780";
    string t = "";
    for(int i = 0; i < 9; i++){
        char c; cin >> c;
        t += c;
    }
    dp[t] = 0;
    queue<string> q;
    q.push(t);
    while(!q.empty()){
        string s = q.front();   q.pop();
        int now = dp[s];
        if(s == g){
            cout << dp[s] << endl;
            return 0;
        }
        for(int i = 0; i < 9; i++){
            if(i%3==2)  continue;
            if(s[i] != '0' && s[i+1] != '0')    continue;
            swap(s[i], s[i+1]);
            if(dp.count(s) == 0){
                dp[s] = now+1;
                q.push(s);
            }
            swap(s[i], s[i+1]);
        }
        for(int i = 0; i < 6; i++){
            if(s[i] != '0' && s[i+3] != '0')    continue;
            swap(s[i], s[i+3]);
            if(dp.count(s) == 0){
                dp[s] = now+1;
                q.push(s);
            }
            swap(s[i], s[i+3]);   
        }
    }
}


Measured memory_bytes: 23280
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>// accumulate

using namespace std;
typedef long long ll;

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

  int N=s.size()+1;

  vector<int> c(N,0);

  for(int i=0;i<N-1;i++){
    if(s[i]=='<'){
      c[i+1]=max(c[i]+1,c[i+1]);
    }
  }
  //for(int i=0;i<N-1;i++) cout << c[i] << s[i]; cout << c[N-1] << endl;
  for(int i=N-1;0<=i;i--){
    if(s[i]=='>'){
      c[i]=max(c[i],c[i+1]+1);
    }
  }
  //for(int i=0;i<N-1;i++) cout << c[i] << s[i]; cout << c[N-1] << endl;

  cout << accumulate(c.begin(),c.end(),(ll)0) << endl;

  return 0;
}

Measured memory_bytes: 2820
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    // リーダーより右は全員Wになる
    // 左は全員Eになるべき
    let W = 0;
    let E = S.filter(n=>n === "E").length;
    
    if(E === N || E === 0) {
        console.log(0);
        return;
    }
    
    let answer = Infinity;
    
    for(let i=0; i<N; i++) {
        let toE = 0;
        let toW = 0;
        
        if(S[i] === "E") {
            E--;
        }
    
        if(E > 0) {
            toW = E;
        }
        
        if(W > 0) {
            toE = W;
        }
        
        const temp = toE + toW;
        answer = Math.min(answer, temp);
        
        if(S[i] === "W") {
            W++;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 24708
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
#define MOD 1000000007
LL mod_pow(int x,int n){
	LL X=x;
	LL ans=1;
	while (n>0){
		if((n&1)==1)ans=(ans*X)%MOD;
		X=(X*X)%MOD;
		n>>=1;
	}
	return ans;
}
int main() {
	int N,K;
	cin >>N>>K;
	vector<LL> gcd_exact(K+1);
	LL ans=0;
	for (int X = K; X > 0; X--){
		gcd_exact[X]=mod_pow(K/X,N);
		int s=2;
		while (s*X<=K)
		{
			gcd_exact[X]=(gcd_exact[X]+MOD-gcd_exact[s*X])%MOD;
			s++;
		}
		ans=(ans+X*gcd_exact[X])%MOD;
	}
	cout<<ans<<endl;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T &val) {
    fill((T *)ary, (T *)(ary + size), val);
}

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 r;
    cin >> r;
    cout << 3*r*r << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    while (N--) {
        ll A;
        cin >> A;
        if (A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
            cout << "DENIED\n";
            return 0;
        }
    }

    cout << "APPROVED\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
ll dp[4000][4000][6];
int _mp[4000][4000];
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int R, C, K;
  cin >> R >> C >> K;
  REP(i, K) {
    int r, c, k;
    cin >> r >> c >> k;
    _mp[r][c] = k;
  }
  for (int i = 1; i <= R; i++) {
    for (int j = 1; j <= C; j++) {
      for (int k = 3; k >= 0; k--) {
        chmax(dp[i][j][1], dp[i - 1][j][k] + _mp[i][j]);
        chmax(dp[i][j][k], dp[i][j - 1][k]);
        chmax(dp[i][j][k + 1], dp[i][j - 1][k] + _mp[i][j]);
      }
      int a = 10;
    }
  }

  ll ans = 0;
  REP(i, 4) { chmax(ans, dp[R][C][i]); }
  cout << ans << endl;
}

Measured memory_bytes: 483144
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int n;
	cin >> n;
	double a = 0;
	double b = 1;
	vector<int>v(n);
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		v[i] = x;
		b *= x;
	}
	for (int i = 0; i < n; ++i) {
		a += (b/v[i]);
	}
	double ans = b/a;
	cout << fixed << setprecision(12) << ans;
}



















Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

int main(){
    ll x,y;
    cin>>x>>y;
    ll leng = 0;
    while(x <= y){
        x *= 2;
        leng++;
    }
    cout<<leng<<endl;
    return 0;
}

Measured memory_bytes: 3636
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var L = one[0];
  var R = one[1];
  if(R - L >= 2019){
     myout(0);
    return;
  }
  L %= 2019;
  R %= 2019;
  if(L >= R || L == 0 || R == 0){
     myout(0);
    return;
  }
  myerr(L);
  myerr(R);
  var output = 2020;
  for(var i = L; i < R; i++){
    for(var j = i + 1; j <= R; j++){
      var tmp = (i * j) % 2019;
      output = Math.min(output, tmp);
    }
  }
  myout(output);
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'


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


const int MOD = 1000000007;

//////////////////////////////////////////

string s;
int n, k;

void Input() {

    cin >> n >> k;
    cin >> s;
}

void Solve() {


    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();
  return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main()
{
	int D, T, S;
	cin >> D >> T >> S;

	int val = D - T * S;
	if (val <= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################
 
#####ide_ele#####
ide_ele = 0
#################
 
class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
 
    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1
 
    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele
 
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
# coding: utf-8
# Your code here!
a = input().split()
N = int(a[0])
M = int(a[1])
a = []
k = [int(input()) for i in range(N)]
 
temp = int(0)
 
for i in range(300001):
    a.append(0)
    
seg = SegTree(a, segfunc, ide_ele)
 
for i in range(N):
    temp = seg.query(max(0, k[i]-M), min(300001, k[i]+M+1))
    seg.update(k[i], temp+1)
 
print(seg.query(0,300001))

Measured memory_bytes: 137308
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned int  ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
	        res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
} 
#define MAXN   1000001 

int spf[MAXN]; 

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 

        spf[i] = i; 
 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
unordered_map<int, int> dp;
int numFactors(int x) 
{ 
	if(dp.count(x) > 0)
		return dp[x];
	unordered_map<int, int> p;
	int xx = x; 
    while (x != 1) 
    { 
        p[spf[x]]++; 
        x = x / spf[x]; 
    } 
    int ret = 1;
    for(auto it: p){
    	ret *= (it.second + 1);
    }
    return dp[xx] = ret; 
} 
signed main(){
	FASTIO
	sieve();
	int n;
	cin >> n;
	int ans = 0;
	for(int c = 1; c < n; c++){
		int d = n - c;
		ans += numFactors(d);
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 50420
import math
n, d = map(int, input().split())

x = []
for i in range(n):
    a = list(map(int, input().split()))
    x.append(a)

count = 0
for i in range(n):
    for j in range(i+1,n):
        l = 0
        for k in range(d):
            l += (x[i][k] - x[j][k])**2
        if(math.sqrt(l).is_integer()):
            count += 1
print(count)

Measured memory_bytes: 38384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <cmath>
# include <functional>
# include <utility>
#include <iomanip>

# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
int main() {
	int dp[100001];
	int n;
	cin >> n;
	//memset(dp,9999999999 , sizeof(dp));
	
	//memsetの短所をジョージに聞く!!!!!!
	
	for (int i = 0; i <= n; i++)dp[i] = 99999999999;


	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int six = 1; i + six <= n; six *= 6) {
			dp[i + six] = min(dp[i] + 1, dp[i + six]);
		}
		for (int nine = 1; i + nine <= n; nine *= 9) {
			dp[i + nine] = min(dp[i] + 1, dp[i + nine]);
		}
	}
	
		cout << dp[n] << endl;
	
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int cards[4][13], n, i, j, rank;
    char type;
    
    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
             cards[i][j] = 0;
         }
     }


    scanf("%d\n", &n);
    
    for(n; n > 0; n--){
        scanf("%c %d\n", &type, &rank);
        if(type == 'S') i = 0;
        else if (type == 'H') i = 1;
        else if (type == 'C') i = 2;
        else if (type == 'D') i = 3;
        j = rank -1;
        cards[i][j] = 1;
    }
    
    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
            if(cards[i][j] == 0){
                if(i == 0) type = 'S';
                else if (i == 1) type = 'H';
                else if (i == 2) type = 'C';
                else if (i == 3) type = 'D';
                rank = j + 1;
                printf("%c %d\n", type, rank);
            }
        }
    }
    return 0;
}

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

struct Node{
  int key;
  struct Node *p,*l,*r;
};

struct Node *root,*NIL;

void insert(int);
void inorder(struct Node*);
void preorder(struct Node*);
int main(){
  int m,x;
  int i;
  char k[10];

  scanf("%d",&m);
  for(i=0; i < m; i++){
    scanf("%s",k);
    if(strcmp(k,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(k,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int a){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=((struct Node *)malloc(sizeof(struct Node)));
  z->key=a;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->l;
    else x=x->r;
  }
  z->p=y;

  if(y==NIL) root=z;
  else {
    if(z->key < y->key){ 
      y->l=z;
    }
  else y->r =z;
  }
}

void inorder(struct Node *x){
  if(x == NIL) return;
  inorder(x->l);
  printf(" %d",x->key);
  inorder(x->r);
}

void preorder(struct Node *x){
  if(x==NIL) return;
  printf(" %d",x->key);
  preorder(x->l);
  preorder(x->r);
}

Measured memory_bytes: 24036
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;

int A,B;
int now_plug;
int tap_count = 0;

int main(){
  
  cin>>A>>B;
  
  now_plug = 1;
  
while(now_plug < B){
  now_plug += A;
  --now_plug;
  ++tap_count;
}
  
  cout<<tap_count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
// long long型の整数定数 大きな整数を扱うときに使う　慣習みたいなもの
using ll = long long;
// map splitみたいなもんなんかな？
using P = pair<int,int>;
 
int main() {
    //   変数を指定
  int a, b;
  //   c言語を使って入力 >>で入力in　<<で出力out
  cin >> a >> b;
  //   endlは開業
  cout << a*b << endl;
  //   pythonでいうところのbreakみたいなもん
  return 0;
}

Measured memory_bytes: 3552
H, W = [int(i) for i in input().split()]
d = {}
for _ in range(H):
    for a in input():
        if not a in d:
            d[a] = 1
        else:
            d[a] += 1
count = [0, 0, 0, 0, 0]
for v in d.values():
    for i in [4, 2, 1]:
        count[i] += v // i
        v %= i
for i, n in zip([4, 2, 1], [(H // 2) * (W // 2), H % 2 * W // 2 + W % 2 * H // 2, H % 2 * W % 2]):
    if count[i] < n:
        break
    count[i // 2] += (count[i] - n) * 2
else:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <cmath>
#define vi vector<int>


using namespace std;
int main(void) {
  vi num(5);
  int k;
  
  bool det = false;
  cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4] >> k;
  for(int tmp1 = 0; tmp1 <= 4; tmp1++) {
    for(int tmp2 = 0; tmp2 <= 4; tmp2++) {
      if(num[tmp2] - num[tmp1] > k) {
        det = true;
      }
    }
  }
  
  if(det == false) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    bool a = 0, b = 0;
    int n1 = 0, n2 = 0;
    for (int i = 0; i < 2; i++){
        n1 = n1 * 10 + (int) s[i] - 48;
    }
    for (int i = 2; i < 4; i++){
        n2 = n2 * 10 + (int) s[i] - 48;
    }
    if (n1 <= 12 && n1 != 0){
        a = 1;
    }
    if (n2 <= 12 && n2 != 0){
        b = 1;
    }
    // cts(n1); ctn(n2);
    // cts(a); ctn(b);
    if (a && b){
        ctn("AMBIGUOUS");
    }
    else if (a){
        ctn("MMYY");
    }
    else if (b){
        ctn("YYMM");
    }
    else{
        ctn("NA");
    }
    return 0;
}


Measured memory_bytes: 3632
# 169A
# 値 A × B を整数として出力せよ

# 1. 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
# print(a, b)

# 2. 受け取った入力値を使って、適切に処理（計算）すること
answer = a * b

# 3. 計算した結果を出力すること
print(answer)


Measured memory_bytes: 8900
n, m = list(map(int, input().split()))

s = [0] * (n + 1)
e = [0] * (n + 1)

for _ in range(m):
    l, r = list(map(int, input().split()))
    s[l] += 1
    e[r] += 1

ans = 0
cnt = 0
for i in range(1, n + 1):
    cnt = cnt + s[i] - e[i - 1]
    if cnt == m:
        ans += 1

print(ans)


Measured memory_bytes: 4596
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 3e3 + 7;
const ll inf = 1e9 + 5;





string s, t;
ll dp[N][N];
int main()
{
    MohamedMotaz;
    cin >> s >> t;
    memset(dp, 0, sizeof(dp));
    f(i, 1, s.size() + 1){
        f(j,1,t.size() + 1){
            if (s[i - 1] == t[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    //f(i,1,s.size() + 1) {f(j,1,t.size() + 1) cout << dp[i][j] << " "; cout << endl;}

    ll a = s.size() , b = t.size() ;
    string ans = "";

    while (a && b){
        if (dp[a][b] == dp[a -1][b]) a--;
        else if (dp[a][b] == dp[a][b - 1]) b--;
        else {ans.push_back(s[a - 1]);
        a--; b--;}
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}





Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int sum = 0, total = 0;
    int cnt = 0;
    while(cin >> s)
    {
        int a, b;
        for(int i = 0; i < s.size(); i++) if(s[i] == ',') a = stoi(s.substr(0, i)), b = stoi(s.substr(i + 1));
        sum += a * b;
        total += b;
        cnt++;
    }
    cout << sum << "\n" << (total + cnt - 1) / cnt << "\n";
    return 0;
}




Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define sevensins ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod  1000000007
#define vect vector<long long int>
#define bins binary_search
#define vecti vector<int>::iterator
#define bitout __builtin_popcount
#define binsrch binary_search
int main() 
{sevensins
ll t,i,j,k,l,n;
cin>>t;
cout<<fixed << setprecision(20) <<2*3.141592653589793*t<<"\n";
return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int cf;
int main()
{
    int l,r;
    cin>>l>>r;
    for(int i=l;i<=r;i++)
    {
        if(i==0)
        {
            cout<<"Zero"<<endl;
            return 0;
        }
        if(i<0)
        {
            cf++;
        }
    }
    if(cf%2==0)
    {
        cout<<"Positive"<<endl;
        return 0;
    }
    cout<<"Negative"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#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 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; cin >> n;
    map<pair<ll, ll>, ll> cnt;
    set<pair<ll, ll>> st;
    vi x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
        st.insert(make_pair(x[i], y[i]));
    }
    rep(i, n){
        rep(j, n){
            if(i == j) continue;
            // i -> j となるp, qを候補に登録
            ll p = x[j] - x[i];
            ll q = y[j] - y[i];
            cnt[make_pair(p, q)]++;
        }
    }

    ll maxCnt = 0;
    ll p = 0, q = 0;
    for(auto &tcnt: cnt){
        if(tcnt.second > maxCnt){
            maxCnt = tcnt.second;
            p = tcnt.first.first;
            q = tcnt.first.second;
        }
        else if(tcnt.second == maxCnt){
            if(p < tcnt.first.first){
                p = tcnt.first.first;
                q = tcnt.first.second;
            }
        }
    }

    cout << n-maxCnt << endl;
}

Measured memory_bytes: 3748
#include <iostream>
using namespace std;
 
int main() {
 
  int n;
  cin >> n;
  int ans = 0;
  for(int i=0;i<n;i++) {
    int s;
    cin >> s;
 
    int flg = 0;   
    for(int j=1;j*j<=s ;j++) {
      if( ((s-j)%(2*j+1) == 0 )){//&& 2*((s-j)/(2*j+1))*j+(s-j)/(2*j+1)+j == s ) {
    //  cout <<s<<" "<< j << endl;
    flg = 1;
    break;
      }
    }
     
    if(flg == 0) ans++;
  }
  cout << ans <<endl;
 
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define INT long long
using namespace std;
INT n, a[200020], b[200020], c[200020], ans;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ ) cin>>a[i];
    for(int i = 0 ; i < n ; i++ ) cin>>b[i];
    for(int p = 0 ; p < 29 ; p++ )
    {
        INT T = (1<<p), flag = 0;
        for(int i = 0 ; i < n ; i++ ) c[i] = b[i]%(2*T);
        sort(c, c+n);
        for(int i = 0 ; i < n ; i++ )
        {
            flag += (int)(lower_bound(c, c+n, 2*T-(a[i]%(2*T))) - lower_bound(c, c+n, T-(a[i]%(2*T)))) - 1;
            flag += (int)(lower_bound(c, c+n, 4*T-(a[i]%(2*T))) - lower_bound(c, c+n, 3*T-(a[i]%(2*T)))) - 1;
        }
        if( flag%2 ) ans |= (1<<p);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 4100;

int n;
int a[MAXN];
int c[MAXN];
int dp[MAXN][MAXN];
int dd[MAXN][2][MAXN];
int pos[2][MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n * 2; ++i) {
		char ch;
		cin >> ch >> a[i];
		--a[i];
		if (ch == 'W')
			c[i] = 0;
		else
			c[i] = 1;
		pos[c[i]][a[i]] = i;
	}
	for (int i = 0; i < 2 * n; ++i) {
		for (int j = 0; j < i; ++j) {
			++dd[i][c[j]][a[j] + 1];
		}
		for (int j = 0; j < n; ++j) {
			dd[i][0][j + 1] += dd[i][0][j];
			dd[i][1][j + 1] += dd[i][1][j];
		}
	}
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			dp[i][j] = int(1e9);
	dp[0][0] = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			if (i < n) {
				int x = pos[0][i];
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + dd[x][0][n] - dd[x][0][i] + dd[x][1][n] - dd[x][1][j]);
			}
			if (j < n) {
				int x = pos[1][j];
				dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + dd[x][0][n] - dd[x][0][i] + dd[x][1][n] - dd[x][1][j]);
			}
		}
	}
	cout << dp[n][n] << "\n";
	return 0;
}




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

int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    int c = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == t[i])
            c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#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;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;
int main()
{
    string L;
    cin >> L;

    int N = (int)L.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(2, 0));
    dp[0][0] = 1;

    rep(i, N) {
        int n = L[i] - '0';
        rep(j, 2) {
            for (int d = 0; d <= (j ? 1 : n); d++) {
                int k = (d ? 2 : 1);
                dp[i + 1][j || (d < n)] += dp[i][j] * k;
                dp[i + 1][j] %= MOD;
            }
        }
    }

    cout << (dp[N][0] + dp[N][1]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 8788
#include<bits/stdc++.h>
#include<bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(ll i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define srt(vec) sort(vec.begin(),vec.end())
#define mod 1000000007
#define MAX 100005
#define M 32
#define endl "\n"
using namespace std;
ll pow1(ll a,ll b){if(b==0) return 1; ll p=pow1(a,b/2);if(b%2) return ((p*p))*a;return (p*p);}
ll pow2(ll a,ll b){if(b==0) return 1; ll p=pow2(a,b/2);if(b%2) return (((p*p)%mod)*a)%mod;return (p*p)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
int find1(int i,int dsu[]){if(dsu[i]==i) return i; dsu[i]=dsu[dsu[i]]; return find1(dsu[i],dsu);}
void union1(int i,int j,int dsu[]) {dsu[j]=find1(i,dsu);}
ll a[1000005];
double tree[4000020];


int main()
{
    int test;
    test=1;
    for(int z=0;z<test;z++)
    {
        int n;
        cin>>n;
        int p=0;
        fn(i,n)
        {
            int a;
            cin>>a;
            if(a%2==0)
            {
                if(a%3==0||a%5==0)
                {
                   p=0;
                }
                else
                {
                    p=1;
                    break;
                }
            }
        }
        if(p)
            cout<<"DENIED";
        else
            cout<<"APPROVED";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

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

			int n = sc.nextInt();
			int m = sc.nextInt();
			
			int[] heights = new int[n+1];
			
			for(int i = 0 ; i < n ; i++) {
				heights[i] = sc.nextInt();
			}
			
			
			Map<Integer, HashSet<Integer>> pathMap = new HashMap<Integer, HashSet<Integer>>();

			
			for(int i = 0 ; i < m ; i++ ) {
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				
				if ( pathMap.containsKey(a)) {
					pathMap.get(a).add(b);
				}
				else {
					pathMap.put(a, new HashSet<Integer>());
					pathMap.get(a).add(b);
				}
				
				if ( pathMap.containsKey(b)) {
					pathMap.get(b).add(a);
				}
				else {
					pathMap.put(b, new HashSet<Integer>());
					pathMap.get(b).add(a);
				}
			}
			
			int total = 0;
			//
			for(int i = 0 ; i < n ; i++ ) {
				
				boolean isGood = true;

				if ( pathMap.containsKey(i)) {
					
					HashSet<Integer> pathSet = pathMap.get(i);
					
					for(int j : pathSet) {
						if ( heights[i] <= heights[j] ) {
							isGood = false;
							break;
						}	
					}					
				}
				
				if ( isGood )
					total++;
			}
			
			System.out.println(total);

		}
	}
}

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

int main(){
 
  string S;
  
  cin >> S;
  
  int N = S.size();
  int cnt=0, ans=0;
  
   for(int i=0;i<N;i++){
     if(S[i] =='A'|| S[i]=='C'|| S[i]=='G'||S[i]=='T' ){
      cnt ++;
     }
     else{
       ans=max(ans,cnt);
       cnt = 0;
     }
   }

 ans=max(ans,cnt);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


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

  ll n;cin>>n;
  vector<vector<ll>>a(n,vector<ll>(n,-1));
  rep(i,n){
    ll m;cin>>m;
    rep(j,m){
      ll x,y;cin>>x>>y;
      x--;
      a[i][x]=y;
    }
  }
  ll res=0;
  rep(i,1<<n){
    bitset<16>ti=i;
    vector<ll>tf(n,-1);
    ll tres=0;
    ll f=1;
    rep(j,n){
      tf[j]=ti[j];
    }
    rep(j,n){
      if(tf[j]==0)continue;
      rep(k,n){
        if(a[j][k]==-1)continue;
        if(tf[k]!=-1&&a[j][k]!=tf[k]){f=0;break;}
        tf[k]=a[j][k];
      }
      if(f==0)break;
    }
    rep(j,n)if(tf[j]==1)tres+=tf[j];
    if(f){
      chmax(res,tres);
    }
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256