akhauriyash/Code-Regression huggingface dataset:
/**
 *    author: tanishq_code_c
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



void __print(int x) {cerr << x;}; void __print(long x) {cerr << x;}; void __print(long long x) {cerr << x;}; void __print(unsigned x) {cerr << x;}; void __print(unsigned long x) {cerr << x;}; void __print(unsigned long long x) {cerr << x;}; void __print(float x) {cerr << x;}; void __print(double x) {cerr << x;}; void __print(long double x) {cerr << x;}; void __print(char x) {cerr << '\'' << x << '\'';}; void __print(const char *x) {cerr << '\"' << x << '\"';}; void __print(const string &x) {cerr << '\"' << x << '\"';}; void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif


#define int                                         long long
#define setbits(x)                                  __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                         10000007
#define inf                                         1e18
#define endl                                        '\n'
#define pb                                          push_back
#define all(x)                                      x.begin(),x.end()
#define ff                                          first
#define ss                                          second

int powmod(int a, int b) {int res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
int fast_pow(int a, int b) {if (b == 1) return a; if (b == 0) return 1; int x = fast_pow(a, b / 2); x *= x; if (b & 1) x *= a; return x;}

void t_c_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    /*#ifndef ONLINE_JUDGE
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
    int n; cin >> n;
    int cnt = 0;
    bool c = 0;
    while (n--) {
        int a, b; cin >> a >> b;
        if (a == b) cnt++;
        else cnt = 0;
        if (cnt >= 3) c = 1;
    }
    if (c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int32_t main()
{
    t_c_c();
    return 0;
}


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

ll mypow(ll a,ll b){
  ll res=1;
  for(ll i=0;i<b;i++)
    res*=a;
  return res;
}

string s;
int len;
ll dp[20][10][10][10][2];

ll rec(int d,int x,int y,int z,int f){
  if( d== len )return 0;

  if( dp[d][x][y][z][f]!=-1 )return dp[d][x][y][z][f];
  
  int left=0,right=9;
  if(f)right=s[d]-'0';

  ll res=0;
  for(ll i=left;i<=right;i++){
    int nf=f;
    if(i < right)nf=0;
    if( x==5 && y==1 && i==3 ){
      ll last=len-d-1;
      if(nf==1){
        ll num=0;
        for(int j=d+1;j<len;j++)num=num*10LL + ( s[j]-'0');
        res+=(num+1);
      }else{
        res+= mypow(10,last);
      }
    }else{
      res+=rec(d+1,y,z,i,nf);
    }
  }
  
  return dp[d][x][y][z][f]=res;
}

int main(){
  for(int i=0;i<20;i++)
    for(int j=0;j<10;j++)
      for(int k=0;k<10;k++)
        for(int l=0;l<10;l++)
          for(int m=0;m<2;m++)
            dp[i][j][k][l][m]=-1;
  
  cin>>s;
  len=s.size();
  cout<< rec(0,0,0,0,1) <<endl;
  return 0;
}



Measured memory_bytes: 3536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

	int ans = 0;

	for (int i = 1; i <= n; ++i)
	{
		int x; cin >> x;

		if ((x & 1) && (i & 1))
			ans++;
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3612
from collections import deque
def f(s,t):
  if s>t:
    a=s
    s=t
    t=a
  return n*(s-1)-s*(s-1)//2+t-s-1
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
E=[[] for i in range(n*(n-1)//2)]
EE=[[] for i in range(n*(n-1)//2)]
B=[0]*(n*(n-1)//2)
for i in range(n):
  for j in range(n-2):
    u=f(i+1,A[i][j])
    v=f(i+1,A[i][j+1])
    EE[u].append(v)
    E[v].append(u)
    B[v]+=1
D=deque([])
V=[0]*(n*(n-1)//2)
F=[10**9]*(n*(n-1)//2)
for i in range(n*(n-1)//2):
  if B[i]==0:
    D.append(i)
    V[i]=1
    F[i]=1
while len(D)>0:
  x=D[0]
  D.popleft()
  for i in range(len(EE[x])):
    B[EE[x][i]]-=1
    if B[EE[x][i]]==0:
      D.append(EE[x][i])
      F[EE[x][i]]=F[x]+1
      V[EE[x][i]]=1
ans=-1
for i in range(n*(n-1)//2):
  if F[i]>ans:
    ans=F[i]
if ans==10**9:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 204764
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map(String::toInt)

    var result = 0

    for (i in 0 until n) {
        if (d[i] == 0) continue
        for (j in i until n) {
            if (i != j) {
                result += d[i] * d[j]
            }
        }
    }

    println(result)
}

Measured memory_bytes: 38060
#include <stdio.h>

int main(void) {
	int i, j, k, n, x, count;
	/*
	1 から n までの数の中から、重複無しで３つの数を選び
	それらの合計が x となる組み合わせの数を求めるプログラムを作成して下さい。 
	*/
	
	while(scanf("%d %d\n", &n, &x) == 2) {
		if(!n && !x) break;
		
		count = 0;
		for(i=1;i<=n-2;i++) {
			for(j=i+1;j<=n-1;j++) {
				for(k=j+1;k<=n;k++) {
					if(i+j+k==x) {
						count ++;
					}
				}
			}
		}
		
		printf("%d\n", count);
		
		
	}
	return 0;
}

Measured memory_bytes: 604
N, M = map(int, input().split())
P = list(map(int, input().split()))

parent = list(range(N))
rank = [0] * N

idx = [None] * N
for i in range(N):
  idx[P[i]-1] = i

# union-find
def getRoot(x):
  p = parent[x]
  if p == x:
    return p
  ret = getRoot(p)
  parent[x] = ret
  return ret

def join(x, y):
  rx = getRoot(x)
  ry = getRoot(y)
  if rank[rx] < rank[ry]:
    parent[rx] = ry
  else:
    parent[ry] = rx
    if rank[rx] == rank[ry]:
      rank[rx] += 1

for _ in range(M):
  x, y = map(int, input().split())
  join(x-1, y-1)

ans = 0
for i in range(N):
  if getRoot(i) == getRoot(idx[i]):
    ans += 1

print(ans)

Measured memory_bytes: 16180
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)
#define ll LL
#define st f
#define nd s
#define pb PB
#define mp MP
#define eb emplace_back
#define siz(c) SIZ(c)
const int inf = 1e9+7;
const ll INF = 1e18L+7;

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

map<int, int> M;
int main()
{
  int n;
  cin >> n;

  LL res = 0;
  FOR(i, 1, n)
    {
    int h;
    cin >> h;
    res += M[h - i];

    M[-h-i]++;
    }
  cout << res << endl;
}


Measured memory_bytes: 20456
N,M = map(int,input().split())

a = [int(input())-1 for _ in range(M)]
T = 1
for i in range(M-1):
    if a[i]+1 == a[i+1]:
        T = 0
        break
if T == 0:
    print(0)
else:
    if N == 1:
        if M==0:
            print(1)
        else:
            print(0)
    else:
        L = [0 for _ in range(N)]
        for i in range(M):
            L[a[i]] = -1
        if L[0] == -1:
            L[1] = 1
        else:
            L[0] = 1
            if L[1] != -1:
                L[1] = 2
        for i in range(2,N):
            if L[i] != -1:
                if L[i-2] == -1:
                    L[i] = L[i-1]%1000000007
                elif L[i-1] == -1:
                    L[i] = L[i-2]%1000000007
                else:
                    L[i] = (L[i-1]+L[i-2])%1000000007
        print(L[-1])

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = (1 << 30) - 1;
const ll LINF = (1L << 62) - 1;
const ll MOD = 1000000007;
template <class T> inline void chmin(T& a, T& x) { a = a < x ? a : x; }
template <class T> inline void chmax(T& a, T& x) { a = a > x ? a : x; }

vector<ll> a;

void dfs(int n, ll t) {
  if (n == 10) {
    a.push_back(t);
    return;
  }
  int x = t % 10;
  if (x > 0) dfs(n + 1, t * 10 + x - 1);
  if (x < 9) dfs(n + 1, t * 10 + x + 1);
  dfs(n + 1, t * 10 + x);
  a.push_back(t);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  for (ll i = 1; i < 10; ++i) {
    dfs(1, i);
  }
  sort(all(a));
  cout << a[k - 1] << endl;
  return 0;
}


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

int main(){
    string s;
    int s_l, i;
    int p_a, p_z;
    bool a_flag = false;

    cin >> s;
    s_l = s.length();

    for (i=0; i < s_l; i++){
    if (s[i] == 'A' && a_flag != true){
        p_a = i;
        a_flag = true;
    }
    if (s[i] == 'Z')
        p_z = i;
    }

    cout << p_z-p_a+1 << '\n';

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
 
int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
 
	string s,t;
	int a,b;
	cin>>s>>t>>a>>b;
	string u;
	cin>>u;
	if(u==s)	a--;
	else b--;
	cout<<a<<' '<<b;
	
	return 0;	
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  string S;
  cin >> S;
  sort(all(S));
  char alp = 'a';
  rep(i, S.size()){
    if(S.at(i) == alp){
      alp++;
    }
    else if(S.at(i) > alp){
      cout << alp << endl;
      return 0;
    }
  }
  if(S.at(S.size()-1) == 'z'){
    cout << "None" << endl;
  }
  else{
    cout << alp << endl;
  }
}


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

int main(){
    int H1,H2,M1,M2,K;
    cin>>H1>>M1>>H2>>M2>>K;

    int ans=0;
    int tmp;

    if(H2 == H1) tmp = M2-M1;
    else tmp = (H2 - H1 - 1)*60 + 60 - M1 + M2;

    ans = tmp - K;
    if(ans < 0) ans = 0;
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e6+10;
int n,tot,son[N][26],cnt[N],flag[26];
vector<char>v[N];
char s[N];

int main(){
	n=read();
	For(i,1,n){
		scanf("%s",s+1);
		int len=strlen(s+1),u=0;
		Dow(j,len,1){
			if (!son[u][s[j]-'a']) son[u][s[j]-'a']=++tot;
			u=son[u][s[j]-'a'];
		}
		cnt[u]++;
		For(j,1,len) v[i].pb(s[j]); 
	}
	ll ans=0;
	For(i,1,n){
		For(j,0,25) flag[j]=0;
		for (auto j:v[i]) flag[j-'a']++;
		int u=0;
		Dow(j,siz(v[i])-1,0){
			For(k,0,25) if (flag[k]&&son[u][k]) ans+=cnt[son[u][k]];
			u=son[u][v[i][j]-'a'],flag[v[i][j]-'a']--;
		} 
		ans--;
	}
	printf("%lld\n",ans);
}

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

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int n,m;
	cin>>n>>m;
	while(n--) {
		string s;
		cin>>s;
		cout<<s<<"\n"<<s<<"\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N, K, t[40000], p,dp1[111][40000],dp2[111][40000];

int main() {
	cin >> N >> K;
	for (int i = 1; i*i <= N; ++i) {
		t[i] = N / i;
		p = i;
	}
	for (int i = 1; i < p; ++i) {
		t[i] -= t[i + 1];
	}
	t[p] -= p;
	for (int i = 1; i <= p; ++i) {
		dp1[0][i] = 1;
		dp2[0][i] = t[i];
	}
	for (int i = 0; i < K; ++i) {
		for (int j = 1; j <= p; ++j) {
			dp2[i + 1][j] += dp1[i][j];
			dp1[i + 1][j] += dp2[i][j];
		}
		for (int j = 1; j <= p; ++j) {
			dp2[i + 1][j + 1] += dp2[i + 1][j];
			dp2[i + 1][j + 1] %= mod;
		}
		dp1[i + 1][p] += dp2[i + 1][p];
		dp1[i + 1][p] %= mod;
		for (int j = p - 1; j; --j) {
			dp1[i + 1][j] += dp1[i + 1][j + 1];
			dp1[i + 1][j] %= mod;
		}
		for (int j = 1; j <= p; ++j) {
			dp2[i + 1][j] *= t[j];
			dp2[i + 1][j] %= mod;
		}
	}
	cout << dp1[K][1] << endl;
}

Measured memory_bytes: 69504
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
v_odd = v[::2]
v_even = v[1::2]
c_odd = Counter(v_odd)
c_even = Counter(v_even)
ans = len(v)
for c_o, c_e in zip(c_odd.most_common(), c_even.most_common()):
    if c_o == c_e:
        continue
    else:
        ans -= max(c_o[1], c_e[1])
        ans -= min(c_odd.most_common()[0][1], c_even.most_common()[0][1])
        break
else:
    ans -= c_odd.most_common()[0][1]
    if len(c_even.most_common()[1:]) > 0:
        ans -= c_even.most_common()[1][1]

print(ans)

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

int main()
{
	int N, M, X, Y;
	scanf("%d%d%d%d", &N, &M, &X, &Y);

	int i, j, k, x[N], y[M];
	for (i = 0; i < N; i++) 
		scanf("%d", &x[i]);
	for (j = 0; j < M; j++)
		scanf("%d", &y[j]);
	
	int max, min;
	for (max = x[0], i = 1; i < N; i++) {
		if (max < x[i])
			max = x[i];
	}
	for (min = y[0], i = 1; i < M; i++) {
		if (min > y[i])
			min = y[i];
	}

	if (X > max)
		max = X;
	if (Y < min)
		min = Y;

	if (min - max >= 1)
		printf("No War\n");
	else
		printf("War\n");

	return 0;
}


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

int main() {
  double L;
  cin >> L;
  double V;

  if((int)L%3==0) {
      V=(L/3)*(L/3)*(L/3);//((double)L/(double)3)*((double)L/(double)3)*((double)L/(double)3);
  } else {
      V=((double)L/(double)3)*((double)L/(double)3)*((double)L/(double)3);
  }/*if((int)L%3==1) {
      V=((int)L/3)*((int)L/3)*((int)L/3)+((int)L/3)*((int)L/3)+L/(double)9+(double)1/(double)27;
  } else {
      V=((double)L/(double)3)*((double)L/(double)3)*((double)L/(double)3);//V=((int)L/3)*((int)L/3)*((int)L/3)+((double)2/(double)3)*((int)L/3)*((int)L/3)+(L*(double)4)/(double)9+(double)8/(double)27;
  }*/

  cout << fixed << setprecision(6);
  cout << V << endl;
  
}

Measured memory_bytes: 256
from collections import Counter


n = int(input())
v = list(map(int, input().split()))

v_odd = []
v_even = []
for index in range(len(v)):
    i = index + 1
    if i % 2 == 0:
        v_even.append(v[index])
    else:
        v_odd.append(v[index])
# print(v_odd)
# print(v_even)
# print(Counter(v_odd).most_common())
# print(Counter(v_even).most_common())

odd_1st = Counter(v_odd).most_common()[0][1]
even_1st = Counter(v_even).most_common()[0][1]
if Counter(v_odd).most_common()[0][0] != Counter(v_even).most_common()[0][0]:
    number_of_rewrites = len(v_odd) - odd_1st
    number_of_rewrites += len(v_even) - even_1st
else:
    odd_2nd = Counter(v_odd).most_common()[1][1] if len(Counter(v_odd).most_common()) >= 2 else 0
    even_2nd = Counter(v_even).most_common()[1][1] if len(Counter(v_even).most_common()) >= 2 else 0

    number_of_rewrites = min(
        len(v_odd) - odd_1st + len(v_even) - even_2nd,
        len(v_odd) - odd_2nd + len(v_even) - even_1st,
    )

print(number_of_rewrites)


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	map<int, int> m;
	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		if (m[a]) m[a] = 0;
		else m[a]++;
	}
	
	int count = 0;
	for (auto x : m){
		if (x.second) count++;
	}

	cout << count << endl;

}


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int q;
    cin>>q;
    int c[n]={};
    while(q--){
        int t,x,d;
        cin>>t>>x>>d;
        x--;
        if(t==1){
            c[x] += d;
        }
        else c[x] -= d;
        if(c[x] > a[x] || c[x]<0){
            cout << x+1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3188
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long  A[100003], B[100003], C, D,a[3000], c[10], d[10], now, num, N, K, M, ans;
string S, s[100];
bool h,w[10], k[100];
char cc;


int main() {
	cin >> N;
	B[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		B[i] = A[i - 1] - A[i];
		ans += abs(B[i]);
	}
	B[N + 1] = A[N];
	ans += abs(B[N+1]);

	for (int i = 1; i <= N; i++) {
		cout << ans -(abs(B[i])+abs(B[i+1]))+abs(B[i]+B[i+1]) << endl;
	}
	return 0;

}

Measured memory_bytes: 2816
#include<stdio.h>

int main(void)
{
	int r, g, b;

	scanf("%d", &r);
	scanf("%d", &g);
	scanf("%d", &b);

	if ((g * 10 + b) % 4 == 0) {
		printf("YES");
	}
	else {
		printf("NO");
	}

	return(0);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var s, t string

func main() {
	sc.Split(bufio.ScanWords)
	s, t = nextStr(), nextStr()

	fmt.Println(t + s)
}


Measured memory_bytes: 640
n, p = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * 2
for num in a:
    cnt[num % 2] += 1

if cnt[1] == 0:
    if p == 0:
        print(2 ** n)
    else:
        print(0)

else:
    print(2 ** ( n - 1))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }


struct UnionFind {
    vector<int> data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    ll size(int k) {
        return (-data[find(k)]);
    }
};


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

    ll N, M; cin >> N >> M;
    vector<i_i> bridge(M);
    rep(i,M) {
        int a, b; cin >> a >> b; a--; b--; 
        bridge[i] = make_pair(a,b);
    }

    vel ans;
    ll max_huben = N * (N - 1) / 2LL;
    ans.pub(max_huben);
    
    UnionFind uf(N);

    for(int i = M - 1; i >= 1; i--) {
        i_i p = bridge[i];
        if(uf.find(p.fs) != uf.find(p.sc)) {  max_huben -= uf.size(p.fs) * uf.size(p.sc); uf.unite(p.fs, p.sc); }
        ans.pub(max_huben);
    }
    for(int i = M - 1; i >= 0; i--) cout << ans[i] << endl;

}



Measured memory_bytes: 3444
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
// 小大
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}
typedef struct{
    llint aa;
    llint bb;
}frequent;
// 小大
int cmp( const void *p, const void *q ) {
    return ((frequent*)p)->bb - ((frequent*)q)->bb;
}


int main(void){
    llint n,i,ans=0;
    scanf("%lld",&n);
    llint a[n];
    
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    qsort(a,n,sizeof(llint),compare);
    for(i=0;i<n-1;i++){
        if(a[i] == a[i+1]){
            ans+=2;
            i++;
        }
    }
    printf("%lld\n",n-ans);
    return 0;
}


Measured memory_bytes: 1788
#include<iostream>

using namespace std;


int main(){
	int n,i,j,k;

	while (1){
		j = 0;
		cin >> n;
		if (n == 0){
			break;
		}

		while (n != 1){
			j++;
			if (n % 2 == 0){
				n = n / 2;
			}else{
				n = n * 3 + 1;
			}
		}
		cout << j << endl;
	}

}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


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

	sort(s.begin(), s.end());
	string res = "yes";
	rep(i, s.size()-1) {
		if (s[i]==s[i+1]) res = "no";
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import math

import numpy as np

a, b = [int(v) for v in input().split()]


try:
    print(min(np.intersect1d(np.arange(math.ceil(a/0.08), (a+1) //0.08+ 1).astype(int), np.arange(math.ceil(b/0.1), (b+1)//0.1 + 1).astype(int))))

except:
    print(-1)


Measured memory_bytes: 20252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;
ll g[310][310];
bool a[310][310];

int main () {
  cin >> N;

  rep(i, N) {
    rep(j, N) cin >> g[i][j];
  }

  rep(i, N) {
    rep(j, N) {
      bool flg = false;
      rep(k, N) {
        if (k == i || k == j || i == j) {
          continue;
        } 

        if (g[i][j] > (g[i][k] + g[k][j])) {
          cout << -1 << "\n";
          return 0;
        } else if (g[i][j] == (g[i][k] + g[k][j])) {
          //cout << i << " " << j << "\n";
          //cout << i << " " << k << "\n";
          //cout << k << " " << j << "\n";
          //cout << "\n";
          //a[i][j] = false;
          //a[j][i] = false;
          //a[i][k] = true;
          //a[k][i] = true;
          //a[j][k] = true;
          //a[k][j] = true;
          flg = true;
        }
      }

      if (!flg) {
        a[i][j] = true;
        a[j][i] = true;
      }
    }
  }

  ll ans = 0;

  rep(i, N) {
    for(int j=i+1;j<=N;++j) {
      if (a[i][j]) {
        //cout << i << " " << j << "\n";
        ans += g[i][j];
      }
    }
  }

  cout << ans << "\n";

}

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

using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)

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

    if (s == t.substr(0, t.size()-1)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(){

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

    string buf;
    int ans = 0;
    int l, r;
    bool flg = true;

    for (int i=a; i<b+1; i++){
        buf = to_string(i);

        l = 0;
        r = buf.size() - 1;
        while (l<r){
            if (buf.at(l) != buf.at(r)){
                flg = false;
                break;
            }
            l++;
            r--;
        }
        if (flg == true){
            ans++;
        }
        flg = true;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef pair<ll, ll> l_l;
    typedef pair<int , int> i_i;
    typedef vector<ll> vl;
    typedef vector<int> vi;
    typedef vector<char> vec;
    typedef vector<bool> veb;
    typedef vector<string> ves;
    typedef vector<vector<ll>> vvl;
    typedef vector<vector<int>> vvi;
    typedef vector<vector<char>> vvec;
    typedef vector<vector<bool>> vveb;
    typedef vector<vector<string>> vves;
    #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 rep2(i,n) for(int i=2;i<(int)(n);i++)
    #define repk(i,k,n) for(int i=k;i<(int)(n);i++)
    #define fs first
    #define sc second
    #define pb push_back
    #define pp pop_back
    #define all(a) a.begin(),a.end()
    #define rall(a) a.rbegin(),a.rend()
    #define maxel(a) *max_element(all(a))
    #define minel(a) *min_element(all(a))
    #define acc accumulate
    #define EPS (1e-7)
    #define INF (1e18)
    #define PI (acos(-1))
    #define mod (1000000007)
    typedef long long int64;
    //const int64 INF = 1LL << 58;
    #define dame { puts("-1"); return 0;}
    #define YES { cout << "YES" << endl; return 0; }
    #define NO { cout << "NO" << endl; return 0; }
    #define Yes { cout << "Yes" << endl; return 0; }
    #define No { cout << "No" << endl; return 0; }
    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 (a>b) { a=b; return 1; } return 0; }
    int dx[] = {0, 0, -1, 1};
    int dy[] = {1, -1, 0, 0};
     
     
    ll search(ll x){
        ll d = INF;
        for(ll i = 1; i*i<=x ; i++){
            if(x%i==0){
            if(d>=(i+(x/i)-2)) d = i+(x/i)-2 ;      
            }
        }
        return d;
    }
     
    int main(){
    	cin.tie(0);
    	ios::sync_with_stdio(false);
     
        ll n;
        cin >> n;
        cout << search(n) << endl;    
        return 0;
     
    }

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

#define INF (1<<26)
#define MAX 100
struct state{  int a,b;};

int n,a,b;
map<int,bool> f[MAX];
vector<int> G[MAX];
int t[MAX][MAX];
bool visited[MAX][MAX];

void solve(int a,int b){
  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      visited[i][j]=false;

  queue<state> Q;
  Q.push((state){a,b});
  visited[a][b]=true;

  while(!Q.empty()){
    state s=Q.front();Q.pop();
    t[s.a][s.b]++;

    if(s.a+1<MAX&&!visited[s.a+1][s.b]){
      visited[s.a+1][s.b]=true;
      Q.push((state){s.a+1,s.b});
    }

    if(!f[s.a][s.b])continue;
    for(int i=0;i<(int)G[s.a].size();i++){
      state to=s;
      to.b=G[s.a][i];
      if(!visited[to.a][to.b]){
	visited[to.a][to.b]=true;
	Q.push(to);
      }
    }
  }
}

void init(){
  for(int i=0;i<MAX;i++){
    G[i].clear();
    f[i].clear();
    for(int j=0;j<MAX;j++){
      t[i][j]=0;
    }
  }
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    init();
    for(int i=0;i<n;i++){
      cin>>a;
      for(int j=0;j<a;j++){
	cin>>b;
	f[b][i]=true;
	G[b].push_back(i);
      }
    }

    for(int i=0;i<n;i++)solve(0,i);

    int ans=INF;
    for(int i=1;i<=30;i++)
      for(int j=0;j<n;j++)
	if(t[i][j]==n)ans=min(ans,i);
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1524
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int mod=998244353,N=1e5+5,G=3,Gi=332748118;
int a[N],b[N],n,m,ans,cho[N],fac[N],inv[N],rev[N],lim,l;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod;
	return res;
}

void init(int n){
	fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=fpow(fac[n],mod-2);for(int i=n-1;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	cho[0]=1;for(int i=2;i<=n;i+=2) cho[i]=1ll*cho[i-2]*(i-1)%mod;
}

int C(int n,int m){
	if(n<m||m<0) return 0;
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}

void ntt(vector<int> &a,int op){
	for(int i=0;i<lim;i++) if(i<rev[i]) swap(a[i],a[rev[i]]);
	for(int mid=1;mid<lim;mid<<=1){
		int w0=fpow(op==1?G:Gi,(mod-1)/(mid<<1));
		for(int len=mid<<1,i=0;i<lim;i+=len){
			int w=1;
			for(int j=0;j<mid;j++,w=1ll*w*w0%mod){
				int x=a[i+j],y=1ll*w*a[i+mid+j]%mod;
				a[i+j]=(x+y)%mod;
				a[i+mid+j]=(x-y+mod)%mod;
			}
		}
	}
}

vector<int> convo(vector<int> &va,vector<int> &vb){
	int n=va.size()-1,m=vb.size()-1;
	for(lim=1,l=0;lim<=n+m;lim<<=1) l++;
	for(int i=0;i<lim;i++) rev[i]=(rev[i>>1]>>1)|((i&1)<<l-1);
	vector<int> res,a(lim+1),b(lim+1);
	for(int i=0;i<=n;i++) a[i]=va[i];
	for(int i=0;i<=m;i++) b[i]=vb[i];
	ntt(a,1);
	ntt(b,1);
	for(int i=0;i<=lim;i++) a[i]=1ll*a[i]*b[i]%mod;
	ntt(a,-1);
	int inv=fpow(lim,mod-2);
	for(int i=0;i<=n+m;i++) res.push_back((1ll*a[i]*inv+mod)%mod);
	return res;
}

vector<int> dico(int l,int r){
	if(l==r){
		vector<int> f(b[l]/2+1);
		for(int i=0;i<f.size();i++) f[i]=1ll*C(b[l],i<<1)*cho[i<<1]%mod;
		//printf("#%d %d\n",l,r);
		//for(int i=0;i<f.size();i++) printf("%d ",f[i]);puts("");
		return f;
	}
	int mid=l+r>>1;
	vector<int> f=dico(l,mid),g=dico(mid+1,r);
	//printf("#%d %d\n",l,r);
	f=convo(f,g);
	//for(int i=0;i<f.size();i++) printf("%d ",f[i]);puts("");
	return f;
}

signed main(){
	read(n);n<<=1;
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+1+n);
	for(int l=1,r;l<=n;l=r+1){
		r=l;
		while(a[r+1]==a[l]) r++;
		b[++m]=r-l+1;
	}
	init(n);
	//for(int i=1;i<=m;i++) printf("%d ",b[i]);puts("");
	vector<int> f=dico(1,m);
	for(int i=0;i<f.size();i++){
		int x=1ll*f[i]*cho[n-i*2]%mod;
		if(i&1) ans=(ans-x)%mod;
		else ans=(ans+x)%mod;
	}
	write((ans+mod)%mod);
}

Measured memory_bytes: 6380
abcde = [int(input()) for i in range(5)]
tmp = zip(abcde, list(map(lambda x: 10 if x % 10 == 0 else x % 10, abcde)))
tmp = sorted(tmp, key=lambda x: x[1])
print(tmp[0][0] + sum(map(lambda x: x[0]+(10-x[1]), tmp[1:])))


Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
using namespace std;
long long d[102][1201][11];//最後に判断した数//合計//使用した個数

int f=0;
int main(){
	d[0][0][0]=1;
	d[0][0][1]=1;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=1000;j++){
			for(int k=0;k<=9;k++){
				d[i+1][j][k]+=d[i][j][k];
				d[i+1][j+i+1][k+1]+=d[i][j][k];
				
			}
		}
	}
	int n,s;
	while(cin>>n>>s,n){
		cout<<d[100][s][n]<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 11352
#include <bits/stdc++.h>
using namespace std;
int main () {
  long H, W;
  cin >> H >> W;
  vector<vector<long>> data(H, vector<long>(W, INT_MAX));
  char a;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a;
      if(a == '#')data.at(i).at(j) = 0;
    }
  }
  for(int i = 0; i < H; i++){
    for(int j = 1; j < W; j++){
      data.at(i).at(j) = min(data.at(i).at(j - 1) + 1, data.at(i).at(j));
    }
    for(int j = W - 2; j >= 0; j--){
      data.at(i).at(j) = min(data.at(i).at(j + 1) + 1, data.at(i).at(j));
    }
  }
  for(int i = 0; i < W; i++){
    for(int j = 1; j < H; j++){
      data.at(j).at(i) = min(data.at(j - 1).at(i) + 1, data.at(j).at(i));
    }
    for(int j = H - 2; j >= 0; j--){
      data.at(j).at(i) = min(data.at(j + 1).at(i) + 1, data.at(j).at(i));
    }
  }
  long ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      ans = max(ans, data.at(i).at(j));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

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

int abs(int p) {return p > 0 ? p : -p;}

int main()
{
	int i, t;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		t = lower_bound(a, a + n, b[i]) - a;
		c += abs(i - t) % 2;
	}
    cout << c / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 2005
using namespace std;
int p=0,num=0,idx;
string s[2];

struct Graph{
  int l,r,v;
};

Graph G[2][N];

int make_G(){
  int node=num++;
  G[idx][node].l=-1;
  G[idx][node].r=-1;
  G[idx][node].v=-1;
  if(s[idx][p++]==')')return node;
  G[idx][node].l=make_G();
  p++;
  int Num=0;
  while('0'<=s[idx][p]&&s[idx][p]<='9')
    Num=Num*10+s[idx][p]-'0',p++;
  p++;
  G[idx][node].v=Num;
  p++;
  G[idx][node].r=make_G();
  p++;
  return node;
}

void output(int x,int y){
  cout<<'(';
  if(G[0][G[0][x].l].v>=0&&G[1][G[1][y].l].v>=0)
    output(G[0][x].l,G[1][y].l);
  cout<<')';
  cout<<'['<<G[0][x].v+G[1][y].v<<']';
  cout<<'(';
  if(G[0][G[0][x].r].v>=0&&G[1][G[1][y].r].v>=0)
    output(G[0][x].r,G[1][y].r);
  cout<<')';
}

int main(){
  cin>>s[0]>>s[1];
  make_G();
  idx=1;
  p=0;
  int num2=num;
  make_G();
  output(0,num2);
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3208
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;
using namespace __gnu_pbds;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "  ";
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

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

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
    ll n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    for(ll i=1;i<=n;i++){
        if(i==k){
            cout<<(char)(str[i-1]-'A'+'a');
        }
        else{
            cout<<str[i-1];
        }
    }
    cout<<endl;
    return 0;
}






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

using namespace std;

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

    string ans;
    for(int i=0; i<s.size(); ++i){
        if(s[2] == s[3] && s[4] == s[5]) ans = "Yes";
        else ans = "No";
    }

    cout << ans << endl;
}

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

using namespace std;

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>> v(h+1,vector<char>(w+1,'#'));
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++)cin>>v[i][j];
  }
  vector<vector<int>> a(h+1,vector<int>(w+1,0));
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(i==1&&j==1)a[i][j]=1;
      else{
        if(v[i][j]=='.'){
          a[i][j]=(a[i-1][j]+a[i][j-1])%M;
        }
      }
    }
  }
  cout<<a[h][w];
}

Measured memory_bytes: 5248
use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, a: [usize; n - 1]);
    let mut a_v = vec![0usize; 200_001];
    for v in a {
        a_v[v - 1] += 1;
    }

    let ans = a_v.iter().take(n).join("\n");
    println!("{}", ans);
}


Measured memory_bytes: 6292
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A = list(map(int, input().split()))

    print('YES') if A.count(5) == 2 and A.count(7) == 1 else print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10412
#include <stdio.h>
int main()
{
    int a,max,min;
    int n,i;
    long long int sum=0;
    scanf("%d",&n);
    max=-1000000;
    min=1000000;
    for(i=1;i<=n;i++){
        scanf("%d",&a);
        if(min>a){min=a;}
        if(max<a){max=a;}
        sum=sum+a;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2120
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"

#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

int n;
ll a[100000], b[100000], cnt;

int main(){
	cnt = 0;
	cin >> n;
	lp(n)
		cin >> a[i] >> b[i];
	for (int i = n - 1; i >= 0; i--) {
		a[i] += cnt;
		if (a[i]) {
			cnt += b[i] - ((a[i] - 1) % b[i] + 1);
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

ll sz = 1e6 + 5;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	set<ll> st;
	rep(i, n) st.insert(a[i]);
	unordered_map<ll, ll> ump;
	rep(i, n) ump[a[i]]++;

	VecB ok(sz, true);

	for(ll i : st){
		for (ll j = 2; j * i < sz; ++j){
			ok[j * i] = false;
		} 
	}

	ll ans = 0;
	rep(i, n){
		if (ok[a[i]] && ump[a[i]] == 1) ans++;
	}
	co(ans);

	return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  queue<int> st;
  for(int i=0;i<n;i++){
    st.push(s[i]-'A');
  }
  int kaisu=1;
  for(;!st.empty()&&k>0;k--){
    if((st.front()+kaisu)%2){
      st.front()=1-st.front();
    }else{
      st.pop();
      kaisu++;
    }
  }
  if(st.empty()){
    if(n%2){
      if(k%2){
        printf("BB");
      }else{
        printf("AB");
      }
      for(int i=2;i<n-1;i+=2){
        printf("AB");
      }
      printf("A\n");
    }else{
      for(int i=0;i<n;i+=2){
        printf("BA");
      }
    }
    printf("\n");
  }else{
    int count=0;
    for(;!st.empty();count++){
      if((st.front()+kaisu)%2){
        printf("A");
      }else{
        printf("B");
      }
      st.pop();
    }
    if((n-count)%2){
      printf("A");
      count++;
    }
    for(;count<n;count+=2){
      printf("BA");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 1412
/* created   : 2019-11-05 23:16:49
 * accepted  : 2019-11-06 10:21:25
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  string s; cin >> s;
  int n = s.size();
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    if (s[i] == '<') {
      a[i + 1] = max(a[i + 1], a[i] + 1);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '>') {
      a[i] = max(a[i], a[i + 1] + 1);
    }
  }
  trace(s, n, a);
  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
}

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


Measured memory_bytes: 2844