akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> L(n);
    for(int i = 0; i < n; i++) cin >> L[i];
    sort(L.begin(), L.end());
    int ans = 0;
    for(int b = 0; b < n; ++b){
        for(int a = 0; a < b; ++a){
            int ab = L[a] + L[b];
            int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
            int l = b + 1;
            ans += r - l;
        }
    }
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int h, w;
    char[][] css;

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

    void run() {
        FastReader sc = new FastReader();
        h = sc.nextInt();
        w = sc.nextInt();
        css = new char[h][];
        for (int i = 0; i < h; i++) {
            css[i] = sc.next().toCharArray();
        }
        solve();
    }

    void solve() {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(css[i][j]);
            }
            System.out.println();
            for (int j = 0; j < w; j++) {
                System.out.print(css[i][j]);
            }
            System.out.println();
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 25096
S_original=input()
S_list=list(S_original)
length_S=len(S_list)

a=0
i=0

while i < length_S:
  if S_list[i]=='+':
    a += 1
    i += 1
  else:
    a = a-1
    i=i+1
    

print(a)
  

Measured memory_bytes: 2940
import sys

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

n=int(input())
ap=list(map(int,input().split()))
amin=min(ap)
amax=max(ap)

if amax==1:
    print("pairwise coprime")
    sys.exit()

if amin!=1:
    bp=enum_div(amin)+[amin]
    bp=bp[1:]
    for bpi in bp:
        yn=""
        for ai in ap:
            if ai%bpi!=0:
                yn="coprime"
                break
        if yn=="":
            print("not coprime")
            sys.exit()

if n>=78500 :
    print("setwise coprime")
    sys.exit()

aa=[0]*(amax+1)
for ai in ap:
    aa[ai]+=1
    
for pp in range(2,amax+1):
    psum=sum(aa[pp: :pp])
#    print("pp:",pp,psum)
    if psum>=2:
            print("setwise coprime")
            sys.exit()
## max_13.txt ... max_16.txt : "setwise coprime"
print("pairwise coprime")
   


Measured memory_bytes: 181488
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

typedef complex<double> Point, Vector;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

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

    double x1, y1, x2, y2, x3, y3, x4, y4;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
        if(x1 > x4 || y1 > y4 || x2 < x3 || y2 < y3) cout << "NO" << endl;
        else cout << "YES" << endl;
    }

    return 0;
}


Measured memory_bytes: 3244
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
using namespace std;

int n;
int a, b;
int mark[200002];
vector<int>vec[200002];
vector<int>ends;
int find_diameter(){
	if (n == 1) return 0;
	memset(mark, -1, sizeof(mark));
	queue<int>q;
	q.push(1);
	mark[1] = 0;
	int temp;
	while(!q.empty()){
		temp = q.front();
		q.pop();
		for (int i=0;i<vec[temp].size();i++){
			if (mark[vec[temp][i]] == -1){
				mark[vec[temp][i]] = mark[temp] + 1;
				q.push(vec[temp][i]);
			}
		}
	}
	q.push(temp);
	memset(mark, -1, sizeof(mark));
	mark[temp] = 0;
	while(!q.empty()){
		temp = q.front();
		q.pop();
		for (int i=0;i<vec[temp].size();i++){
			if (mark[vec[temp][i]] == -1){
				mark[vec[temp][i]] = mark[temp] + 1;
				q.push(vec[temp][i]);
			}
		}
	}
	return mark[temp];
}
int winstate[500002];
int main(){
	scanf("%d", &n);
	for (int i=1;i<n;i++){
		scanf("%d %d", &a, &b);
		vec[a].push_back(b);
		vec[b].push_back(a);
	}	
	int diameter = find_diameter();
	winstate[1] = 1;
	winstate[2] = 0;
	winstate[3] = 1;
	for (int i=4;i<=200002;i++){
		winstate[i] = 1 ^ min(winstate[i-1], winstate[i-2]);
	
	}
	if (winstate[diameter+1] == 1)printf("First\n");
	else printf("Second\n");
	return 0;
}

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

int main() {
	long long int x,k,d,r,s;
	cin>>x>>k>>d;
	if (x<0){
		r=0-x;
		s=(r/d);
		if (s>=k){
			cout<<r-(k*d);
			return 0;
		}
		else{
			r=r-(s*d);
			k=k-s;
			if (k%2==0){
				cout<<r;
			}
			else{
				cout<<abs(-r+d);
			}
		}
	}
	else{
		r=x;
		s=(r/d);
		if (s>=k){
			cout<<r-(k*d);
			return 0;
		}
		else{
			r=r-(s*d);
			k=k-s;
			if (k%2==0){
				cout<<r;
			}
			else{
				cout<<abs(r-d);
			}
		}
	}
	
	return 0;
}

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

void solveA(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;
}
void solveB(){
  int n,t,ci,ti;
  cin >> n >> t;
  int ans = 2000;
  
  for(int i=0;i<n;i++){
    cin >> ci >> ti;
    if (ci<=ans && ti<=t) ans = ci;
  }
  if (ans==2000) cout << "TLE" << endl;
  else cout << ans << endl;  
}

void solveC(){
}
void solveD(){
}

int main(){
  solveA();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char s[5];
int main()
{
	scanf("%s",s+1);cout<<s[1];
	scanf("%s",s+1);cout<<s[2];
	scanf("%s",s+1);cout<<s[3];
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    if (s == u)
    {
        a--;
    }
    else if (t == u)
    {
        b--;
    }

    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 384
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

INF = 10 ** 10
dp = [[INF] * (N * 1000 + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(N * 1000 + 1):
        if j <= wv[i - 1][1]:
            dp[i][j] = min(dp[i][j], wv[i - 1][0])
        else:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - wv[i - 1][1]] + wv[i - 1][0])
        dp[i][j] = min(dp[i][j], dp[i - 1][j])

ans = 0
for i in range(N * 1000 + 1):
    if dp[N][i] <= W:
        ans = max(ans, i)
print(ans)


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

int64_t calc(string, bitset<10>, int);

int main() {
  string s_num;
  cin >> s_num;
  const int n = s_num.size();

  //bitset<10> b;
  //int n = stoi(num);
  int64_t sum = 0;

  for (int tmp = 0; tmp < (1 << n-1); tmp++) {
    bitset<10> b(tmp);
    //cout << b << endl;

    sum += calc(s_num, b, n);
  }

  cout << sum << endl;
}

int64_t calc(string s_num, bitset<10> b, int n) {
  int64_t ret = 0;
  int tmp = -1; //前の1の位置
  //int pow_10 = 1;
  int64_t t;
  //cout << b << " : ";
  for (int i = 0; i < n-1; i++) {
    if(b[i] == 1) {
      t = (int)stoll(s_num.substr(tmp+1, i - tmp));
      ret += t;
      tmp = i;
      //cout << t << " + ";
    }
  }
  t = (int64_t)stoll(s_num.substr(tmp+1));
  ret += t;
  //cout << t << " = " << ret << endl;

  return ret;
}

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

int main() {
	string S;
	cin >> S;
	int ans = 700;
	for (int i = 0;i<S.size();++i) {
		if ('o' == S[i]) {
			ans += 100;
		}
	}
	cout << ans <<  endl;
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while (1) {
		minv = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != -1) {
			sum += M[i][p[i]];
		}
	}
	return sum;
}

int main(void) {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int e; cin >> e;
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}
	int k = prim();
	printf("%d\n", k);
	return 0;
}


Measured memory_bytes: 3220
// 1142_OrganizeYourTrainpartII.cpp
//
#include <bits/stdc++.h>
using namespace std;
void solve(string s) {
  int len=s.length();
  set<string> st;
  for(int i=1;i<=len-1;++i){
    string a=s.substr(0,i);
    string b=s.substr(i,len-i);

    st.insert(a+b);
    st.insert(b+a);

    reverse(b.begin(),b.end());

    st.insert(a+b);
    st.insert(b+a);

    reverse(a.begin(),a.end());

    st.insert(a+b);
    st.insert(b+a);

    reverse(b.begin(),b.end());

    st.insert(a+b);
    st.insert(b+a);
  }
  cout<<st.size()<<endl;
}
int main() {
  int n;
  string s;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>s;
    solve(s);
  }
  return 0;
}



Measured memory_bytes: 3100
/*input
iphone
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define inf 1000000000000000001
#define F first
#define S second
#define dbg(x) cout << #x << " = " << x << '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void solve()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}

int main() 
{
    off;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

bool comp(pair<pair<int,int>,string> G,pair<pair<int,int>,string> H){
    int Ga=G.first.first;
    int Gb=G.first.second;
    int Ha=H.first.first;
    int Hb=H.first.second;
    
    if(Ga-Gb>=0 && Ha-Hb<0)return true;
    if(Ga-Gb<0 && Ha-Hb>=0)return false;
    
    if(Ga-Gb>=0 && Ha-Hb>=0){
        return Gb<Hb;
    }else{
        return Ga>Ha;
    }
}

signed main(void){
    int N;
    string S;
    vector<pair<pair<int,int>,string>> V;
    
    cin >> N;
    REP(i,N){
        cin >> S;
        int a=0,b=0;
        REP(j,S.size()){
            if(S[j]=='('){
                a++;
            }else{
                b++;
            }
        }
        V.push_back({{a,b},S});
    }
    
    sort(V.begin(),V.end(),comp);
    
    //REP(i,N){cout << V[i].second << endl;}
    
    
    int now=0;
    bool ok = true;
    REP(i,N){
        string S = V[i].second;
        REP(j,S.size()){
            if(S[j]=='('){
                now++;
            }else{
                now--;
            }
            if(now<0)ok=false;
        }
    }
    if(now!=0)ok = false;
    
    cout << (ok?"Yes":"No") << endl;
    
    return 0;
}




Measured memory_bytes: 52408
from itertools import permutations
import math
n = int(input())
A = []
for _ in range(n):
    x,y = map(int,input().split())
    A.append([x,y])
tmp = 0
cnt = 0
for L in permutations(A):
    cnt += 1
    for i in range(1,len(L)):
            tmp += math.sqrt((L[i][0]-L[i-1][0])**2+(L[i][1]-L[i-1][1])**2)
print(tmp/cnt)
    

Measured memory_bytes: 73904
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; public Pair(int xx, int yy) { x = xx; y = yy; } }
    private static int[] dx = { 1, 0, -1, 0 };
    private static int[] dy = { 0, -1, 0, 1 };
    public static void Main()
    {
        int N = NextInt();
        int Z = NextInt();
        int W = NextInt();
        int[] a = LineInt();
        //最後のカードは必ずどっちかがとる

        //Xがとる場合
        int pt1 = Math.Abs(a[N - 1] - W);

        //Yがとる場合
        int pt2 = 0;
        if (N != 1) pt2 = Math.Abs(a[N - 2] - a[N - 1]);

        Console.WriteLine(Math.Max(pt1, pt2));
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13524
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

int main() {
    size_t k = input();
    size_t a = input();
    size_t b = input();
    for (auto i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3640
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

rew = { 'r': P, 's': R, 'p': S, }
win = { 'r': 'p', 's': 'r', 'p': 's' }
te = {'r', 's', 'p'}

tot = 0
for i in range(K):
    tv = T[i::K] + 'k'
    # 左から勝っていく
    mae = ''
    for j in range(len(tv)-1):
        s = tv[j]
        ns = tv[j+1]

        if mae != win[s]:
            tot += rew[s]
            mae = win[s]
        else:
            if ns == 'k':
                break
            mae = te - {win[ns], mae}
print(tot)

Measured memory_bytes: 3316
def bury(i,j)
  @map[i][j] = "0"
  [[0,1],[1,0],[0,-1],[-1,0]].each do |x,y|
    next if !(0..11).include?(i+x) || !(0..11).include?(j+y)
    bury(i+x,j+y) if @map[i+x][j+y]=="1"
  end
end

loop do
  @map = 12.times.map{ gets.chomp }
  cnt = 0
  12.times do |i|
    12.times do |j|
      if @map[i][j]=="1"
        cnt += 1
        bury(i,j)
      end
    end
  end
  puts cnt
  break if gets.nil?
end

Measured memory_bytes: 6320
K, A, B = map(int, input().split())

bisket = 1
money = 0

if B - A > 2:
    remain = K - A + 1
    bisket = A
    bisket += remain // 2 * (B - A)
    if remain % 2 == 1:
        bisket += 1
else:
    bisket += K

print(bisket)


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

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

Measured memory_bytes: 3632
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	map<string,int>mp;
	while (N--) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3668
s=input()
t=input()
n=len(s)
A='abcdefghijklmnopqrstuvwxyz'
i=0
while A:
    if s==t:
        print('Yes')
        exit()
    if i==n:
        print('No')
        exit()
    if s[i]==t[i]:
        if s[i] in A:
            A=A.replace(s[i],'')
    else:
        if s[i] in A and t[i] in A:
            if t[i] in s:
                A=A.replace(t[i],'')
                s=s.replace(s[i],'X').replace(t[i],s[i]).replace('X',t[i])
            else:
                A=A.replace(t[i],'')
                s=s.replace(s[i],t[i])
        else:
            print('No')
            exit()
    i+=1

Measured memory_bytes: 3872
#include<iostream>
using namespace std;
int main(){
    int A,B,C,X,k = 0;
    cin >> A >> B >> C >> X;
    for (int l = 0;l <= A; l++)
    {
        for (int m = 0;m <= B; m++)
        {
            for (int n = 0;n <= C;n++)
            {
                int Y = 500*l + 100*m + 50*n;
                if(Y == X)k++;
            }
            
        }
        
    }
    cout << k << endl;
}

Measured memory_bytes: 3152
/*author  ADITYA BANSAL
         //~ MNNIT ALLAHABAD     */
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long
ll power(ll,ll);
ll ncr(ll,ll);
void fact();
ll mul(ll a,ll b);
#define watch(x) cerr<<(#x)<<"is"<<x<<nl;
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi(a,b) for(ll i=a; i<b; i++)
#define fk(a,b) for(ll k=a; k<b; k++)
#define fri(a,b) for(ll i=a; i>b; i--)
#define fj(a,b) for(ll j=a; j<b; j++)
#define ffi(a,b) for(ll i=a;i*i<=b;i++)
#define mp make_pair
#define ff first 
#define  tc ll t; cin>>t; while(t--)
#define all(v) (v).begin(),(v).end()
#define ss second
#define pb push_back
#define mem(v) memset((v),0,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define pob pop_back
#define nl endl
const int mod=1e9+7;
const ll  N=100002LL;
ll fac[N+2];
ll inv[N+2];



signed main(){ fast
	//~ tc
	
	{
		 ll h,w;
		 cin>>h>>w;
		 
		char a[h+1][w+1];
		fi(1,h+1) fj(1,w+1) cin>>a[i][j];
		
		ll dp[h+1][w+1],f=0;
		fi(1,h+1) { if(a[i][1]=='#' || f )  {dp[i][1]=0; f=1;} else dp[i][1]=1; } 
		f=0;
		fi(1,w+1) { if(a[1][i]=='#' || f )  {dp[1][i]=0; f=1;} else dp[1][i]=1;}
		
		fi(2,h+1) {
			fj(2,w+1)  if(a[i][j]=='#')
			dp[i][j]=0;
			else{
				dp[i][j]= ad(dp[i-1][j],dp[i][j-1]);
			}
		}
		cout<<dp[h][w]<<nl;
		
	}
    return 0;
}
 
 
/******************************************************************************/
 
ll mul(ll a,ll b){
    return ((a)*(b))%mod;
}
 
ll power(ll a,ll n){
  ll res=1;
  while(n){
      if(n&1) res= mul(res,a);
     n>>=1; 
     a= mul(a,a);
  }
    return res;
}
void fact(){
	inv[0]=fac[0]=1;
	fi(1,N){
	 fac[i]=mul(fac[i-1],i);
	inv[i]=power(fac[i],mod-2);
}
}
 
ll ncr(ll r,ll n){
	
	if(r>n) return 0;
	ll e=fac[n];
	e=mul(e,inv[r]);
	e=mul(e,inv[n-r]);
	return e;
}


Measured memory_bytes: 9088
#include <stdio.h>
int main(void) {
  int a[100],b[100],n,m,i,j,suma,sumb,total,a1,a2;
  while(1){
  	a1=-1;
  	a2=-1;
scanf("%d%d",&n,&m);
suma=sumb=0;
if(n==0&&m==0)break;
for(i=0;i<n;i++){
	scanf("%d",&a[i]);
	suma+=a[i];
}
for(i=0;i<m;i++){
	scanf("%d",&b[i]);
	sumb+=b[i];
}
total==suma+sumb;
if(total%2==1)break;
else{
for(i=0;i<n;i++){
for(j=0;j<m;j++){
	if((suma-a[i]+b[j])==(sumb-b[j]+a[i])){
		a1=a[i];
		a2=b[j];
	}
	if(a1!=-1)break;
}if(a1!=-1)break;
}
  }
  
if(a1!=-1)printf("%d% d\n",a1,a2);
else printf("-1\n");
}
  return 0;
}

Measured memory_bytes: 612
using System;
using System.IO;
using System.Linq;

class Solve{
    static void Main(string[] args){
        var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var A = arr[0];
        var B = arr[1];
        var M = arr[2];
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var answer = a.Min() + b.Min();
        for (int i = 0; i < M; i++){
            var xyc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var disctTgt = a[xyc[0] - 1] + b[xyc[1] - 1] - xyc[2];
            answer = disctTgt < answer ? disctTgt : answer;}
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 53140
#include<bits/stdc++.h>
using namespace std;
static const int INF=(1<<21);
int m[101][101],n;
int d[101]; //最短距離を記録
void bfs(int s){
  queue<int>q;
  q.push(s); //始点sを入れる（訪問）
  for(int i=0;i<n;i++) d[i]=INF;//予めINFを入れておく
  d[s]=0;
  while(!q.empty()){
    int u=q.front();
    q.pop(); //キューから頂点uを取り出し、訪問
    for(int v=0;v<n;v++){
      if(m[u][v]==0) continue;
      //辺がない
      if(d[v]!=INF) continue;
      //訪問したことがある
      d[v]=d[u]+1; //vは未訪問の頂点であり、隣接しているため、d[u]に1を足す
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<( (d[i]==INF)?(-1):d[i] )<<endl;
  }
}
int main(){
  int u,k,v;
  scanf("%d",&n);
   for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      m[u][v]=1;
    }
  }
   bfs(0);
   return 0;
}
      


Measured memory_bytes: 3184
'''C - Slimes
https://atcoder.jp/contests/abc143/tasks/abc143_c

>>> main(10, 'aabbbbaaca')
5
>>> main(5, 'aaaaa')
1
>>> main(20, 'xxzaffeeeeddfkkkkllq')
10

'''


def main(n, s):
    i = 0
    tmp = ''

    for s in s:
        if s != tmp:
            i += 1

        tmp = s

    print(i)


if __name__ == "__main__":
    n = int(input())
    s = input()

    main(n, s)


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;}
#define chmin(a, b) a = min((a), (b));

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

//const int INF = 1 << 30;
const int INF = 10000;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n, m;
	cin >> n >> m;
	vector<vi> d(n, vi(n, INF));
	rep(i, m) {
		int s, t, dt;
		cin >> s >> t >> dt;
		d[s][t] = dt;
	}

	vector<vi> dp(1 << n, vi(n, INF));
	dp[0][0] = 0;	// limit start to 0 because cyclic

	rep(i, 1 << n) rep(j, n) rep(k, n) {
		if(i & (1 << j)) continue;	// already visited
		chmin(dp[i | (1 << j)][j], dp[i][k] + d[k][j]);
	}

	int ans = dp[(1 << n) - 1][0];
	cout << (ans == INF ? -1 : ans) << endl;
//	show2(dp[15], n, n);
}



Measured memory_bytes: 6236
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: u64 = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    a[0] %= m;
    for i in 1..n {
        a[i] = (a[i] + a[i - 1]) % m;
    }

    let mut ans = 0u64;
    let mut zero = 0u64;
    let mut mp = std::collections::HashMap::new();

    for i in 0..n {
        let cnt = mp.entry(&a[i]).or_insert(0);
        ans += *cnt;
        *cnt += 1;
        if a[i] == 0 {
            zero += 1;
        }
    }
    ans += zero;
    println!("{}", ans);
}


Measured memory_bytes: 14588
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.C
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int n = cin.NextInt();
			var c = new List<int>();
			var s = new List<int>();
			var f = new List<int>();
			var ans = new List<int>();
            for (int i = 0; i < n-1; i++)
            {
				c.Add(cin.NextInt());
				s.Add(cin.NextInt());
				f.Add(cin.NextInt());

				ans.Add(0);
				for (int j = 0; j < ans.Count; j++)
				{
					if (ans[j] == 0) ans[j] += s[i];
					else ans[j] = (Math.Max(0, (ans[j] - s[i] + f[i] - 1) / f[i])) * f[i] + s[i];
					ans[j] += c[i];
				}
			}
			ans.Add(0);

            foreach (var item in ans)
            {
                Console.WriteLine(item);
            }

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	int i,j,k=-1;
	string s;
	cin >> s;
	int a = (int)s[0]-48, b = (int)s[1] - 48, c = (int)s[2] - 48, d = (int)s[3] - 48;
	vector<int> e(2), f(2);
	vector<string> op1 = { "+","-" }, op2 = { "+","-" }, op3 = { "+","-" };

	e[0] = a + b;
	e[1] = a - b;
	f[0] = c + d;
	f[1] = c - d;

	for (i = 0; i < 2; i++) {
		for (j = 0; j < 2; j++) {
			if (e[i] + f[j] == 7) {
				k = 0;
				break;
			}
			else if (e[i] - f[j] == 7) {
				k = 1;
				break;
			}
		}
		if (k >= 0) {
			break;
		}
	}
	if (k >= 0) {
		cout << a << op1[i] << b << op2[k] << c << op3[((j == k) - 1) * -1] << d << "=7" << endl;
	}
	else {
		cout << "Error!" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define MAXN 505

int n, m, ans[MAXN][MAXN] ;
char s[MAXN][MAXN] ;
int main() {
	scanf("%d%d", &n, &m) ;
	for (int i = 1; i <= n; ++ i) scanf("%s", s[i] + 1) ;
	for (int i = 1; i <= n; ++ i) ans[i][1] = 1 ;
	for (int i = 1; i <= n; i = i + 2)
	for (int j = 2; j < m; ++ j) ans[i][j] = 1 ;
	for (int i = 1; i <= n; ++ i)
	for (int j = 1; j <= m; ++ j)
		if (s[i][j] == '#') ans[i][j] = 2 ;
	for (int i = 1; i <= n; ++ i, putchar('\n'))
	for (int j = 1; j <= m; ++ j)
		if (ans[i][j]) putchar('#') ; else
			putchar('.') ;
	puts("") ;
	for (int i = 1; i <= n; ++ i, putchar('\n'))
	for (int j = 1; j <= m; ++ j)
		if (ans[i][j] ^ 1) putchar('#') ; else
			putchar('.') ; 
	return 0 ;
}

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

int main() {
	int a,b,c,buf;
	cin >> a >> b >> c;
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	if(b>c){
		buf=b;
		b=c;
		c=buf;
	}
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	cout << a << " "<< b << " " << c << endl;
	
	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
@@@@@@@@@@@ ȁQ
@@@@@ ȁQ @iL<_M j@ Welcome to My Coding Space!
@@@@ i L_T`j@/@ i     @hamayanhamayan0
@@@@^@@@_@ @  |@|
@@@ /@@ /PPPP/@@|
@ Q_(__Ƃ/@    Q/ .| .|QQQQ
@ @@@_/QQQQ/@iu@
---------------------------------------------------------------------------------------------------*/














int X, Y, A, B, C;
int p[101010], q[101010], r[101010];
ll smpq[201010];
ll smr[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X >> Y >> A >> B >> C;
	rep(i, 0, A) cin >> p[i];
	rep(i, 0, B) cin >> q[i];
	rep(i, 0, C) cin >> r[i];

	vector<int> pq;
	sort(p, p + A, greater<int>());
	rep(i, 0, X) pq.push_back(p[i]);
	sort(q, q + B, greater<int>());
	rep(i, 0, Y) pq.push_back(q[i]);
	sort(all(pq), greater<int>());

	smpq[0] = 0;
	rep(i, 0, X + Y) smpq[i + 1] = smpq[i] + pq[i];

	sort(r, r + C, greater<int>());
	smr[0] = 0;
	rep(i, 0, C) smr[i + 1] = smr[i] + r[i];

	ll ans = 0;
	rep(c, 0, min(C, X + Y) + 1) chmax(ans, smr[c] + smpq[X + Y - c]);
	cout << ans << endl;
}







Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main()
{
  int n,m; cin>>n>>m;
  int v[n][m] = {0};
  int w[m] = {0};
  int r = n, k = m; 
  rep(i,n)rep(j,m) cin>>v[i][j];
  rep(i,m) cin>>w[i];
  rep(i,n)
  {
    int out = 0;
    rep(j,m)
      out += w[j] * v[i][j];
    cout << out << "\n";
  }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int a, b, c; cin >> a >> b >> c;
    set<int> st;
    st.insert(a); st.insert(b); st.insert(c);
    cout << st.size() << endl;
}

Measured memory_bytes: 256
while True:
    m, f, l = [int(i) for i in input().split()]
    if (m == -1) and (f == -1) and (l == -1):
        break
    total = 0
    if m > 0:
        total += m
    if f > 0:
        total += f
    if m == -1 or f == -1:
        print("F")
    elif total >= 80:
        print("A")
    elif total >= 65:
        print("B")
    elif total >= 50:
        print("C")
    elif total >= 30:
        if l >= 50:
            print("C")
        else:
            print("D")
    elif total < 30:
        print("F")


Measured memory_bytes: 5604
n, m = map(int, input().split())
ikeru = [[] for _ in range(n)]
for i in range(m):
	a, b = map(int, input().split())
	ikeru[a - 1].append(b - 1)
	ikeru[b - 1].append(a - 1)

fukasa = [10 ** 18 for _ in range(n)]
kaisuu = 0
settansaku = set([])
setmada = set([0])
kouho = 1

while kouho != 0:
	kaisuu += 1
	for i in list(setmada):
		settansaku.add(i)
		setmada.remove(i)
		kouho -= 1
		for k in ikeru[i]:
			if not k in setmada:
				if not k in settansaku:
					setmada.add(k)
					kouho += 1
					fukasa[k] = kaisuu

if fukasa[n-1] <= 2:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Measured memory_bytes: 59176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>
#define ll long long
#define lint long long
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
#define INF 1e9

#define mod 1000000007
int i, j, k, l, m;
int N, M, K;
int dp[100005][2];
int main()
{
    cin >> N;
    vector<pair<long, long>> p(N);

    vector<pair<long, long>> q(N);
    rep(i, N)
    {
        cin >> p[i].first >> p[i].second;
    }

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

    long dx, dy;
    int ans = (N == 1) ? 1 : INF;
    int match;
    int a = (N == 1) ? 1 : 1;
    //rep(i,N)cout<<p[i].first<<" "<<p[i].second<<endl;

    // cout <<p[3].first<<p[3].second << endl;
    for (int k = 0; k < N; k++)
    {
        for (i = k + 1; i < N; i++)
        {

            //       cout << "k=:"<<k <<",i="<<i<<"pk="<<p[k].first<<" " << p[k].second << "pi="<<p[i].first << " " << p[i].second <<endl;
            dx = p[i].first - p[k].first;
            dy = p[i].second - p[k].second;

            if (dx != 0 || dy != 0)
            {
                int tmp = 1;
                match = 0;
                j = 0;
                while (j < N)
                {
                    for (l = j + 1; l < N; l++)
                    {
                        if (((p[l].first - p[j].first) == dx && (p[l].second - p[j].second) == dy))
                        {
                            match++;
                            //    j = l;
                         //   break;
                        }
                        else
                            tmp++;
                    }
                    //if (l == j)
                    //   continue;
                    //                 cout << "dx:" << dx << "dy:" << dy << endl;
                    //                cout << "tmp:" << tmp << "match:" << match << endl;
                    j++;
                }

                ans = min(ans, tmp);
                a = max(a, match);
            }
        }
    }
    //cout << ans << endl;
    if (N == 1) cout << 1 << endl;
    else cout << (N - a) << endl;
    //  cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
/*===============================================================
*  Filename: C.cpp
*  Author: zhuyutian
*  Date: 2018.04.16
================================================================*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100005;

int n,a,b,c,d;

int main()
{
    //freopen("C.in","r",stdin);
    //freopen("C.out","w",stdout);
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	bool ok = false;
	ll D = b - a;
	for(int k = 0; k <= n - 1; k++){
		ll l = 1ll * k * (-d) + 1ll * (n - 1 - k) * c;
		ll r = 1ll * k * (-c) + 1ll * (n - 1 - k) * d;
		if(D >= l &&  D<= r) ok = true;
	}
	puts(ok ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# UnionFind
class UnionFind():
    def __init__(self, n):
        self.nodes=[-1] * n  # nodes[x]: 負なら、絶対値が木の要素数

    def get_root(self, x):
        # nodes[x]が負ならxが根
        if self.nodes[x] < 0:
            return x
        # 根に直接つなぎ直しつつ、親を再帰的に探す
        else:
            self.nodes[x]=self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x, y):
        root_x=self.get_root(x)
        root_y=self.get_root(y)
        # 根が同じなら変わらない
        # if root_x == root_y:
        # pass
        if root_x != root_y:
            # 大きい木の方につないだほうが計算量が減る
            if self.nodes[root_x] < self.nodes[root_y]:
                big_root=root_x
                small_root=root_y
            else:
                small_root=root_x
                big_root=root_y
            self.nodes[big_root] += self.nodes[small_root]
            self.nodes[small_root]=big_root

def main():
    N,M=MI()
    P=LI_()

    uf=UnionFind(N)
    get_root, unite, nodes=uf.get_root, uf.unite, uf.nodes

    XY=LLIN_(M)
    for x,y in XY:
        unite(x,y)

    ans = 0
    for i,a in enumerate(P):
        ans += get_root(i)==get_root(a)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 100784
#include<bits/stdc++.h>
using namespace std;
long long s;
long long bx=1000000000ll;
int main(){
	scanf("%lld",&s);
	if(s==1000000000000000000ll){
		cout<<"0 "<<"0 "<<"1000000000 "<<"1 "<<"0 "<<"1000000000";
		return 0;
	}
		long long cx=bx-(s%bx);
		long long cy=(s+cx)/bx;
		cout<<"0 "<<"0 "<<"1000000000 "<<"1 "<<cx<<" "<<cy;
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int n;
	
	int a[10000];
	
	while(true){
		cin >> n;
		if(cin.eof()){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> a[i];
			a[i] = -a[i];
		}
		
		sort(a, a + n);
		
		int ans = 0;
		
		for(int i = 0; i < n; i++){
			a[i] = -a[i];
			ans += (i + 1) * a[i];
			//printf("%d ", a[i]);
		}
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

struct P {
    bool operator<(const P& p) const {
        return a > p.a;
    }
    int a, i;
};

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

    int n;
    cin >> n;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        p[i] = { a, i };
    }
    sort(p.begin(), p.end());

    ll dp[2001];
    dp[0] = 0;
    for (int k = 0; k < n; k++) {
        dp[k + 1] = dp[k] + (ll)p[k].a * (p[k].i - k);
        for (int i = k - 1, j = 0; i >= 0; i--, j++) {
            dp[i + 1] = max(dp[i] + (ll)p[k].a * (p[k].i - i), dp[i + 1] + (ll)p[k].a * (n - 1 - j - p[k].i));
        }
        dp[0] += (ll)p[k].a * (n - 1 - k - p[k].i);
    }

    cout << *max_element(dp, dp + n + 1) << endl;

    return 0;
}

Measured memory_bytes: 3688
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int m = sc.nextInt();
        
        // ans: r行すべてとc列すべてにある爆弾の個数の最大値
        int ans = 0;
        
        // countr, countc: 各行各列に存在する爆弾の個数
        // setp: 爆弾の存在する点の集合
        // maxr, maxc: countr, countcの最大値
        int[] countr = new int[h];
        int[] countc = new int[w];
        Set<String> setp = new HashSet<String>();
        int maxr = 0;
        int maxc = 0;
        for (int i = 0; i < m; i++) {
            int row = sc.nextInt()-1;
            int col = sc.nextInt()-1;
            countr[row]++;
            countc[col]++;
            setp.add(row + " " + col);
            maxr = Math.max(maxr, countr[row]);
            maxc = Math.max(maxc, countc[col]);
        }
        
        // setr, setc: maxr, maxcである行、列の集合
        Set<Integer> setr = new HashSet<Integer>();
        for (int i = 0; i < h; i++) {
            if (maxr == countr[i]) setr.add(i);
        }
        Set<Integer> setc = new HashSet<Integer>();
        for (int i = 0; i < w; i++) {
            if (maxc == countc[i]) setc.add(i);
        }
        
        // maxrかつmaxcの(r, c)について全探索
        // (r, c)がsetpになければ++する
        boolean ok = false;
        for (Integer r : setr) {
            for (Integer c : setc) {
                String p = r + " " + c;
                if (!setp.contains(p)) {
                    ok = true;
                    break;
                }
            }
        }
        
        ans = maxr + maxc - 1;
        if (ok) ans++;
        System.out.println(ans);
    }
}


Measured memory_bytes: 144316
A, B, K = map(int, input().split())

mini = min(A, B)
a = range(1, mini+1)
a = {i for i in a for j in a[::-1] if i * j == mini}

maxi = max(A, B)
b = range(1, maxi+1)
b = {i for i in b for j in b[::-1] if i * j == maxi}

print(sorted(a & b, reverse=True)[K-1])

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

const int N = 10000;

class Solver {
    private:
        bool is_prime_[N + 1];
    public:
        Solver() {
            for (int i = 0; i <= N; ++i) {
                is_prime_[i] = true;
            }
            for (int i = 2; i <= N; ++i) {
                if (!is_prime_[i]) {
                    continue;
                }
                for (int j = 2; j * i <= N; ++j) {
                    is_prime_[j * i] = false;
                }
            }
        }
        int solve(int n) {
            for (int i = n; true; --i) {
                if (is_prime_[i] && is_prime_[i - 2]) {
                    return i;
                }
            }
        }
};

int main() {
    Solver s;
    int n, x;
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        x = s.solve(n);
        cout << x - 2 << ' ' << x << endl;
    }
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 256