akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all int i=0; i<n; i++
#define pb push_back
typedef long long int ll;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}
int ans = 0; int a,b,c;
void solve(){
	while(true){
		if(b>=1 && c>=2){
			ans+=3;
			b--;
			c-=2;
		}
		else break;
	}
	while(true){
		if(a>=1 && b>=2){
			ans+=3;
			b-=2;
			a--;
		}
		else break;
	}
	cout<<ans<<endl;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
  
    x = x % p;
  
    while (y > 0) 
    { 
        if (y & 1){
			res = (res*x) % p; 
			y--;
		}
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}
int main(){ 
 	int a,b;
 	cin>>a>>b;
 	cout<<max(0, a-2*b)<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define N 1000010
#define MAX 1234567890

void solve()
{
	ll n, x, t;
	cin >> n >> x >> t;
	cout << (n+x-1) / x * t << endl;
}

int main()
{
    fastio;
    
    solve();
    
	return 0;
}

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

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

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a.at(i);
  vector<ll> even = {-1},odd = {-1};
  rep(i,n){
    if(i%2==0){
      even.push_back(a.at(i));
    }else{
      odd.push_back(a.at(i));
    }
  }
  if(n%2==0)reverse(odd.begin(),odd.end());
  else reverse(even.begin(),even.end());

  if(n%2==0){
    rep(i,n/2)cout<<odd.at(i)<<" ";
    rep1(i,n/2)cout<<even.at(i)<<" ";
  }else{
    rep(i,n/2+1)cout<<even.at(i)<<" ";
    rep1(i,n/2)cout<<odd.at(i)<<" ";
  }
  cout<<endl;
  return 0;
}

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

// --- MOD begin --- cut here ---

ll MOD = 1e9 + 7;
// ll MOD = 998244353;

// g = eGCD(a, b, s, t)  --->  sa + tb = g
constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

constexpr ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(a, b, dummy1, dummy2);
}

struct Fp {
  ll val;

  Fp(ll t = 0) :
    val(t < 0 ? MOD + t % MOD : t >= MOD ? t % MOD : t) {}

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};

class Comb {
  int nMax;
  vector<Fp> vFact;
  vector<Fp> vInvFact;
public:
  Comb(int nm) : nMax(nm), vFact(nm+1), vInvFact(nm+1) {
    vFact.at(0) = 1;
    for (int i = 1; i <= nMax; i++) vFact.at(i) = i * vFact.at(i-1);
    vInvFact.at(nMax) = vFact.at(nMax).inv();
    for (int i = nMax; i >= 1; i--) vInvFact.at(i-1) = i * vInvFact.at(i);
  }
  Fp fact(int n) { return vFact.at(n); }
  Fp comb(int n, int r) {
    return vFact.at(n) * vInvFact.at(r) * vInvFact.at(n-r);
  }
  // The number of permutation extracting r from n.
  Fp perm(int n, int r) {
    return vFact.at(n) * vInvFact.at(n-r);
  }
};

/* 
   Power function    power(a, b) == a^b
   Speed is O(log b).
   The same source code can be used for integers by replacing
   Fp with int etc.  Unfortunately, replacing Fp with auto does not
   make the function generic for int and Fp.
 */
Fp power(Fp a, ll b) {
  Fp twoPow = a;
  Fp rv = 1;
  while (b > 0) {
    if (b & 1LL) rv *= twoPow;
    twoPow *= twoPow;
    b >>= 1;
  }
  return rv;
}

// --- MOD end --- cut here ---



int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());

  Comb cb(N+1);
  Fp vMax = 0;
  for (ll i = K-1; i < N; i++) vMax += cb.comb(i, K-1) * Fp(A.at(i));
  Fp vMin = 0;
  for (ll i = 0; i <= N-K; i++) vMin += cb.comb(N-i-1, K-1) * Fp(A.at(i));
  cout << (ll)(vMax - vMin) << endl;
  

  return 0;

}



Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>

#define ll long long

using namespace std;

inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main() {
	char ch=getchar();
	if (ch>='A'&&ch<='Z') putchar('A');
	else putchar('a');
	putchar('\n');
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

int main() {
	int n, k, d, cur;
	cin >> n >> k;
	
	unordered_set<int> s;
	
	for(int i = 0; i < k; i++) {
		cin >> d;
		
		for(int j = 0; j < d; j++) {
			cin >> cur;
			if(s.find(cur) == s.end()) {
				s.insert(cur);
				n--;
			}
		}
	}
	
	cout << n << endl;
	
	return 0;
}

















Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  long long N,A,r;
  r=0;
  cin >> N;
  vector<long long> vec(N),seen(N,0);
  for (int i=0;i<N;i++) {cin >> vec.at(i);}
  
  seen.at(0)=1;
  A=1;
  long long count=0;
  while (r==0) {
    A=vec.at(A-1);
	if (seen.at(A-1)==0) {
	  seen.at(A-1)++;
	  if (A==2) {r=1;}
	}
	else {r=1;}
	count++;
  }
  if (seen.at(1)==1) {cout << count << endl;} else {cout << -1 << endl;}
  
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 300000 + 10;

int N, M;

void Work()
{
	scanf("%d%d", &N, &M);
	int p = M * 1900 + (N - M) * 100;
	while (M --) p *= 2;
	printf("%d\n", p);
}

int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(true)
  {
    c -= b;
    if(c<=0) {
      cout<<"Yes\n";
      break;
    }
    a -= d;
    if(a<=0) {
      cout<<"No\n";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3616
import java.util.*;
import java.util.Map.Entry;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		HashMap<String, Integer> map = new HashMap<String, Integer>(); 
		for(int i = 0; i < N; i++) {
			String s = sc.next();
			if(map.containsKey(s)) {
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}
		}
		
		List<Entry<String, Integer>> list = new ArrayList<Entry<String, Integer>>(map.entrySet());
		Collections.sort(list, new Comparator<Entry<String, Integer>>(){
			public int compare(Entry<String, Integer> obj1, Entry<String, Integer> obj2) {
				return obj2.getValue().compareTo(obj1.getValue());
			}
		});
		
		boolean first_flag = true;
		int num = 0;
		ArrayList<String> ans = new ArrayList<String>();
		for(Entry<String, Integer> entry : list) {
			if(first_flag) {
				num = entry.getValue();
				ans.add(entry.getKey());
				first_flag = false;
			} else {
				int value = entry.getValue();
				if(num == value) {
					ans.add(entry.getKey());
				} else {
					break;
				}
			}
		}
		
		Collections.sort(ans);
		
		for(int i = 0; i < ans.size(); i++) {
			System.out.println(ans.get(i));
		}
	}
}


Measured memory_bytes: 82520
#include<stdio.h>

int main(void){
  int i,n,a,b,c;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d %d %d", &a,&b,&c);
    if(a*a==b*b+c*c || b*b==a*a+c*c ||c*c==b*b+a*a) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

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

using namespace std;

#define TRUE 1
#define FALSE 0

typedef long long ll;

ll n,q;
vector<ll> st,lazy;

void AddLazy(ll n,ll izq,ll der,ll v){
	lazy[n] += v;
	st[n] += (der-izq + 1)*v;
}

void PushLazy(ll n,ll izq,ll der){
	if(izq == der)
		return;
	ll m = (izq + der)/2;
	AddLazy(2*n,izq,m,lazy[n]);
	AddLazy(2*n+1,m + 1,der,lazy[n]);
	lazy[n] = 0;//Ya se utilizo
}

void build(ll n,ll izq,ll der){
	if(izq == der)
		st[n] = 0;
	else{
		ll m = (izq + der)/2;
		build(2*n,izq,m);
		build(2*n+1,m + 1,der);
		st[n] = st[2*n] + st[2*n + 1];
	}
	
}

ll query(ll n,ll izq,ll der,ll i,ll j){
	if(j < izq || der < i)
		return 0;
	if(i <= izq && der <= j)
		return st[n];
	PushLazy(n,izq,der);
	ll m = (izq + der)/2;
	
	ll p1 = query(2*n,izq,m,i,j);
	ll p2 = query(2*n+1,m + 1,der,i,j);
	
	return p1 + p2; 
}
void update(ll n,ll izq,ll der,ll i,ll j,ll v){
	if(j < izq || der < i)
		return;
	if(i <= izq && der <= j){
		AddLazy(n,izq,der,v);
		return;
	}
	PushLazy(n,izq,der);
	ll m = (izq + der)/2;
	update(2*n,izq,m,i,j,v);
	update(2*n + 1,m + 1,der,i,j,v);
	st[n] = st[2*n] + st[2*n + 1];
		
}

void BUILD(){
	build(1,1,n);
}
void UPDATE(ll i,ll j,ll v){
	update(1,1,n,i,j,v);
}
ll QUERY(ll i,ll j){
	return query(1,1,n,i,j); 
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> q;
	
	st.resize(4*n + 2);
	lazy.resize(4*n + 2);
	
	for(ll i = 0; i <= 4*n + 1;++i){
		st[i] = 0;
		lazy[i] = 0;
	}
	
	//BUILD();
	
	ll p,s,t,x;
	while(q--){
		cin >> p;
		if(p == 0){
			cin >> s >> t >> x;
			UPDATE(s,t,x);
		}
		else{
			cin >> s >> t;
			cout << QUERY(s,t) << '\n';
		}
	}
	

	//WAIT
}







Measured memory_bytes: 9192
import sys
from heapq import heappop, heappush
from scipy.sparse.csgraph import floyd_warshall
input = sys.stdin.readline
 
def main():
    n,w,l = map(int,input().split())
    d = [[10**15 for _ in range(n)] for _ in range(n)]
    for _ in range(w):
        x,y,z = map(int,input().split())
        x -= 1
        y -= 1
        if z > l:
            continue
        d[x][y] = z
        d[y][x] = z
    for i in range(n):
        d[i][i] = 0
    d = floyd_warshall(d)
    G = [[10**15 for _ in range(n)] for _ in range(n)]
    for i in range(n-1):
        for j in range(i+1,n):
            if d[i][j] <= l:
                G[i][j] = 1
                G[j][i] = 1
    for i in range(n):
        G[i][i] = 0
    G = floyd_warshall(G)
    q = int(input())
    for _ in range(q):
        s,t = map(int,input().split())
        s -= 1
        t -= 1
        ans = G[s][t]
        if ans == 10**15:
            print(-1)
            continue
        print(int(ans)-1)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 19824
#include <stdio.h>

void add_BIT(int N, long long BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

long long sum_BIT(long long BIT[], int r)
{
	long long sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, N, Q, a, t, p, x;
	long long BIT[500001] = {};
	scanf("%d %d", &N, &Q);
	for (i = 1; i <= N; i++) {
		scanf("%d", &a);
		add_BIT(N, BIT, i, a);
	}	
	for (i = 1; i <= Q; i++) {
		scanf("%d %d %d", &t, &p, &x);
		if (t == 0) add_BIT(N, BIT, p + 1, x);
		else printf("%lld\n", sum_BIT(BIT, x) - sum_BIT(BIT, p));
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 8096
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b))
        cout << "A" << endl;
    else
        cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 256
def examA():
    N, A, B = LI()
    if N==1:
        if A==B:
            print(1)
        else:
            print(0)
        return
    ans = (N-2)*max(B-A,0) + 1
    if B<A:
        ans = 0
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define D(i,n) for (int i=(n); i-->0;)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream& operator<<(ostream& os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i]; return os;}
const bool debug = 1;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m; cin>>n>>m;
    cout<<(1<<m) * (100*(n-m) + 1900*m)<<"\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
from collections import defaultdict
d = defaultdict(int)

for _ in range(n):
    d[input()[0]]+=1

march = []
for k,v in d.items():
    if k in ["M","A","R","C","H"]:
        march.append(v)

#iter_tools
#組み合わせ(重複なし)
from itertools import combinations
from operator import mul
ret = 0
if len(march) <= 2:
    print(0)
else:
    ret = 0
    for i in combinations(march,3):
        mul_of_i = 1
        for j in i:
            mul_of_i *= j
        ret += mul_of_i
    print(ret)



Measured memory_bytes: 3316
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())
A_max=max(A)
A_max_idx=A.index(A_max)    #0-indexed
A_min=min(A)
A_min_idx=A.index(A_min)    #0-indexed

if 0<=A_min:    #Aの最小値が0以上である場合、累積和を構成すれば良い
    print N-1
    for i in range(1,N):
        print i,i+1
else:    #Aの最小値が0より小さい場合
    if 0<=A_max:
        if abs(A_min)<=abs(A_max):  #絶対を取った時にA_maxがA_min以上
            print 2*N-1
            for i in range(1,N+1):  #A_maxを配列Aの全ての値にそれぞれ足していく
                print A_max_idx+1,i
            for i in range(1,N):    #その後に累積和を取れば良い
                print i,i+1
        elif abs(A_min)>abs(A_max):  #絶対を取った時にA_minがA_max以上
            print 2*N-1
            for i in range(1,N+1):  #A_minを配列Aの全ての値にそれぞれ足していって、aを全て負の数にする
                print A_min_idx+1,i
            for i in range(N,1,-1): #後ろから累積和
                print i,i-1
    elif A_max<0:   #aの値が全部負なので、後ろから累積和を取ればよい
        print N-1
        for i in range(N,1,-1): #後ろから累積和
            print i,i-1

Measured memory_bytes: 28524
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int a,b,c;
  while(cin >> a>> b >> c,a+b+c) {
    int n;
    cin >> n;
    vector<vector<int> > vv;
    vector<int> ans(a+b+c, 2);
    REP(i,n) {
      vector<int> v(3);
      REP(k,3) {
        cin >>v[k];
        v[k]--;
      }
      bool f;
      cin >> f;
      if (f) {
        REP(k,3) ans[v[k]] = 1;
      } else {
        vv.push_back(v);
      }
    }
    FOR(it,vv) {
      if (ans[(*it)[0]] == 1 && ans[(*it)[1]] == 1) 
        ans[(*it)[2]] = 0;
      else if (ans[(*it)[1]] == 1 && ans[(*it)[2]] == 1)
        ans[(*it)[0]] = 0;
      else if (ans[(*it)[0]] == 1 && ans[(*it)[2]] == 1)
        ans[(*it)[1]] = 0;
    }
    REP(i,a+b+c)
      cout << ans[i] << endl;
  }

}

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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO; 
	
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i <n; ++i) {
		cin >> a[i];
	}
	ll ans = 0;
	sort(a.begin(), a.end());
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			if (a[i] == a[j]) {
				continue;
			}
			else {
				for (int k = j+1; k < n; ++k) {
					if (a[k] != a[j] && a[i] != a[k] && a[i] + a[j] > a[k]){
						++ans;
					}
					else {
						continue;
					}
				}
			}
		}
	}
	
	cout << ans;
	

}


Measured memory_bytes: 3648
def reachable(dt,dx,dy):
  r = dx + dy
  c1 = dt >= r
  c2 = ((dt - r) % 2 == 0)
  return c1 & c2

def solve():
  N = int(input())
  t=0
  x=0
  y=0
  ans = "Yes"
  for i in range(N):
    raw = list(map(int,input().split(" ")))
    dt=raw[0]-t
    dx=raw[1]-x
    dy=raw[2]-y
    t = raw[0]
    x = raw[1]
    y = raw[2]
    if not reachable(dt,dx,dy):
      ans = "No"
      break
    
  return ans

if __name__ == '__main__':
  
  ans = solve()
  print(ans, flush=True)

Measured memory_bytes: 3064
n = int(input())
is_prime = [True] * 1005
MOD = 10 ** 9 + 7
is_prime[0] = is_prime[1] = False
factors = []
for i in range(2, n + 1):
    if is_prime[i]:
        cnt = 0
        for j in range(i * i, n + 1, i):
            is_prime[j] = False
        i_init = i
        while i <= n:
            cnt += n // i
            i *= i_init
        factors.append(cnt)
ans = 1
for x in factors:
    ans = ans * (x + 1) % MOD
print(ans)

Measured memory_bytes: 9216
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
using namespace std;
typedef long long ll;
int main(){
	int h,w,n;
	int a[100100];
	int e[102][102];
	cin>>h>>w>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int k=1;
	bool t=true;
	for(int i=1;i<=h;i++){
		if(t){
			for(int j=1;j<=w;j++){
				e[i][j]=k;
				a[k]--;
				if(a[k]==0)k++;
			}
			t=!t;
			continue;
		}
		else{
			for(int j=w;j>=1;j--){
				e[i][j]=k;
				a[k]--;
				if(a[k]==0)k++;
			}
			t=!t;
			continue;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cout<<e[i][j];
			if(j!=w)cout<<" ";
		}
		if(i!=h)cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define N 10000

main(){
  int a,x,i,count=0,count2=0,n;

  scanf("%d",&n);
  if( N<n )
    exit(1);

  while(count2<n){
    scanf("%d",&x);
    a=1;
    if( x == 2 )
      a=1;
    else if( x < 2 || x%2 == 0)
      a=0;
    else{
      for( i = 3; i <= sqrt((double)x); i += 2 ){
	if( x%i == 0 ){
	  a=0;
	  break;
	}
	else
	  a=1;
      }
    
    }
    if(a==1)
      count++;
    count2++;

  }

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

  return 0;
}

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

bool arr[4][55];
int n, m;
int id(char c) {
	if (c == 'S') return 0;
	if (c == 'H') return 1;
	if (c == 'C') return 2;
	if (c == 'D') return 3;
}
char mrk[] = {'S', 'H', 'C', 'D'}, c;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c >> m;
		arr[id(c)][m] = true;
	}

	for (int i = 0; i < 4; i++) for (int j = 1; j <= 13; j++) {
		if (!arr[i][j]) cout << mrk[i] << " " << j << endl;
	}
	return 0;
}



Measured memory_bytes: 3080
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    int n;
    int[][] es;
    int INF = 1 << 28;

    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        es = new int[n][n];

        for (int i = 0; i < n; i++) {
            String s = sc.next();

            for (int j = 0; j < n; j++) {
                es[i][j] = s.charAt(j) == '1' ? 1 : INF;
            }
            es[i][i] = 0;
        }

        dist = new int[n];
        if (dfs(0, -1, 0, new HashSet<>())) {
            System.out.println(-1);
            return;
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    es[j][k] = Math.min(es[j][k], es[j][i] + es[i][k]);
                }
            }
        }

        int ans = 0;
        for (int i = 0; i < n; i ++) {
            for (int j = 0; j < n; j++) {
                ans = Math.max(ans, es[i][j]);
            }
        }
        System.out.println(ans + 1);
    }

    int[] dist;
    boolean dfs(int cur, int par, int d, HashSet<Integer> visited) {
        if (visited.contains(cur)) {
//            debug(cur, par, d, visited);
            return Math.abs(dist[cur] - dist[par]) % 2 == 0;
        }
        visited.add(cur);
        dist[cur] = d;
        for (int i = 0; i < n; i++) if (es[cur][i] != 0 && es[cur][i] != INF) {
            if (i == par) continue;
            if (dfs(i, cur, d + 1, visited)) {
                return true;
            }
        }
        return false;

    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
       new Main().run();
    }

}


Measured memory_bytes: 28832
import math
i,j = map(int,input().split())

p=[]
for row in range(i):
  p.append(list(map(int,input().split())))

ok = 0
for src in range(i):
  for dst in range(src+1,i):
    itoj =0
    for dim in range(j):
      itoj += (p[dst][dim] - p[src][dim])**2
    if math.sqrt(itoj)%1 == 0:
      ok +=1
print (ok)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

bool A[300000];
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while(true) {
        int N; cin >> N;
        if (N == 0) break;
        rep(i,300000) A[i] = true;
        A[0] = A[1] = false;
        for (int i = 2; i < 300000; i++) {
            if (A[i]) {
                for (int j = 2; j*i <300000; j++) {
                    A[j*i] = false;
                }
            }
        }
        int count = 0;
        for (int i = N+1; i <= 2*N; i++) {
            if (A[i]) count++;
        }

        cout << count << endl;
    }
}


Measured memory_bytes: 3428
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

typedef pair<int , string> t;

int main(void){

  int n,num;
  string s;
  map < t , int > m;

  cin >> n;
  for( int i = 0 ; i < n ; i++ ){
    cin >> s >> num;
    m[ t( s.size() , s ) ] += num;
  }

  map<t,int>::iterator it;
  for( it = m.begin() ; it != m.end() ; it++ ){
    cout << it->first.second <<  " " << it->second << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
import java.util.*;

public class Main{
	private static final int MAX = 1000000;

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] map = new int[n+1][n+1];

		for(int i=0;i<n;i++){
			int from = sc.nextInt();
			int m = sc.nextInt();

			for(int j=0;j<m;j++){
				map[from][sc.nextInt()] = 1;
			}
		}

		floyd(map);

		int m = sc.nextInt();
		for(int i=0;i<m;i++){
			int from = sc.nextInt();
			int to = sc.nextInt();
			int rem = sc.nextInt();

			if(map[from][to] < MAX && rem >= map[from][to]+1){
				System.out.println(map[from][to]+1);
			}
			else{
				System.out.println("NA");
			}
		}
	}

	private static void floyd(int[][] map){
		int n = map.length-1;

		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				map[i][j] = map[i][j] == 0 ? MAX : map[i][j];
			}
		}

		for(int k=1;k<=n;k++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					if(i == j) continue;
					map[i][j] = Math.min(map[i][j],map[i][k]+map[k][j]);
				}
			}
		}
	}
}

Measured memory_bytes: 13000
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

s = input()
t = input()

if len(s) >= len(t):
    ans_l = []
    for i in range(0, len(s)-len(t)+1):
        s_s = s[i:len(s)-1+i]
        flag = True
        for ssi, ti in zip(s_s, t):
            if ssi == "?":
                continue
            if ssi != ti:
                flag = False
                break
        if flag:
            ans_l.append(i)

    d = []
    for ans_i in ans_l:
        tmp_s = (s[:ans_i]+t+s[len(t)+ans_i:]).replace("?", "a")
        d.append(tmp_s)
    d = sorted(d)
    if len(d) > 0:
        print(d[0])
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 100010;

ll M;
vi g[MN], gc[MN];
ll dp[MN]; //mark
ll ans[MN];

void pre(int v, int p) {
    dp[v] = 1;
    for (int to : g[v]) {
        if (to != p) {
            gc[v].pb(to);
            pre(to, v);
            dp[v] = dp[v] * (dp[to] + 1) % M;
        }
    }
}

void dfs(int v, ll up) {
    int sz = gc[v].size();
    vector<ll> vl(sz + 1), vr(sz + 1);

    vl[0] = vr[sz] = 1;

    rep(i, sz) {
        int to = gc[v][i];
        vl[i + 1] = vl[i] * (dp[to] + 1) % M;
    }

    for (int i = sz - 1; i >= 0; --i) {
        int to = gc[v][i];
        vr[i] = vr[i + 1] * (dp[to] + 1) % M;
    }

    if (v == 0) {
        ans[v] = dp[v];
    } else {
        ans[v] = dp[v] * (up + 1) % M;
    }

    rep(i, sz) {
        int to = gc[v][i];
        ll nx = vl[i] * vr[i + 1] % M;
        if (v != 0) {
            nx = nx * (up + 1) % M;
        }
        dfs(to, nx);
    }
}

int main() {
    int N; cin >> N >> M;
    rep(i, N-1) {
        int x, y;
        cin >> x >> y; --x; --y;
        g[x].pb(y); g[y].pb(x);
    }
    pre(0, -1);
    dfs(0, 0LL);

    rep(i, N) {
        cout << ans[i] << "\n";
    }

	return 0;
}

Measured memory_bytes: 23424
H, W, K = map(int, input().split())
B = [list(input()) for _ in range(H)]
T = 0
for i_1 in range(2**H):
  for i_2 in range(2**W):
    X = [j_1 for j_1 in range(H) if (i_1>>j_1)&1]
    Y = [j_2 for j_2 in range(W) if (i_2>>j_2)&1]
    S = 0
    for x in X:
      for y in Y:
        if B[x][y]=="#":
          S += 1
    if S==K:
      T += 1
print(T)     

Measured memory_bytes: 9080
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}


template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}

int main(void) {
	ll n, k;
	cin >> n >> k;
	vector<ll>p(n);
	rep(i, n) {
		cin >> p[i];
	}
	sort(ALL(p));
	ll ans = 0;
	rep(i, k) {
		ans += p[i];
	}
	cout << ans;
}

/*

*/


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

ll pow(int d) {
  ll p = 1;
  for (int i = 0; i < d; i++) {
    p *= 5;
  }
  return p;
}

int main() {
  ll N;
  cin >> N;
  int D;
  for (int i = 0; i < 100; i++) {
    if (pow(i) <= N/2 && N/2 < pow(i+1)) {
      D = i;
      break;
    }
  }

  
  ll A[D];
  for (int i = 0; i < D; i++) {
    A[i] = (N/2)/pow(i+1);
  }
  
  ll ans = 0;
  for (int i = 0; i < D; i++) {
    ans += A[i];
  }
  
  if (N % 2 == 0) {cout << ans << endl;}
  else {cout << 0 << endl;}
}
    

Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string a,b;
    cin>>a>>b;
    cout<<b+a;
	exit(0);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

public class Main {
    private static final class FastInput {
        private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer st;

        private int nextInt() throws Exception {
            return Integer.parseInt(nextWord());
        }

        private long nextLong() throws Exception {
            return Long.parseLong(nextWord());
        }

        private String nextWord() throws Exception {
            if (st == null || !st.hasMoreElements()) st = new StringTokenizer(br.readLine(), " ");
            return st.nextToken();
        }

        private long[] lineToIntArr(int len) throws Exception {
            long[] arr = new long[len];
            for (int i = 0; i < arr.length; i++) arr[i] = nextLong();
            return arr;
        }
    }

    public static void main(String[] args) throws Exception {
        FastInput in = new FastInput();
        int n = in.nextInt();
        long[] a = in.lineToIntArr(n);
        long[] dp = new long[n+1];
        for(int i = 0; i <= n; ++i){
            dp[i] = 1000000007;
        }
        dp[0] = 0;
        for(int i = 0; i <n; ++i){
            if(i + 1 < n) dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(a[i] - a[i+1]));
            if(i + 2 < n) dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(a[i] - a[i+2]));
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        bw.write(String.valueOf(dp[n - 1]));
        bw.flush();
    }
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  set<string> s;
  rep(i,0,n) {
    string o;
    cin >> o;
    s.insert(o);
  }

  cout << sz(s) << '\n';
}

Measured memory_bytes: 19244
def main():
    x = int(input())
    s = list(input())

    n_r = s.count('R')
    n_g = s.count('G')
    n_b = s.count('B')
    sum = n_r * n_g * n_b
    for i in range(len(s)):
      for j in range(i+1):
        if j > 0 and i + j < x:
          if s[i-j] != s[i] and s[i] != s[i+j] and s[i-j] != s[i+j]:
            sum -= 1
    print(sum)
main()

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

int main(){
    int y1, m1, d1, y2, m2, d2;
    cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
    if(y2 > y1 || y2 == y1 && m2 > m1 || y2 == y1 && m2 == m1 && d2 > d1){
        swap(y1, y2);
        swap(m1, m2);
        swap(d1, d2);
    }
    int ans = y1 - y2 + (m1 > m2 || (m1 == m2 && d1 > d2) ? 1 : 0);
    cout << ans << endl;

    return 0;
}



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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
	string s;
	cin >> s;
	int num = (int)s.size() - 2;
	cout << s[0] << num << s[s.size() - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    // from kenkoooooo
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

fn minmax<T: Ord>(a: T, b: T) -> (T, T) {
    if a < b {
        (a, b)
    } else {
        (b, a)
    }
}

fn solve2(a: &Vec<i64>) -> Vec<(i64, i64)> {
    let n = a.len();
    let mut ret = vec![(0i64, 1i64 << 50); n];
    let mut j = 1;
    let mut sum_j = a[0];
    let mut sum_i = a[0];
    for i in 2..n {
        sum_i += a[i - 1];
        while j + 1 < i && sum_j + a[j] < sum_i - a[j] - sum_j {
            sum_j += a[j];
            j += 1;
        }
        ret[i] = minmax(sum_i - sum_j, sum_j);
        if j + 1 < i {
            let tmp = minmax(sum_i - sum_j - a[j], sum_j + a[j]);
            if ret[i].0 < tmp.0 {
                ret[i] = tmp
            }
        }
    }
    ret
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut a: Vec<i64> = sc.read_vec(n);
    let from_left = solve2(&a);
    a.reverse();
    let mut from_right = solve2(&a);
    from_right.reverse();
    let mut ret = std::i64::MAX;
    for (&(x, y), &(z, w)) in from_left.iter().skip(1).zip(from_right.iter()) {
        ret = min(ret, max(y, w) - min(x, z));
    }
    println!("{}", ret);
}


Measured memory_bytes: 14588
//#include<bits/stdc++.h>
//using namespace std;
//int n,x,mod=998244353;
//long long ans=0;
//int main()
//{
//    cin>>n;
//    cin>>x;
//    for(long long i=0;i<=x;i++)
//    {
//        long long tmp=i;
//        int flag=0;
//        int cnt=0;
//        while(1)
//        {
//            if(tmp==i&&flag)
//                break;
//            flag=1;
//            if(tmp%2==0)
//            {
//                tmp/=2;
//                tmp+=pow(2.0,n-1);
//            }
//            else
//            {
//                tmp-=1;
//                tmp/=2;
//            }
//            cnt++;
//            cout<<tmp<<" ";
//        }
//        ans+=cnt;
//        ans%=mod;
//        cout<<endl;
//        cout<<"cnt="<<cnt<<endl;
//    }
//    cout<<ans%mod<<endl;
//    return 0;
//}
#pragma warning(disable:4996)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn = 205;
const int inf = 0x3f3f3f3f3f;
int dist[maxn][maxn];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		getchar();
		for (int j = 1; j <= n; j++)
		{
			char input;
			scanf("%c", &input);
			if (input == '1')
			{
				dist[i][j] = 1;
			}
			else
			{
				dist[i][j] = inf;
			}
		}
	}
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
			{
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				if (i == j)
				{
					dist[i][j] = 0;
				}
			}
		}
	}
	int ans = -1,flag=0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (dist[i][j] % 2 == 0 && (dist[1][i] + dist[1][j])%2)
			{
				flag = 1;
				break;
			}
			if (dist[i][j] % 2 && (dist[1][i] + dist[1][j]) % 2 == 0)
			{
				flag = 1;
				break;
			}
			ans = max(ans,dist[i][j]);
		}
	}
	if (flag)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n", ans + 1);
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 1016
#include<stdio.h>

main(){
  int s[10000];
  int t[500];
  int n,q;
  int count=0;
  int i,j;
  int p;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&s[i]);
    for(j=0; j<i; j++){
      if(s[i] == s[j]){
	p = s[i];
	i--;
	n--;
      }
    }
  }
  
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&t[i]);
    for(j=0; j<i; j++){
      if(t[i] == t[j]){
	p = t[i];
	i--;
	q--;
      } 
    }
  }
  
  for(i=0; i<n; i++){
    for(j=0; j<q; j++){
      if(s[i] == t[j]){
	count++;
      }
    }
 }

 printf("%d\n",count);
 return 0;
}

Measured memory_bytes: 612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n= s.nextInt(),k  = s.nextInt()-1;
        String word = s.next();

        String res = word.substring(0,k)+word.substring(k,k+1).toLowerCase()+word.substring(k+1,word.length());
        System.out.println(res);
    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 3005;
const int MOD = 998244353;
 
int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
 
int n, s;
int a[N], store[N];
int cache[N][N];
 
int dp(int idx, int s)
{
	if(s < 0)
		return 0;
	if(s == 0)
		return store[idx];
	if(idx > n)
		return 0;
	int &ans = cache[idx][s];
	if(ans != -1)
		return ans;
	ans = 2 * dp(idx + 1, s) + dp(idx + 1, s - a[idx]);
	ans %= MOD;
	return ans;
 
}
 
int32_t main()
{
	memset(cache, -1, sizeof(cache));
	cin >> n >> s;
	for(int i = 0; i <= n + 2; i++)
		store[i] = pow(2, n + 1 - i, MOD);
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = dp(1, s);
	cout << ans;
	return 0;
}

Measured memory_bytes: 74376
#include <iostream>
#include <cstdio>
#include <cstring>
#include<algorithm>
using namespace std;
int main()
{
        std::ios::sync_with_stdio(false);
        int a,b;
        while (cin>>a) {
            if(a<105) cout<<0<<endl;
            else if(a<135) cout<<1<<endl;
            else if(a<165) cout<<2<<endl;
            else if(a<189) cout<<3<<endl;
            else if(a<195) cout<<4<<endl;
            else cout<<5<<endl;
        }
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>

using namespace std;

int main()
{
    string s;
    cin >> s;
    deque<char> dq;
    for (auto& ch : s) {
        if (ch == 'B') {
            if (!dq.empty()) {
                dq.pop_back();
            }
        } else {
            dq.push_back(ch);
        }
    }

    while (!dq.empty()) {
        cout << dq.front();
        dq.pop_front();
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

int main(){
	ll n, m, q; cin >> n >> m >> q;
	if (n == 1){
		ll count = 0;
		rep(i, m){
			ll a, b; cin >> a >> b;
			count++;
		}
		rep(i, q){
			cout << count << endl;
		}
		return 0;
	}
	vvl pdp(n,vl(n,0));
	rep(i, m){
		ll l, r; cin >> l >> r;
		l--; r--;
		pdp[l][r] += 1;
	}
	rep(i, n) for (ll j = i+1; j < n; j++){
		pdp[i][j] += pdp[i][j-1];
	}
	vvl dp(n, vl(n, 0));
	rrep(i,n-1) for (ll j = i; j < n; j++){
		if (i == n - 1) dp[i][j] = pdp[i][j];
		else dp[i][j] = dp[i + 1][j] + pdp[i][j];
	}
	rep(i, q){
		ll pl, pr; cin >> pl >> pr;
		cout << dp[pl - 1][pr - 1] << endl;
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++){
    if (s.at(i) == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}
    


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

int main() {
  uint64_t Ans = 0;  // 回答：
  int N; cin >> N; // 文字列数：１～４０００
  string S; cin >> S; // 対象文字列
  uint64_t R,G,B;  // 各色の個数
  R=0;G=0;B=0;

  // 各色のカウント
  for(char c : S){
    R += c=='R';
    G += c=='G';
    B += c=='B';
  }
  // とりあえず、全色違う組数を出す
  Ans = R * G * B;

  // ２点間の距離が同じ組を判定し、合計数から引く
//  int j,k;  //２文字目３文字目の位置
//    rep1(d,N){
//  rep(i,N){
//      j = i + d; k = i + d + d;
//      if ( k > N-1 ) { break; }
  // for (int d=1;d<N;++d){
  //   for (int i=0,j=d,k=2*d;k<N;++i,++j,++k){
  //       // 異なる色の場合、全数から引く
  //       if ( S.at(i) != S.at(j) && S.at(i) != S.at(k) && S.at(j) != S.at(k) ){
  //         Ans--;
  //       }
  //     }
  // }

    for (int p=1;p<N;++p){
        for (int i=0,j=p,k=2*p;k<N;++i,++j,++k){
            if (S[i]!=S[j]&&S[j]!=S[k]&&S[k]!=S[i])
                --Ans;
        }
    }

  cout << Ans << endl;
}


Measured memory_bytes: 3628