akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[100100];


int main() {
    string s;
    li k;
    cin >> s >> k;
    set<string> st;
    li n = sz(s);

    string best5;
    rep(i, n) {
        repp(j, i, n) {
            string ss = s.substr(i, j - i + 1);
            //cout << ss << endl;
            if (sz(st) < k) {
                st.insert(ss);
                if (sz(st) == k) {
                    best5 = ss;
                }
            } else if (ss > best5) {
                break;
            } else {
                st.insert(ss);
                auto it = st.begin();
                rep(l, k - 1)++it;
                best5 = *it;
            }
        }
    }

    auto it = st.begin();
    rep(l, k - 1)++it;
    cout << *it << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9 + 7;

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

  string s;
  cin >> s;
  int c = 0, f = 0;
  REP(i, s.size()){
    if(s[i] == 'C') c = 1;
    if(c && s[i] == 'F') f = 1;
  }
  if(c && f){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 200005;
const ll MOD = 1000000007;

string str;
int n, m;
vector<int> edge[MAXN];
int cnt[MAXN][2], sz;
bool B[MAXN];

bool vis[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    cin >> str;
    REP1 (i, n) {
        B[i] = str[i-1] == 'B';
    }
    REP (i, m) {
        int u, v;
        cin >> u >> v;
        edge[u].eb(v);
        edge[v].eb(u);
        cnt[u][B[v]]++;
        cnt[v][B[u]]++;
    }

    sz = n;

    vector<int> stk;
    REP1 (i, n) {
        if (cnt[i][0] == 0 || cnt[i][1] == 0) {
            stk.eb(i);
            vis[i] = true;
        }
    }

    while (stk.size()) {
        sz--;
        int nd = stk.back();
        stk.pop_back();

        for (auto v : edge[nd]) {
            cnt[v][B[nd]]--;
            if (!vis[v] && (cnt[v][0] == 0 || cnt[v][1] == 0)) {
                stk.eb(v);
                vis[v] = true;
            }
        }
    }

    debug(sz);
    assert(sz != 1);

    cout << (sz > 0 ? "Yes" : "No") << endl;

    #ifdef tmd

    REP1 (i, n) {
        if (!vis[i]) {
            debug(i, B[i]);
        }
    }

    #endif // tmd
}


Measured memory_bytes: 12880
while True:
    x=[]
    n=input()
    if n=='-':
        break
    m=int(input())

    for i in range(m):
        h=int(input())
        x.append(h)
    for j in range(m):
        y=n[x[j]:]
        y+=n[0:x[j]]
        n=y
    print(y)


Measured memory_bytes: 5596
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=300005;
typedef pair<int,int> Point;

int W,H,N,ans;
Point P[MAXN];

int mx[MAXN*4],tag[MAXN*4];
void Add(int l,int r,int delta,int L=1,int R=N,int id=1)
{
	if(l<=L&&R<=r)
	{
		mx[id]+=delta;
		tag[id]+=delta;
		return;
	}
	int mid=(L+R)/2;
	mx[id*2]+=tag[id];tag[id*2]+=tag[id];
	mx[id*2+1]+=tag[id];tag[id*2+1]+=tag[id];
	tag[id]=0;
	if(l<=mid)
		Add(l,r,delta,L,mid,id*2);
	if(r>mid)
		Add(l,r,delta,mid+1,R,id*2+1);
	mx[id]=max(mx[id*2],mx[id*2+1]);
}

pair<int,int> p[MAXN],q[MAXN];
int a,b;

void Solve()
{
	memset(mx,0,sizeof mx);
	memset(tag,0,sizeof tag);
	sort(P+1,P+N+1);
	a=b=0;
	int last;
	for(int i=1;i<N;i++)
	{
		if(P[i].second<=H/2)
		{
			last=i-1;
			while(a&&P[i].second>p[a].second)
			{
				Add(p[a].first,last,p[a].second-P[i].second);
				last=p[a--].first-1;
			}
			if(last!=i-1)
				p[++a]=make_pair(last+1,P[i].second);
		}
		else
		{
			last=i-1;
			while(b&&P[i].second<q[b].second)
			{
				Add(q[b].first,last,P[i].second-q[b].second);
				last=q[b--].first-1;
			}
			if(last!=i-1)
				q[++b]=make_pair(last+1,P[i].second);
		}
		p[++a]=make_pair(i,0);
		q[++b]=make_pair(i,H);
		Add(i,i,H-P[i].first);
		ans=max(ans,mx[1]+P[i+1].first);
	}
}

int main()
{
	scanf("%d%d%d",&W,&H,&N);
	for(int i=1;i<=N;i++)
		scanf("%d%d",&P[i].first,&P[i].second);
	P[++N]=Point(0,0);
	P[++N]=Point(W,H);
	Solve();
	for(int i=1;i<=N;i++)
		swap(P[i].first,P[i].second);
	swap(W,H);
	Solve();
	
	printf("%d\n",ans<<1);
	
	return 0;
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	long long C[n];
	long long dp[n] = {0};
	map<long long,long long>last;
	for(long long i = 0; i < n;i++)
	{
		cin >> C[i];
	}
	dp[0] = 1;
	dp[1] = 1;
	if(C[0] ==  C[1])
	{
		last[C[1]] = 1;
	}
	else
	{
		last[C[0]] = 1;
		last[C[1]] = 2;
	}
	for(long long i = 2; i < n;i++)
	{
		if(C[i] ==  C[i-1])
		{
			dp[i] = dp[i-1];
		}
		else
		{
			if(last[C[i]] == 0)
			{
				dp[i] = dp[i-1];
			}
			else
			{
				if(last[C[i]] ==  1)
				{
					dp[i] = dp[i-1] + 1;
				}
				else
				{
					dp[i] = dp[i-1] + dp[last[C[i]]-1];
					dp[i] = dp[i]%1000000007;
				}
			}
			last[C[i]] = i+1;
		}
	}
	cout << dp[n-1] << endl;

}

Measured memory_bytes: 15872
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    boolean isN=false;
    boolean isS=false;
    boolean isE=false;
    boolean isW=false;
    String tmp;
    for(int i=0;i<S.length();i++){
      tmp=S.substring(i,i+1);
      if(tmp.equals("N")){
        isN=true;
      }else if(tmp.equals("S")){
        isS=true;
      }else if(tmp.equals("E")){
        isE=true;
      }else{
        isW=true;
      }
    }
    if((isN&&!isS)||(isE&&!isW)||(!isN&&isS)||(!isE&&isW)){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    






  }
  

  
}


Measured memory_bytes: 23124
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val s = read()
    var cnt = 0
    for(i in 0 until s.length-1) {
        if(s[i] != s[i+1]) {
            cnt++
        }
    }
    println(cnt)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 34180
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    int A=0,B=0;
    for(int i=0; i<4; i++){
        int a;
        cin >> a;
        A += a;
    }
    for(int i=0; i<4; i++){
        int b;
        cin >> b;
        B += b;
    }
    cout << max(A,B) << enld;
    return 0;
}


Measured memory_bytes: 3052
n=int(input())
a=list(map(int,input().split()))
m=0
b=[0]*n
for i in reversed(range(n)):
    num=int(n/(i+1))
    #print("["+str(num)+"]")
    if num==1:
        if a[i]==1:
            b[i]=1
            m+=1
    else:
        sum=0
        for j in range(num):
            sum+=b[(i+1)*(j+1)-1]
        sum%=2
        if a[i]==1:
            b[i]=1-sum
            m+=1-sum
        else:
            b[i]=sum
            m+=sum
        
print(m)
if(m!=-1):
    for i in range(n):
        if b[i]!=0:
            print((i+1),end=" ")
        print("")

Measured memory_bytes: 8248
def solve():
    N = int(input())
    A = [0] * (N + 1)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                s = x * x + y * y + z * z + x * y + x * z + y * z
                if s <= N:
                    A[s] += 1
    for i in range(1, N + 1):
        print(A[i])

solve()

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

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

  set<char> cs;
  REP(i,s.size()) cs.insert(s[i]);

  char ans='0';
  REP(i,26){
    if(!cs.count(i+'a')){
      ans = i+'a';
      break;
    }
  }

  if(ans=='0'){
    cout <<"None" <<endl;
  }else{
    cout <<ans <<endl;
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)



int main(){
    int a,b,c;
    scanf("%d/%d/%d", &a, &b, &c);
    if(a < 2019){
        cout << "Heisei" << endl;
        return 0;
    }
    if(a == 2019 && b < 5){
        cout << "Heisei" << endl;
        return 0;
    }
    cout << "TBD" << endl;
    return 0;

}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    double a,b,c,d,e,f,x,y,x2,and,then;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF)
    {
        x2=(c*e)-(b*f);
        then=(a*e)-(b*d);
        and=((a*f)-(d*c));
        x=(x2)/(then);
        y=(and)/(then);
        if((x2/then)==-0)
        {
            x=0;
        }
       printf("%0.3lf %0.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 1784
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<std::vector<size_t>> shojiki(n), hushin(n);
  for (size_t i = 0; i < n; ++i) {
    size_t a;
    scanf("%zu", &a);
    for (size_t j = 0; j < a; ++j) {
      size_t x;
      int y;
      scanf("%zu %d", &x, &y);
      --x;

      if (y == 0) {
        // y == 0 => hushin
        hushin[i].push_back(x);
      } else {
        shojiki[i].push_back(x);
      }
    }
  }

  int res = 0;
  for (size_t i = 0; i < (1_zu << n); ++i) {
    bool valid = true;
    for (size_t j = 0; j < n; ++j) {
      if (i >> j & 1) {
        for (size_t k: hushin[j])
          if (i >> k & 1) valid = false;
        for (size_t k: shojiki[j])
          if (~i >> k & 1) valid = false;
      } else {
        
      }
    }
    if (valid) res = std::max(res, __builtin_popcount(i));
  }
  printf("%d\n", res);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int sum = 0;
        for (int i = 0; i < 2; i++) {
            if (A <= B) {
                sum += B;
                B--;
            } else {
                sum += A;
                A--;
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 22868
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	int h, w;
	cin >> h >> w;

	vector<string> r(h + 2, string(w + 2, '#'));

	REP(i, h)
	{
		string s;
		cin >> s;

		REP(j, w)
		{
			r[i + 1][j + 1] = s[j];
		}

	}

	REP(i, h + 2)
		cout << r[i] << endl;
}


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

int main(){
	int S; cin>>S;
	vector<int64_t> C(S+1, 0); C[0] = 1;
	for(int n=3; n<=S; ++n) C[n] = (C[n-1] + C[n-3]) % 1'000'000'007;
	cout<< C[S] <<'\n';
}


Measured memory_bytes: 3572
#include <iostream>
#include<bits/stdc++.h>
#define input ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define dl endl
#define ft first
#define sc second
using namespace std;
int n, a[4];
string s;
int main()
{
	//freopen("", "r", stdin);
	//freopen("", "w", stdout);
	input;
	cin >> n;
	while (n--)
	{
		cin >> s;
		if (s == "AC")a[0]++;
		else if (s == "WA")a[1]++;
		else if (s == "TLE")a[2]++;
		else a[3]++;
	}
	cout << "AC x " << a[0]<<dl;
	cout << "WA x " << a[1] << dl;
	cout << "TLE x " << a[2] << dl;
	cout << "RE x " << a[3] << dl;
}

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


int main(){
    int N; cin >> N;
    vector<int> A(N);
    map<int, ll> mp;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if(mp.count(A[i])) mp[A[i]]++;
        else mp[A[i]]=1;
    }
    ll total=0;
    for(auto x: mp){
        ll num=x.second;
        total+=num*(num-1)/2;
    }
    for(int i=0; i<N; i++){
        ll res=0;
        ll x=mp[A[i]];
        if(x >= 2){
            res=total-x*(x-1)/2+(x-1)*(x-2)/2;
        }
        else res=total;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

signed main(){
    int q,h,s,d;
    cin>>q>>h>>s>>d;
    int x = min(q*4,min(h*2,s));
    int y = d;
    
    int n;
    cin>>n;
    
    cout<<min(x*n,(n/2)*y+(n%2)*x)<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int kMaxN = 200001;

struct E {
  int r, c;
} e[kMaxN];

int n, m, x, y, ans;

int G(int x) {
  return e[x].r == x ? x : e[x].r = G(e[x].r);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    e[i].r = i;
    e[i].c = 1;
  }
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    x = G(x);
    y = G(y);
    if (x != y) {
      e[y].r = x;
      e[x].c += e[y].c;
    }
  }
  for (int i = 1; i <= n; i++) {
    ans = max(ans, e[G(i)].c);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 5464
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, ans = 0;
	string str;
	
	cin >> n >> str;
	
	for(int i = 0; i < n - 2; i++){
		if(str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C'){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll K, X, Y, x=0, y=0;
  std::cin >> K >> X >> Y;
  bool rev = rev = (abs(X) < abs(Y));
  if(rev) swap(X, Y);
  bool x_minus = (X < 0), y_minus = (Y < 0);
  X = abs(X), Y = abs(Y);

  if(K%2==0&&(X+Y)%2==1){
    std::cout << -1 << '\n';
    return 0;
  }
  vvl ans = vv(0, 2, 0, ll);
  if(X+Y<K && (X+Y)%2==1){
    y -= K - X;
    x +=  X;
    ans.push_back(std::vector<ll> {x, y});
    x += (K+X-Y)/2;
    y += K - (K+X-Y)/2;
    ans.push_back(std::vector<ll> {x, y});
    y += K-X+Y - (K-(K+X-Y)/2);
    x -= (K+X-Y)/2;
    ans.push_back(std::vector<ll> {x, y});
  }else{
    ll c = (K-(X+Y)%K)%K, N=(X+Y)/K+((X+Y)%K!=0?1:0);
    if(c%2==1) N++;
    if(X+Y<K) N=2;
    ll init = -(N*K-X-Y)/2;
    while(y>init){
      if(y-K<init) x+=K-(y-init);
      y = max(y-K, init);
      ans.push_back(std::vector<ll> {x, y});
    }
    while(x<X || y<Y){
      if(x<X) {
        if(x+K>X) y += K - (X - x);
        x+=min(K, X-x);
      }else y+=min(K, Y-y);
      ans.push_back(std::vector<ll> {x, y});
    }
  }
  std::cout << ans.size() << '\n';
  for(int i=0;i<ans.size();i++){
    if(!rev) std::cout << (x_minus?-1:1)*ans[i][0] << " " << (y_minus?-1:1)*ans[i][1] << '\n';
    else std::cout << (y_minus?-1:1)*ans[i][1] << " " << (x_minus?-1:1)*ans[i][0] << '\n';
  }
  return 0;
}


Measured memory_bytes: 13996
x, n = map(int, input().split())
p = list(map(int, input().split()))

nums = [i for i in range(102)]

for i in p:
    nums.remove(i)

ans = []
for i in reversed(nums):
    if i <= x:
        sx = x - i
        ans.append(i)
        break

for i in nums:
    if i >= x:
        lx = i - x
        ans.append(i)
        break

if sx <= lx:
    print(ans[0])
else:
    print(ans[1])

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  ll n,a,b;
  cin >>n>>a>>b;
  if( a==0 &&b==0){
    cout<< 0<<endl;
  }
  else{
    cout << a*(n/(a+b)) +min(a,n%(a+b))<<endl;
  }
  

  
}




Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	while(cin>>n>>m,n){
		vi in(n);rep(i,n)cin>>in[i];
		int out=-1;
		rep(i,n)loop(j,i+1,n)if(in[i]+in[j]<=m)out=max(out,in[i]+in[j]);
		if(out+1)cout<<out<<endl;
		else cout<<"NONE"<<endl;
	}
}













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

using namespace std;

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, a;
  cin >> n >> a;
  cout << n * n - a << endl;
  return 0;
}


Measured memory_bytes: 256
X = 0; Y = 10 ** 5
N = gets.to_i
G = Hash.new{|h,k| h[k] = [] }
USED = {}

N.times do
  x,y = gets.split.map(&:to_i)
  G[X + x] << Y + y
  G[Y + y] << X + x
end

def bigraph_edge_count(u)
  return 0 if USED[u]

  ys = 0
  xs = 0

  q = [u]
  USED[u] = u
  
  until q.empty?
    v = q.shift
    if v > Y
      ys += 1
    else
      xs += 1
    end
    G[v].reject{|w| USED[w] }.each do |w| 
      USED[w] = u
      q << w
    end
  end
  
  ys * xs
end

puts G.keys.inject(0){|s, u| s + bigraph_edge_count(u) } - N


Measured memory_bytes: 24060
#include <iostream>
#include <string>

using namespace std;

int n;

void dfs(string s, char mx)
{
  if (s.size() == n)
  {
    cout << s << endl;
    return;
  }
  for (char c = 'a'; c <= mx + 1; c++)
  {
    string t = s;
    t += c;
    // 今使ってる値と今までの最高のどっちか進んでる方
    dfs(t, max(mx, c));
  }
}

int main(void)
{
  cin >> n;
  dfs("", 'a' - 1);
  return 0;
}

Measured memory_bytes: 1536
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {

			String str = kb.readLine();
			String[] tmpArray = str.split( " " );
			int n=Integer.parseInt( tmpArray[0] );
			int m=Integer.parseInt( tmpArray[1] );
			int l=Integer.parseInt( tmpArray[2] );
						
			int[][] matrixA = new int[n][m];
			int[][] matrixB = new int[m][l];
			double[][] matrixC = new double[n][l];
			for( int i=0; i<n; i++ ) {
				str = kb.readLine();
				tmpArray = str.split( " " );
				for( int j=0; j<m; j++ ) {
					matrixA[i][j]=Integer.parseInt( tmpArray[j] );
				}
			}
			for( int i=0; i<m; i++ ) {
				str = kb.readLine();
				tmpArray = str.split( " " );
				for( int j=0; j<l; j++ ) {
					matrixB[i][j]=Integer.parseInt( tmpArray[j] );
				}
			}
			for( int i=0; i<n; i++ ) {
				for( int j=0; j<l; j++ ) {
					matrixC[i][j]=0;
				}
			}
			for( int i=0; i<n; i++ ) {
				for( int k=0; k<m; k++ ) {
					for( int j=0; j<l; j++ ) {
						matrixC[i][j]+=matrixA[i][k]*matrixB[k][j];
					}
				}
			}
			
			for( int i=0; i<n; i++ ) {
				for( int j=0; j<l; j++ ) {
					if( l-1 != j ) {
						System.out.printf( "%.0f ", matrixC[i][j] );
					} else {
						System.out.printf( "%.0f\n", matrixC[i][j] );
					}
				}
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 46112
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using sl = stack<ll>;
using ql = queue<ll>;

const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};


void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vl a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll N;
    bool ans = true;
    cin >> N;
    vb check(1000000002, false);
    REP(i, N){
        ll A;
        cin >> A;
        if(check[A] == false){
            check[A] = true;
        } else {
            ans = false;
            break;
        }
    }

    YES(ans);

    return 0;
}

Measured memory_bytes: 125224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  vector<int> T(1010),A(1010);
  for(int i=0;i<N;i++){cin >> T[i] >> A[i];}
  long long sum,t,a;
  sum=2; t=1; a=1;
  for(int i=0;i<N;i++){
    if(t*A[i]!=a*T[i]){
      long long q=(a+A[i]-1)/A[i]; long long r=(t+T[i]-1)/T[i];
      if(q==0 && r==0){a=A[i]; t=T[i];}
      else{
        long long qr=max(q,r);
        a=qr*A[i]; t=qr*T[i];
      }
    }
    //cout << t << " " << a << endl;
  }
  cout << t+a << endl;
}

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

int main() {

  long long N, W;
  cin >> N >> W;

  long long wList[N];
  long long vList[N];

  for ( int i=0; i<N; i++ ) {
    cin >> wList[i] >> vList[i];
  }

  long long wBase = wList[0];
  long long W_ = 305LL;
  for ( int i=0; i<N; i++ ) {
    wList[i] -= wBase;
  }

  long long dp[N+1][N+1][W_+1];
  for ( int n=0; n<N; n++ ) {
    for ( int k=0; k<N; k++ ) {
      for ( int w=0; w<=W_; w++ ) {
         dp[n][k][w]=0;
      }
    }
  }
  dp[0][0][0] = 0;
  for ( int n=0; n<N; n++ ) {
    for ( int k=0; k<N; k++ ) {
      for ( int w=0; w<=W_; w++ ) {

        if ( w-wList[n] >= 0 ) {
          dp[n+1][k+1][w] = max( dp[n][k][w-wList[n]] + vList[n], dp[n][k+1][w] );
        } else {
          dp[n+1][k+1][w] = dp[n][k+1][w];
        }

      }
    }
  }

  long long max_v = 0;
  for ( int k=0; k<=N; k++ ) {
    long long amari = W - k*wBase;
    if ( amari >= 0 ) {
      max_v = max( max_v, dp[N][k][min(amari, 300LL)] );
    }
  }
  cout << max_v << endl;

  return 0;
}

Measured memory_bytes: 24576
#include<stdio.h>
int main(){
  char s[100010],d[100010];
  int r,i;
  scanf("%s",s);
  for(i=r=0;s[i];i++){
    if(s[i]=='w'){
      if(r<2||d[r-1]-'e'||d[r-2]-'m')break;
      r-=2;
    }
    else d[r++]=s[i];
    if(r==0)break;
  }
  printf("%s\n",s[i+1]+r?"Rabbit":"Cat");
  return 0;
}

Measured memory_bytes: 528
// Author: Jashan Bansal
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second	
#define mp make_pair
#define int long long
#define ll long long
#define pii pair<int,int>
#define all(arr) arr.begin(), arr.end()
#define sz(arr) ((long long)arr.size())
// const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
#define log1(x) cout << x << '\n'
#define log2(x,y) cout << x << " " << y <<'\n'
#define log3(x,y,z) cout << x <<" " << y <<" " << z << '\n'
#define logarr(arr,n) for(int __=0; __ < n; __++)	cout << arr[__] << " "; cout << '\n'

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


void solve(){
	int n,w; cin >> n >> w;
	vi wt(n), val(n);
	for(int i=0; i<n; i++) cin >> wt[i] >> val[i];

	int s = accumulate(val.begin(), val.end(),0);

	vector<vi> dp(n+1, vi(s+1));

	dp[0][0] = 0;
	for(int i=1; i<= s; i++){
		dp[0][i] = 1e18;
	}

	int ans = INT_MIN;

	for(int i=1;i<=n; i++){
		for(int j=1; j<=s; j++){	
			dp[i][j] = (val[i-1] > j) ? dp[i-1][j] : min(dp[i-1][j], dp[i-1][j-val[i-1]] + wt[i-1]);
			if(dp[i][j] <= w)
				ans = max(ans, j);
		}
	}

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

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--)
		solve();
	return 0;
}	

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    if (i + 1 == N){
      cout << "Three" << endl;
    }
  }
}

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

int main() {
  int K,A,B;
  string ans ="NG";
  cin >> K >> A >> B;

  for(int i =A;i<=B;i++){
    
    if(i%K==0){
      ans = "OK";
      break;
    }
  }

  

  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
int main()
{
	int n, k;
    std::cin >> n >> k;
 
    std::vector<int> hs;
    for (int i = 0; i < n; i++)
    {
        int h;
        std::cin >> h;
        hs.push_back(h);
    }
 
    std::sort(hs.begin(), hs.end());
 
    int min = hs.at(k-1) - hs.at(0);
    for (int i = 1; i < n-k+1; i++)
    {
        min = std::min(min, hs.at(i+k-1) - hs.at(i));
    }
 
    std::cout << min << std::endl;
 

    return 0;
}



Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int i, cnt = 0, tmp = 0;
    char str[11];

    gets(str);
    for(i = 0; i < strlen(str); i++){
        if(str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T'){
            tmp++;
            cnt = cnt < tmp ? tmp : cnt;
        }else{
            tmp = 0;
        }
    }
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long sumA = 0;
		int[] aArray = new int[n];
		long sumB = 0;
		int[] bArray = new int[n];
		for(int i=0;i < n;i++) {
			int tmp = sc.nextInt();
			aArray[i] = tmp;
			sumA += tmp;
		}
		for(int i=0;i < n;i++) {
			int tmp = sc.nextInt();
			bArray[i] = tmp;
			sumB += tmp;
		}

		if(sumA < sumB) {
			System.out.println(-1);
			return;
		}
		int answer = 0;
		long fusokuPoint = 0;
		List<Integer> yojoPointList = new ArrayList<Integer>();
		for(int i =0;i <n;i++) {
			if(bArray[i] > aArray[i]) {
				fusokuPoint += bArray[i] - aArray[i];
				answer++;
			}else {
				yojoPointList.add(aArray[i] - bArray[i]);
			}
		}
		if(fusokuPoint ==0) {
			System.out.println(0);
			return;
		}
		Collections.sort(yojoPointList,Collections.reverseOrder());
		for(Integer yojoPoint : yojoPointList) {
			answer++;
			fusokuPoint-= yojoPoint;
			if(fusokuPoint <=0) {
				break;
			}

		}
		System.out.println(answer);
	}

}

Measured memory_bytes: 85520
import sys
N, M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        new = [A[k][j:j+M] for k in range(i,i+M)]
        if new == B:
            print('Yes')
            sys.exit()
print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

int main() {
  ll K;
  cin >> K;

  ll ans = 0;
  for (ll i = 1; i <= K; i++) {
    for (ll j = 1; j <= K; j++) {
      for (ll k = 1; k <= K; k++) {
        ans += __gcd(i, __gcd(j, k));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
//Author: QOEINDIEDIS
//Date: 09-23-2019
#include <bits/stdc++.h>
#define fill(x,c) memset(x,c,sizeof(x))
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const long long LL_INF = (long long) 2e18 + 5;
const int SIZE = 1e6+10;
ll n,i;
ll a[SIZE];
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
	cin>>n;
	for(i=sqrt(n);i>0;i--){
		if(n/i*i==n){
			break;
		}
	}
	cout<<(n/i+i-2);
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define INF (1<<21)
#define W 0
#define G 1
#define B 2

int n,A[100][100];
void dijkstra();

int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);

  for(i =0;i<n;i++){
     for(j =0;j<n;j++){
       A[i][j] = INF;
     }
  }
  for(i =0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j =0;j<k;j++){
      scanf("%d%d",&v,&c);
      A[u][v] = c;
    }
  }
  
  dijkstra();

  return 0;
}


void dijkstra(){
  int i,u,v,min,sum =0;
  int d[100],color[100];

  for(i =0;i<n;i++){
    d[i] = INF;
    color[i] = W;
  }

  d[0] = 0;
  color[0]=G;
  while(1){
    min = INF;
    u = -1;
    for(i =0;i<n;i++){
      if(min > d[i] && color[i] != B){
	u = i;
	min = d[i];
      }
    }
    if(u == -1)break;
    color[u] = B;
    for(v = 0;v < n;v++){
      if(color[v] != B && A[u][v] != INF){
	if(d[v] > d[u]+A[u][v]){
	  d[v] = d[u]+A[u][v];
	  color[v] = G;
	}
      }
    }
  }
    
  for(i =0;i<n;i++){
    printf("%d ",i);
    if( d[i] == INF){
      printf("%d\n",-1);
    }
    else printf("%d\n",d[i]);
  }
}



Measured memory_bytes: 2060
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long double PI=acos(-1.0),ans,a,b,x,c;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>x;
	c=x/(a*a);
	ans=90.0-atan(((c<(b/2.0))?(a*c*2.0/b/b):((a/2.0)/(b-c))))*180.0/PI;
	cout<<fixed<<setprecision(30)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  ll N,K;
  string s;
  cin>>N>>K;
  cin>>s;
  ll cnt=0,rem=0;
  for(int i=0;i<N;i++){
    if(s[i]=='L' && i>0 && s[i-1]=='L'){cnt++;}
    else if(s[i]=='R' && i+1<N && s[i+1]=='R'){cnt++;}
  }
  rem=N-1-cnt;
  while(K>0 && rem>0){
    K--;
    cnt+=min<ll>(rem,2);
    rem-=min<ll>(rem,2);
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 512
#pragma warning(disable:4996)
#include <stdio.h>

int main() {
	int w, h;
	int x, y;
	scanf("%d %d %d %d", &w, &h, &x, &y);

	printf("%lf %d\n", (double)w * (double)h / 2.00000f, x + x == w && y + y == h);
}

Measured memory_bytes: 128
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=998244353;         
const int N=1e6+4;
const int lim=61;

ll fac[N],infac[N];

ll me(ll a,ll b)
{
	ll res=1;

	while(b)
	{
		if(b&1)
		res=(res*a)%mod;

		b>>=1; a=(a*a)%mod;
	}

	return res;
}

ll mi(ll n)
{
	return me(n,mod-2);
}

void factorial()
{
	fac[0]=1;
	for(ll i=1;i<N;i++)
	fac[i]=(i*fac[i-1])%mod;
	//modular inverse factorial array in O(logn+n)=O(n) time
	infac[N-1]=mi(fac[N-1]); //O(logn)
	for(ll i=N-1;i>0;i--)
	infac[i-1]=(i*infac[i])%mod;
}

ll ncr(int n,int r)
{
	if(n<r)
	return 0;
	ll res=fac[n];
	res=(res*infac[r])%mod;
	res=(res*infac[n-r])%mod;
	return res;
}

int main()
{
	factorial();

	int n,m,k;

	cin>>n>>m>>k;

	ll ans=0;

	for(int i=0;i<=k;i++)
	{
		ll here=(m*me(m-1,n-1-i))%mod;

		ll ways=ncr(n-1,n-i-1);

		here=(here*ways)%mod;

		//cout<<here<<endl;

		ans=(ans+here)%mod;
	}

	lpri(ans);

    return 0;
}


Measured memory_bytes: 19392
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll gcd(ll c, ll d) {
    while (d > 0) {
        ll x = c;
        ll y = d;
        c = y;
        d = x % y;
    }
    return c;
}

int main()
{
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll n = c * d / gcd(c, d);
    ll _b = b - b / c - b / d + b / n;
    ll _a1 = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / n;
    cout << _b - _a1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define N 800
#define LL long long
 
const LL mod=1000000007;
LL n,m,a[N],b[N],f[N][N],g[N][N];
 
void upd(LL &x,LL y){x=(x+y%mod+mod)%mod;}
 
int main(){
	scanf("%lld",&n);
	for (LL i=0;i<n*2;++i) scanf("%lld",a+i);
	for (LL i=0;i<n;++i){
		LL x=a[i<<1],y=a[i<<1|1];
		if (x>0&&y>0){b[x]=b[y]=-1; continue;}
		if (x<0&&y<0){++m; continue;}
		if (x>0) b[x]=1;
		if (y>0) b[y]=1;
	}
	f[0][0]=1;
	for (LL i=1,x=0,y=0;i<=n*2;++i){
		if (b[i]<0) continue;
		memset(g,0,sizeof g);
		if (b[i]>0){
			for (LL j=0;j<=x+y;++j)
				for (LL k=0;k<=x+y;++k){
					upd(g[j+1][k],f[j][k]);//m
					if (k) upd(g[j][k-1],f[j][k]*k);//m
				}
			++x;
		}
		else{
			for (LL j=0;j<=x+y;++j)
				for (LL k=0;k<=y;++k){
					if ((j-k-x+y)>=0) upd(g[j+1][k],f[j][k]);//m-1
					if (j) upd(g[j-1][k],f[j][k]);//m
					upd(g[j][k+1],f[j][k]);//m
				}
			++y;
		}
		memcpy(f,g,sizeof f);
	}
	for (int i=1;i<=m;i++) f[0][0]=1LL*f[0][0]*i%mod;
	printf("%lld\n",f[0][0]);
	
	return 0;
}

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

int main()
{   
     ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	int n,k; 
    cin >> n >> k ;

	int heights[n];
	for(int i = 0 ; i < n ; i ++ ) cin >> heights[i];

	/**
      
     Recursive relationship.
     dp[i] = min(dp[j] + abs(heights[i]-heights[j])) for j = i+1,i+2;

	*/
    
	vector<int>dp(n,INT_MAX);  
    dp[n-1] = 0 ;
    dp[n-2] = abs(heights[n-2]-heights[n-1]);

    for(int i = n-3 ; i >= 0; i --)
    {   
        for( int j = i+1 ; j <= min(n-1,i+k); j ++) 
    	   dp[i] = min(dp[i],dp[j] + abs(heights[i]-heights[j]));
    	
    } 

    cout << dp[0] << endl; 

}

Measured memory_bytes: 3972
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecint a(n, 0);
  REPe(e, a) cin >> e;
  int ans = 0;
  REP(i, n) {
    if ((i + 1) % 2 != 0 && a[i] % 2 != 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644