akhauriyash/Code-Regression huggingface dataset:
import java.nio.ByteBuffer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder(1200);
		do {
			sb.append(br.readLine());
		} while (br.ready());
		String str = sb.toString();
		int len = str.length();
		int[] alpabetCnt = new int[26];
		for (int i = 0; i < len; i++) {
			byte[] bytes = String.valueOf(str.charAt(i)).getBytes();
			int index = 0;
			boolean flg = true;
			for (byte b : bytes) {
				if (judgeByte(b) == 0) {
					flg = false;
				}
				else if (judgeByte(b) == -1) {
					index = b % 65;
				}
				else if (judgeByte(b) == 1) {
					index = b % 97;
				}
			}
			if (flg)
				alpabetCnt[index] = alpabetCnt[index] + 1;
		}
		String label = "a";
		for (int cnt : alpabetCnt) {
			System.out.println(label + " : " + cnt);
			byte[] bs = label.getBytes();
			bs = toBytes(bs[0] + 1);
			label = new String(bs, "US-ASCII");
		}
	}

	private static byte[] toBytes(int n) {
		byte[] bs = new byte[1];
		bs[0] = (byte) (0x000000ff & (n));
		return bs;
	}

	private static int judgeByte(byte b) {
		if (b < 65 | (b > 90 & b < 97) | b > 122) {
			return 0;
		}
		if (b < 91) {
			return -1;
		}
		return 1;
	}
}

Measured memory_bytes: 24612
#include <iostream>
#include <string>
using namespace std;
string rot(string s, int n){
	for(int i = 0; s[i] != '\0'; i++){
		if(s[i] >= 65 && s[i] <= 90) s[i] = (s[i] - 65 + n) % 26 + 65;
		else if(s[i] >= 97 && s[i] <= 122) s[i] = (s[i] - 97 + n) % 26 + 97;
	}
	return s;
}
// the this that
string text[3] = {"the", "this", "that"};
int main(){
	string line;
	while(getline(cin, line)){
		for(int i = 0; i < 26; i++){
			line = rot(line, 1);
			if(line.find(text[0], 0) != string::npos || line.find(text[1], 0) != string::npos || line.find(text[2], 0) != string::npos){
				cout << line << endl;
				break;
			}
		}
	}
	return 0;
}

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


int main(){
    char c;
    cin>>c;
    vector<char> v = {'a','e','i','o','u'};

    cout<< ((find(v.begin(), v.end(),c)!=v.end()) ? "vowel": "consonant")<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define MAXN 100+10
using namespace std;
inline int read(){
	int out=0;
	char c=getchar();
	while(c<48||c>57) c=getchar();
	while(c<=57&&c>=48){
		out=(out<<1)+(out<<3)+c-48;
		c=getchar();
	}
	return out;
}
inline void write(int x){
	if(x>9) write(x/10);
	putchar(x%10+48);
}
int a[MAXN];
int b[MAXN];
int n;
int sum=0;
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
		sum+=a[i];
	}
	int m=read();
	for(int i=1;i<=m;++i){
		int x=read();
		int y=read();
		int ans=sum;
		ans-=a[x];
		ans+=y;
		write(ans);
		putchar(10);
	}
	return 0;
}


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

int main(){
  
  char c,d;
  cin >> c >> d;
  string ans = "No";

  if(c == '9' || d == '9'){
    ans = "Yes";
  }
  cout << ans << endl;

}

Measured memory_bytes: 384
def main():
    N = int(input())
    A = list(map(int, input().split()))
    total = 0
    previous = 0
    for i in range(N-1):
        if i == 0:
            if A[i] > A[i+1]:
                total += (A[i]-A[i+1])
            previous = A[i+1] + total
        else:
            diff = 0
            if previous > A[i+1]:
                diff += (previous-A[i+1])
                total += diff
            previous = A[i+1] + diff
    print(total)
main()


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

using namespace std;


int main() {
  int N;
  cin >> N;
  vector<int> v(2*N);

  for(int i=0; i< 2*N; i++) {
    cin >> v[i];
  }

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

  int result = 0;
  for (int i=0; i<N;i++)
    result += v[2*i];

  cout << result << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    char c;
    cin >> c;
    printf("%c\n", c+1);
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  int x1=0,x2=0;
  for(int i=0;i<n;i++){
    int x; cin >> x;
    x1+=x; x2+=x*x;
  }

  int ans=10000000;
  for(int i=0;i<101;i++){
    ans=min(x2-2*i*x1+n*i*i, ans);
  }

  cout << ans << endl;

  return 0;
}

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

int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	using ll = long long;
	ll N;
	cin >> N;
	if(N == 1 or N == 2) {
		cout << "0" << endl;
	} else {
		ll ans = N - 1;
		for(ll d = 2; d * d <= N; d++) if(N % d == 0) {
			{
				ll m = d - 1;
				if(N / m == N / d) ans += m;
			}
			if(d != N / d) {
				ll m = N / d - 1;
				if(N / m == d) ans += m;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int x,n,p,i,ans=(1<<29),ans1;
  vector<int> a(110,0);
  cin >> x >> n;
  for(i=0;i<n;i++){
    cin >> p;
    a[p]=1;
  }
  for(i=0;i<=105;i++){
    if(a[i]==1){
      continue;
    }
    if(ans>abs(i-x)){
      ans=abs(i-x);
      ans1=i;
    }
  }
  if(ans>abs(-1-x)){
    ans=abs(-1-x);
    ans1=-1;
  }
  cout << ans1 << endl; 
  return 0;
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();
        int N = r.i();
        int[] tmp = r.ii();
        ArrayList<Double> v = new ArrayList<>();
        for(int i : tmp)
            v.add((double)i);
        for(int i = 0; i < N-1; i++){
            v.sort(null);
            double x = v.remove(0);
            double y = v.remove(0);
            v.add(0, (x+y)/2);
        }
        println(v.get(0));
    }
    
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, x, c;
  c = 0;
  cin >> X;
  x = X;
  for(int i = 8; i >= 0; i--){
    int j = 0;
    int r = 1;
    while(j < i){r *= 10;
                 j++;
                }
    c += (x - x%r)/r;
    x -= x/r*r;
  }
  if(X%c == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    
    

Measured memory_bytes: 256
//Author : Nishit Patel
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef double db;
typedef long long ll;
#define pb push_back
#define FAST cin.sync_with_stdio(0); cin.tie(0);
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define arep(i, a, n)  for(int i = a; i <= (n); ++i)
#define drep(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x)     for(auto& a : x)
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef unordered_map<ll, ll> hash;
#define deb_1(A)                     {cerr << "[" << #A << "] : " << A << endl;}
#define deb_2(A,B)                   {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl;}
#define deb_3(A,B,C)                 {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl;}
#define deb_4(A,B,C,D)               {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl<< "[" << #D << "] : " << D << endl;}
#define deb_X(x,A,B,C,D,FUNC, ...)  FUNC  
#define deb(...)                    deb_X(,##__VA_ARGS__,\
                                          deb_4(__VA_ARGS__),\
                                          deb_3(__VA_ARGS__),\
                                          deb_2(__VA_ARGS__),\
                                          deb_1(__VA_ARGS__),\
                                         )
                                         
                                        

int main() {
	FAST
	ll n,ans =0;
	
	cin>>n;
	ll v[n];
	ll dp[n];
	rep(i,n)
	{
		cin>>v[i];
	}
	dp[0] = 0;
	dp[1] = abs(v[0] -v[1]);
	arep(i,2,n)
	{
		dp[i] = min((dp[i-2]+ abs(v[i] - v[i-2])),(dp[i-1]+ abs(v[i] - v[i-1])));
	}
	cout<<dp[n-1]<<endl;	
}


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

int main()
{
  ll n;cin >> n;
  vector<ll> a;
  rep(i,n) {
    int tmp; cin >> tmp;
    a.push_back(tmp);
  }

  int ans = 0;
  bool can = true;
  while (can) {
    rep(i, a.size()) {
      if (a[i]%2 != 0) can = false;
    }
    if (can) ans++;
    else break;

    rep(i, a.size()) {
      a[i] /= 2;
    }
  }

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

Measured memory_bytes: 256
def main():
    K, S = map(int, input().split())

    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if z >= 0 and z <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
// AOJ GRL_6_A
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

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

using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vc;

const int INF = 0x3fffffff;

// ?????§???????±???????(Dinic??????bfs()??????????????¨Ford-Fulkerson???)
class Flow{
	public:
		int N;	// ????????°
		vector<vc> F, C, edge;	// F:????????°?????? C:???????????? edge:??£??\????????????
		vector<bool> bf;	// ??????????????£???????????????
		vector<int> lv;	// S??????????????¢

		// ????????????????????? n:????????°
		Flow(int n): F(n,vc(n)), C(n,vc(n)), N(n), edge(n) {}

		// f->t????????????c?????????????????????(??????f->t??????????????????????????????????????¨?????????)
		void addEdge(int f, int t, int c){
			F[f][t] += c;
			C[f][t] += c;
			edge[f].push_back(t);
			edge[t].push_back(f);
		}

		// ??????f->t?????¢????????????addEdge()???????????????????????????????????????????????¨??????
		void uniqueEdge(){
			for(auto e: edge){
				sort( e.begin(), e.end() );
				e.erase( unique( e.begin(), e.end() ), e.end() );
			}
		}

		// s????????????????????¢????±?????????????????????????????????¨DFS??§?????????????????????????????¢?´¢??????
		int bfs(int S, int T){
			lv.assign(N, 0);
			queue<int> que;
			que.push(S);
			lv[S] = 1;
			while( !que.empty() ){
				int n = que.front(); que.pop();
				for(auto v: edge[n]) if( !lv[v] && F[n][v] ){
					lv[v] = lv[n] + 1;
					que.push(v);
				}
			}
			return lv[T];
		}

		// ?¢?????????????DFS??§??¢???
		int dfs(int n, int c, int T){
			if( n == T ) return c;
			bf[n] = true;
			for(int v: edge[n]) if( F[n][v] && !bf[v] && lv[v] > lv[n] ){	// ??????????????¶??????????????¨bfs()?????????????????????
				int f = dfs(v, min(c, F[n][v]), T);
				F[n][v] -= f;
				F[v][n] += f;
				if( f > 0 ) return f;
			}
			return 0;
		}

		// ?????§???????±???????
		int maxFlow(int S, int T){
			if( S == T ) return INF;
			int ret = 0;
			while( bfs(S,T) )	// bfs()???????????´?????????????????????????????????
				for(int add; bf.assign(N,0), add = dfs(0, INF, T);) ret += add;
			return ret;
		}

		// ????????????????????????????????????
		int flow(int f, int t){ return C[f][t] - F[f][t]; }

		// ??°???????????????????????????
		void clear(){ rep(i,N) rep(j,N) F[i][j] = C[i][j]; }
};

int main(){
	int V, E;
	cin >> V >> E;
	Flow fl(V);
	rep(i, E){
		int u, v, c;
		cin >> u >> v >> c;
		fl.addEdge( u, v, c );
	}

	cout << fl.maxFlow(0, V-1) << endl;

	return 0;
}

Measured memory_bytes: 3244
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  long long k;
  cin >> n >> k;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i], A[i]--;
  vector<bool> visited(n, false);
  int cnt = 0;
  int idx = 0;
  for (long long i = 0; i < k; ++i) {
    if (visited[idx]) { break; }
    visited[idx] = true;
    idx = A[idx];
    cnt++;
  }
  if (cnt == k) {
    cout << ++idx << endl;
  } else {
    int iidx = 0;
    int ccnt = 0;
    while (iidx != idx) iidx = A[iidx], k--, ccnt++;
    k %= (cnt - ccnt);
    while (k) {
      idx = A[idx];
      k--;
    }
    cout << ++idx << endl;
  }
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, a, b, c, d;
	string s; cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;
	auto ok1 = [&](int l, int r){
		for(int i = l; i < r; i++){
			if(s[i] == '.' && i > 0 && s[i - 1] == '.' && i + 1 < n && s[i + 1] == '.')
			return true;
		}
		return false;
	};
	auto ok2 = [&](int l, int r){
		for(int i = l; i < r; i++){
			if(s[i] == '#' && i + 1 < n && s[i + 1] == '#')
			return false;
		}
		return true;
	};
	if(!(ok2(a, c) && ok2(b, d))){
		cout << "No" << endl;
		return 0;
	}
	
	if(c < d){
		cout << "Yes" << endl;
		return 0;
	}
	cout << (ok1(b, d + 1) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main ()
{
    ll a,v,b,w,t,s1,s2;
    cin>>a>>v>>b>>w>>t;
     if(abs(a-b)<=(v-w)*t) cout<<"YES"<<endl;
     else cout<<"NO"<<endl;
}


Measured memory_bytes: 3556
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a-b) <= d && abs(b-c) <= d){
        cout << "Yes" << endl;
        return 0;
    }
    if (abs(a-c) <= d){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}   



Measured memory_bytes: 888
N = eval(input())
for _ in range(N):
	x1, y1, x2, y2, x3, y3, x4, y4 = [eval(item) for item in input().split()]
	if abs(x1 - x2) < 1e-10 or abs(x3 - x4) < 1e-10:
		print('YES' if abs(x1 - x2) < 1e-10 and abs(x3 - x4) < 1e-10 else 'NO')
	elif abs((y1 - y2)/(x1 - x2) - (y3 - y4)/(x3 - x4)) < 1e-10:
		print('YES')
	else:
		print('NO')

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

int main() {
  string S; cin >> S;
  
  int count = 0;
  for (int i = 1; i < S.size(); i++) {
    if (S[i-1] == S[i]) {
      if (i == S.size()-1) count++;
      else {
        S[i] = 'A';
        S[i+1] = 'B';
        count++;
      }
    }
  }
  cout << S.size() - count << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>

using namespace std;
const int a = 1e5 + 1000;
int f[a];

int findf(int q){
    if(f[q] < 0){
        return q;
    }
    else{
        f[q] = findf(f[q]);
        return f[q];

    }
}
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i =0; i< a; i++){
        f[i]=  -1;

    }
    for(int i=0; i < M; i++){
    int X;
    int Y;
    int Z;
    cin >> X >> Y >> Z;
    int fx;
    int fy;
    fx = findf(X);
    fy = findf(Y);
    if(fx != fy){f[fy] = fx;
    }
    }
    int b =0;
    for(int i = 1; i<=N; i++){
        if(f[i] < 0){
            b ++;
        }
    }
    cout << b;
}


Measured memory_bytes: 640
<?php

const MOD = 1000000007;
fscanf(STDIN, "%d",$N);
$left = fscanf(STDIN, str_repeat("%d", $N));
$right = fscanf(STDIN, str_repeat("%d", $N));
$right[] = 0;
$left[-1] = 0;
$now = 0;
$ans = 1;
if($right[0] != $left[$N-1]){
    echo 0;
    exit;
}
for($i=0;$i<$N;$i++){
    $now = 0;
    if($left[$i-1] != $left[$i]){
        $now = $left[$i];
    }
    if($now > 0 && $now > $right[$i]){
        echo 0;
        exit;
    }
    if($right[$i] != $right[$i+1]){
        if($now === 0 && $left[$i] < $right[$i]){
            echo 0;
            exit;
        }

        $now = $right[$i];
    }
    if($now===0){
        $ans *= min($left[$i], $right[$i]);
        $ans %= MOD;
    }

}
echo $ans;

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

const int MX = 100 * 1000 + 7;

int p[MX], q[MX];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    map<pair<int, int>, int> gao;
    int a, b, m;
    cin >> a >> b >> m;
    for (int i = 1; i <= a; i++) {
        cin >> p[i];
    }
    for (int i = 1; i <= b; i++) {
        cin >> q[i];
    }

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        gao[make_pair(x, y)] = max(gao[make_pair(x, y)], z);
    }

    int ans = 1e9 + 7;

    auto wu = [&](int i, int j) {
        ans = min(ans, p[i] + q[j] - gao[make_pair(i, j)]);
    };

    int ma = 1, mb = 1;
    for (int i = 2; i <= a; i++) {
        if (p[i] < p[ma]) {
            ma = i;
        }
    }
    for (int i = 2; i <= b; i++) {
        if (q[i] < q[mb]) {
            mb = i;
        }
    }

    wu(ma, mb);
    for (const auto& go : gao) {
        wu(go.first.first, go.first.second);
    }

    cout << ans << "\n";

    return 0;
}


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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        char arr[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
		int n; cin>>n;
      	string s; cin>>s;
      	for(auto x :s) cout<<arr[x-'A'+n];
		cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>

int main(){

    int ans=0;
    int N,M;
    int L[100000]={0};
    int R[100000]={0};

    std::cin>>N>>M;
    for(int i=0;i<M;i++){
        std::cin>>L[i]>>R[i];
    }
   
    int s=1,g=N;

    for(int i=0;i<M;i++){
        if(L[i]>s){
            s=L[i];
        }
        if(R[i]<g){
            g=R[i];
        }
    }

    ans=g-s+1;

    if(ans>0){
        std::cout<<ans<<std::endl;
    }else{
        std::cout<<0<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
ans = 0
i = 2

while n>1 and i*i<=n:
  if n % i == 0:
    c = 0
    while n % i == 0:
      n = n / i
      c = c + 1
    Y=1
    U=2
    while c>=Y:
      ans=ans+1
      Y=Y+U
      U=U+1

  i += 1
      
    
if n > 1:
  ans = 1 + ans

print(ans)

Measured memory_bytes: 9260
package main

import (
	"fmt"
)

func main() {
	var n, a, f int
	fmt.Scan(&n)
	var colors [8]bool
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if a < 3200 {
			colors[a/400] = true
		} else {
			f++
		}
	}
	var cnt int
	for _, c := range colors {
		if c {
			cnt++
		}
	}
	max := cnt + f
	min := cnt
	if cnt == 0 {
		min = 1
	}
	fmt.Println(min, max)
}


Measured memory_bytes: 1772
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


S = input()


count = 0
ans = 0
for s in S:
    if s == "B":
        count += 1
    else:
        ans += count
print(ans)


Measured memory_bytes: 41564
a,b,c,d = gets.chomp.split(" ").map(&:to_i)

cnum = b/c - a/c
if a%c == 0
    cnum += 1
end

dnum = b/d - a/d
if a%d == 0
    dnum += 1
end

cd = c.lcm(d)
cdnum = b/cd - a/cd
if a%cd == 0
    cdnum += 1
end

abnum = b-a+1

puts abnum-cnum-dnum+cdnum


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N, X, Y;
  scanf("%lld %lld %lld", &N, &X, &Y);

  map<ll, ll> m;
  for (ll i = 1; i <= N - 1; i++) {
    for (ll j = i + 1; j <= N; j++) {
      ll d1 = j - i;
      ll d2 = abs(X - i) + 1 + abs(Y - j);
      ll d3 = abs(Y - i) + 1 + abs(X - j);

      ll dist = min(min(d1, d2), d3);
      m[dist]++;
    }
  }

  for (ll i = 1; i < N; i++) {
    cout << m[i] << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> s[m];
  for(int i = 0; i < m; i++){
    int k;
    cin>>k;
    for(int j = 0; j < k; j++){
      int a;
      cin>>a;
      a--;
      s[i].push_back(a);
    }
  }
  int p[m];
  for(int i = 0; i < m; i++) cin>>p[i];
  int ans = 0;
  for(int i = 0; i < (1<<n); i++){
    bool flag = true;
    for(int j = 0; j < m; j++){
      int cnt = 0;
      for(int l = 0; l < s[j].size(); l++){
          if(i&(1<<s[j][l])){
            cnt++;
          }
        }
        if(cnt%2!=p[j]){
          flag = false;
        }
      }
      if(flag) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = intScanner()
	}
	p := make([]int, n)
	m := make([]int, n)
	for i := 0; i < n; i++ {
		if i+as[i] < n {
			p[i+as[i]]++
		}
		if i-as[i] >= 0 {
			m[i-as[i]]++
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		ans += p[i] * m[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8036
using System;
using System.Collections.Generic;

class program
{
    static void Main()
    {
        List<int> Date =  Dateinput();

        int[,] ArrayDate = GetArray(Date);

        for (int i =0;i < ArrayDate.GetLength(0);i++)
        {
            
                int Answer;
            Answer = Algorithm(ArrayDate[i, 0], ArrayDate[i, 1]);
            Console.WriteLine("{0}", Answer);
 
        }


    }


    static List<int> Dateinput()
    {
        List<int> date = new List<int> { };

        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');

            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);

            if (x == 0 && y == 0)
                break;

            date.Add(x);
            date.Add(y);
        }

        return date;
    }


    static int[,] GetArray(List<int> list)
    {
        
        int Length = list.Count;

        int Row = Length / 2;

        int count = 0;

        int[,] DateArray = new int[Row,2];

        for (int i=0;i < Row;i++)
        {
            for (int j=0;j<2;j++)
            {
                DateArray[i, j] = list[count];
                count += 1;
            }
        }

        return DateArray;
        
    }

    static int Algorithm(int x,int y)
    {
        int count = 0;
       for (int i = 1;i < x+1;i++)
        {
            for (int j=1;j< x+1;j++)
            {
                for (int k=1;k< x+1;k++)
                {
                    int SUM = i + j + k;
                    if ((i != j)&&(i != k))
                    {
                        if (j != k)
                        {
                            if (SUM == y)
                            {
                                count += 1;
                            }
                        }
                    }
                    
                }
            }
        }

        return count/6;
    }
}

Measured memory_bytes: 9140
def main():
  MOD=10**9+7
  N=int(input())
  A=list(map(int,input().split()))
  def lcm(a,N):
      from fractions import gcd
      x = a[0]
      y=  a[N//2]
      for i in range(1, N//2):
          x = (x * a[i]) // gcd(x, a[i])
          y = (y * a[i+N//2]) // gcd(y, a[i+N//2])
      y = (y * a[-1]) // gcd(y, a[-1])
      return (x*y)//gcd(x,y)
  z=lcm(A,N)
  ans=0
  for i in range(N):
    ans+=z//A[i]
  print(ans%MOD)
  
if __name__=='__main__':
  main()

Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

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

	int N; cin >> N;
	ll s = 0;
	int cnt = 0;
	int num = INF;
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp;
		s += abs(tmp);
		if (tmp < 0)cnt++;
		num = min(num, abs(tmp));
		
	}

	if (cnt % 2 == 1) s -= (2 * num);

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//<(") 
#define ll long long 
using namespace std;
 
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;
 
const ll mod = 998244353;
const ll siz = 3e3 + 10;
const ll base = 32;
const ll MAXX = 1e18;

ll n, s;
vector<ll> hold;

ll res[siz][siz];

ll dp(ll pos, ll rem) {
	if (pos >= n) {
		return rem == 0;
	}
	ll &ans = res[pos][rem];
	if (ans != -1) {
		return ans;
	}
	ans = (dp(pos + 1, rem) * 2) % mod;
	if (rem - hold[pos] >= 0) {
		ans = (ans + dp(pos + 1, rem - hold[pos])) % mod;
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	cin >> n >> s;
	hold.resize(n);
	for (ll i = 0; i < n; i++) {
		cin >> hold[i];
	}
	memset(res, -1, sizeof(res));
	cout << dp(0, s) << '\n';
	return 0;
}

Measured memory_bytes: 74608
#include<stdio.h>
int main(void)
{
	int n,m,t[101],g[101][101],i,j,ans[101]={0},cnt;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d",&t[i]);
	}
	for(i=1;i<=m;i++){
		cnt=0;
	   for(j=1;j<=n;j++){
		scanf("%d",&g[i][j]);
		if(t[i]==g[i][j]){
				ans[j]++;
			}
			else{
				cnt++;
			}
		}
		ans[t[i]]+=cnt;
	   }
	for(i=1;i<=n;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}


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

#define int long long

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

	int t[n+1][cap+1];
	for(i=0;i<=n;i++) // value and wt.
	{
		for(j=0;j<=cap;j++) // capacity
		{
			if(i==0 or j==0)
				t[i][j]=0;

			else if(w[i-1]>j)
				t[i][j] = t[i-1][j];
			else
				t[i][j] = max(v[i-1]+t[i-1][j-w[i-1]],t[i-1][j]);
		}
	}
	// for(i=0;i<=n;i++)
	// {
	// 	for(j=0;j<=cap;j++)
	// 		cout << t[i][j] <<" ";
	// 	cout << endl;
	// }
	cout << t[n][cap] << endl;	
}

Measured memory_bytes: 82508
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    ll money = 0;
    int count = 0;
    int i = 0;
    cin >> n >> m;
    vector< pair<int, int> > p(n);
    rep(i, n) {
      int a, b;
      cin >> a >> b;
      p[i] = make_pair(a, b);
    }
    sort(p.begin(), p.end());
    while (count < m) {
      while (p[i].second > 0 && count < m) {
        money += p[i].first;
        p[i].second--;
        count++;
      }
      i++;
    }
    cout << money << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long long N, A, B; cin >> N >> A >> B;
    long long div = N / (A + B);
    long long rem = N % (A + B);

    long long result = div * A;
    result += min(A, rem);
    
    cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;

using namespace std;


signed main() {
  int N, a;
  cin >> N;

  priority_queue<double, vector<double>, greater<double>> p;
  REP(i, N){
    cin >> a;
    p.push(a);
  }

  double sum;
  while(p.size() != 1){
    sum = p.top();
    p.pop();
    sum += p.top();
    p.pop();
    p.push(sum/2);
  }

  cout << p.top() << endl;

  return 0;
}

Measured memory_bytes: 256
/* 01 - 19*/

#include <iostream>
#include <vector>
#include <map>
using namespace std;
int n;
int data[26][26],fi[26],la[26];
string st;

bool flag;

void bt(char next,int depth){
	if(depth == n-1){
		if(next == st[0])flag = true;
	}
	if(flag)return;
	
	for(int i=0;i<26;i++){
		if(data[next-'a'][i]){
			data[next-'a'][i]--;
			bt('a'+i,depth+1);
			data[next-'a'][i]++;
		}
	}
}
int main(){
	while(cin >> n,n){
		for(int i=0;i<26;i++){
			fi[i] = la[i] = 0;
			for(int j=0;j<26;j++)
				data[i][j] = 0;
		}
		for(int i=0;i<n;i++){
			cin >> st;
			data[st[0]-'a'][st[st.length()-1]-'a']++;
			fi[st[0]-'a']++;
			la[st[st.length()-1]-'a']++;
			
		}
		
		data[st[0]-'a'][st[st.length()-1]-'a']--;
		flag = false;
		bool notSearch = false;
		
		for(int i=0;i<26;i++){
			if(fi[i] != la[i])notSearch = true; 
		}
		
		if(!notSearch)bt(st[st.length()-1],0);
		cout << (flag?"OK":"NG") << endl;
	}
}	

Measured memory_bytes: 916
#include <cstdio>
#include <cstring>
void read(int &a){
	a=0;
	char c=getchar();
	while(c<'0'||c>'9'){
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		a=(a<<1)+(a<<3)+(c^48);
		c=getchar();
	}
}
template<typename Elem_1,typename Elem_2>
Elem_1 min(Elem_1 a,Elem_2 b){
	return a<b?a:b;
}
const int Maxn=5000;
const int Maxm=1000000;
const int Inf=0x3f3f3f3f;
struct Edge{
	int to,nxt,val;
	int cap,flow;
}edge[Maxm<<1|5];
int head[Maxn+5],tot;
void unuse_add_edge(int from,int to,int cap,int val){
	edge[++tot].to=to;
	edge[tot].nxt=head[from];
	edge[tot].val=val;
	edge[tot].cap=cap;
	edge[tot].flow=0;
	head[from]=tot;
}
void add_edge(int from,int to,int cap,int val){
	unuse_add_edge(from,to,cap,val);
	unuse_add_edge(to,from,0,-val);
}
int n,m;
int qu[Maxn+5],qu_f,qu_t;
int dis[Maxn+5];
bool vis[Maxn+5];
bool in_q[Maxn+5];
char mp[55][55];
int id[55][55],id_tot;
int S,T;
bool Dinic_bfs(){
	memset(dis,0x3f,sizeof dis);
	qu_f=1,qu_t=0;
	qu[++qu_t]=S;
	in_q[S]=1;
	dis[S]=0;
	while(qu_f!=qu_t+1){
		int u=qu[qu_f++];
		in_q[u]=0;
		qu_f%=(Maxn+1);
		for(int i=head[u];i;i=edge[i].nxt){
			int v=edge[i].to;
			if(edge[i].flow==edge[i].cap){
				continue;
			}
			if(dis[u]+edge[i].val<dis[v]){
				dis[v]=dis[u]+edge[i].val;
				if(!in_q[v]){
					in_q[v]=1;
					qu_t++;
					qu_t%=(Maxn+1);
					qu[qu_t]=v;
				}
			}
		}
	}
	return dis[T]!=Inf;
}
int Dinic_dfs(int u,int flow,int &min_cost){
	if(u==T||flow==0){
		return flow;
	}
	vis[u]=1;
	int sum=0;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(dis[v]!=dis[u]+edge[i].val||vis[v]||edge[i].flow==edge[i].cap){
			continue;
		}
		int op=min(flow-sum,edge[i].cap-edge[i].flow),f;
		if(f=Dinic_dfs(v,op,min_cost)){
			edge[i].flow+=f;
			edge[((i-1)^1)+1].flow-=f;
			min_cost+=edge[i].val*f;
			sum+=f;
			if(sum==flow){
				break;
			}
		}
	}
	vis[u]=0;
	if(sum==0){
		dis[u]=Inf;
	}
	return sum;
}
int Dinic(int &min_cost){
	int ans=0;
	min_cost=0;
	while(Dinic_bfs()){
		ans+=Dinic_dfs(S,Inf,min_cost);
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",mp[i]+1);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			id[i][j]=++id_tot;
		}
	}
	S=++id_tot;
	T=++id_tot;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(mp[i][j]=='#'){
				continue;
			}
			if(mp[i][j]=='o'){
				add_edge(S,id[i][j],1,0);
			}
			add_edge(id[i][j],T,1,0);
			if(i<n&&mp[i+1][j]!='#'){
				add_edge(id[i][j],id[i+1][j],Inf,-1);
			}
			if(j<m&&mp[i][j+1]!='#'){
				add_edge(id[i][j],id[i][j+1],Inf,-1);
			}
		}
	}
	int ans;
	Dinic(ans);
	printf("%d\n",-ans);
	return 0;
}


Measured memory_bytes: 2084
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1; i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
int n,m;
vector<int>p;
vector<string>s;
void input(){
    cin>>n>>m;
    p.resize(m);
    s.resize(m);
    rep(i,m){
        cin>>p[i]>>s[i];
    }
}
void src(){
    if(m==0){cout<<"0 0"; return;}
    int ac=0;
    vector<int> wa(n,0);
    vector<bool> f(n,0);
    rep(i,n){ f[i]=false;}
    rep(i,m){
        if(f[p[i]-1]==false){
            if(s[i]=="AC"){
                ac++;
                f[p[i]-1]=true;
            }else{
                wa[p[i]-1]++;
            }
        }
    }
    int wa2=0;
    rep(i,n){
        if(f[i]==true){
            wa2+=wa[i];
        }
    }
    cout<<ac<<" "<<wa2;
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	LL ans=0;
	for(int i=1;i<=n;i++){
		ans+=1ll*i*(n-i+1);
	}
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(u>v){
			swap(u,v);
		}
		ans-=1ll*u*(n-v+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;


int main() { 
    ll H, W;
    cin >> H >> W;
    if(H>W) swap(H, W);
    if(H==1){
        cout << 1 << endl;
    }
    else{
        cout << (H*W +1)/2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void) {
    string s;

    cin >> s;

    for (int i = 0, len = s.length(); i < len - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        } else if (i + 2 <= len - 1 && s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

constexpr ll MOD = 1000000007;

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

ll frac[200001];
ll frac_inv[200001];
void init() {
  frac[0] = 1;
  frac_inv[0] = 1;
  REP(i,200000) {
    frac[i+1] = frac[i] * (i+1);
    frac[i+1] %= MOD;
    frac_inv[i+1] = inv(frac[i+1], MOD);
  }
}

ll comb(ll n, ll k) {
  ll tmp = frac[n]*frac_inv[k];
  tmp %= MOD;
  tmp *= frac_inv[n-k];
  return tmp % MOD;
}

int main()
{
  init();
  ll b,w;
  cin>>b>>w;
  ll p=0;
  ll q=1;
  ll r=0;
  ll inv2 = inv(2, MOD);
  ll div = 1;
  ll mul = 1;
  REP(i,b+w) {
    ll oldp = p;
    ll oldr = r;
    if (i < w) {
      p = 0;
    } else {
      p = 2*oldp + comb(i-1, w-1);
      p %= MOD;
    }
    if (i < b) {
      r = 0;
    } else {
      r = 2*oldr + comb(i-1, b-1);
      r %= MOD;
    }
    q = mul - p - r;
    while(q < 0) q += MOD;
    q %= MOD;
    //cerr << p << ' ' << q << ' ' << r << endl;
    ll upper = 2*p + q;
    upper %= MOD;
    ll lower = div*inv2;
    lower %= MOD;
    ll ans = upper*lower;
    ans %= MOD;
    cout << ans << endl;
    div *= inv2;
    div %= MOD;
    mul *= 2;
    mul %= MOD;
  }
  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
bool isrpime(int x){
    if(x==2){
        return true;
    }
    if(x<2 || x%2==0){
        return false;
    }
    int i=3;
    while(i<=sqrt(x)){
        if(x%i==0){
            return false;
        }
        i+=2;
    }
    return true;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a,count=0;
    rep(i,n){
        cin>>a;
        if(isrpime(a)){
            count++;
        }
    }
    cout<<count<<'\n';
    return(0);
}


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



int main(){
		
		int a,b,c;
		cin>>a>>b>>c;
		int arr [2000];
		for (int i=0;i<a;i++)arr[i]=0;
		for(int i=1;i<a;i++)
			for(int j=i+1;j<=a;j++){
				if(j<=b||i>=c){
					arr[j-i]++;
					continue;
				}
				if(i>=b&&j<=c){
					arr[min(j-i,c-b+1-j+i)]++;
					continue;
				}
				if(i<b&&j>c){
					arr[b-i+j-c+1]++;
					continue;
				}
				if(i<b&&j<=c){
					arr[b-i+min(j-b,c-b+1-j+b)]++;
					continue;
				}
				if(i>=b&&j>c){
					arr[j-c+min(c-i,c-b+1-c+i)]++;
				}
			}
		for(int i=1;i<a;i++)cout<<arr[i]<<endl;	
		return 0;
}

Measured memory_bytes: 256
///Code by: Luis Alejandro
///Handle: Sekai
///Country: Cuba

#include <bits/stdc++.h>
#define endl '\n'
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")

using namespace std;

typedef unsigned long long ull;
typedef long long lld;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN=1e5+5;
const int MOD=1e9+7;
const int INF=INT_MAX;
const ld PI=acos(-1);
const ld EPS=1e-9;

#define lg2(x) 31-__builtin_clz(x)
#define logx(a,b) (log(a)/log(b))
#define read(x) cin>>x;

pii mkp(int a, int b){
    if(a>b)swap(a,b);
    return make_pair(a,b);
}

int mod_pow(int a, int b){
    if(!b)return 1;
    if(b&1)return mod_pow(a,b-1)*a%MOD;
    int power=mod_pow(a,b>>1);
    return power*power%MOD;
}

int modular_inverse(int a){
    return mod_pow(a,MOD-2);
}

int lcm(int a, int b){
    return ((a*b)/__gcd(a,b));
}

int nelements(int l, int r){return (abs(r-l)+1);}

int pow2(int a){
    return a*a;
}

int pow3(int a){
    return a*a*a;
}

#define l_shift(x,y) (x<<y)
#define r_shift(x,y) (x>>y)

vector<int> movy={0,0,1,-1};
vector<int> movx={1,-1,0,0};

void solve(){
    map<string,int> fq;
    int n;
    cin>>n;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        fq[s]++;
    }
    cout<<"AC x "<<fq["AC"]<<endl;
    cout<<"WA x "<<fq["WA"]<<endl;
    cout<<"TLE x "<<fq["TLE"]<<endl;
    cout<<"RE x "<<fq["RE"]<<endl;
}

int main()
{
    //freopen("IN.txt","r",stdin);
    //freopen("OUT.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //int t;cin>>t;while(t--)solve();
    solve();
    return 0;
}

Measured memory_bytes: 3664
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; j <= n; j++ {
			if i+j > n {
				continue
			}
			if i*10000+j*5000+1000*(n-(i+j)) == y {
				fmt.Printf("%d %d %d\n", i, j, n-(i+j))
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 512