akhauriyash/Code-Regression huggingface dataset:
import copy
import itertools

def delete_H(num, C_rend):
  lenj = len(num)
  if lenj != 0:
    for count in range(lenj):
      C_rend[j[count]] = "r" * W
  return(C_rend)

def delete_W(num, C_rend):
  lenl = len(num)
  if lenl != 0:
    for count in range(lenl):
      for i in range(H):
        c_h_list = list(C_rend[i])
        c_h_list[l[count]] = "r"
        C_rend[i] = "".join(c_h_list)
  return(C_rend)

H, W, K = map(int, input().split())
C = []
for i in range(H):
  add_H = map(str, input().split())
  C += add_H

counter = 0
C_orig = copy.deepcopy(C)  

for i in range(H + 1):
  for j in itertools.combinations(range(H), i):
    for k in range(W + 1):
      for l in itertools.combinations(range(W), k):
        C = copy.deepcopy(C_orig)
        modified_C_a = delete_H(j, C)
        modified_C_b = delete_W(l, modified_C_a)
        result = "".join(modified_C_b)
        
        if result.count("#") == K:
          counter += 1
        
print(counter)



Measured memory_bytes: 71360
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;

int main(){
  ;;
    string s;
    cin >> s;
    ;
    cout << ("ABC" + s) << endl;;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fo(i,n) for(i=0;i<n;i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);


int main()
{
	  IOS
	  ll n,m,i,j,t,k,l,r,c;
	  cin>>n>>m;
	  ll arr[n+1];
	  map<ll,int>ma;
	  for(i=0;i<n;i++){cin>>arr[i];ma[arr[i]]++;}
	  	vector<pair<int,ll> >vec;
      for(i=0;i<m;i++)
      {
           cin>>l>>r;
           vec.push_back({l,r});
      }
      map<ll,int>::iterator it,it1,it2;
  
  
      for(i=0;i<m;i++)
      {
      	//cout<<"h"<<endl;
      	
      	c=vec[i].first;
      	
      	
       vector<map<ll,int>::iterator >temp;
       
          for(it=ma.begin();it!=ma.end();it++)
          {
          	if(c==0)break;
          	    if(it->first>=vec[i].second)break;
          	    if(it->second>=c)
          	    {
                      it->second-=c;
                      c=0;
          	    }
          	    else{
          	    	c-=it->second;
                    it->second=0;
          	    }
          	    if(it->second==0)temp.push_back(it);

          }
         
           for(j=0;j<temp.size();j++)
           {
           	ma.erase(temp[j]);
           }
           
          if(vec[i].first-c>0)ma[vec[i].second]+=vec[i].first-c;
          
      }
      ll sum=0;
      for(it=ma.begin();it!=ma.end();it++)sum+=(it->first*it->second);
      cout<<sum;
  
}

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

using namespace std;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long
#define lson node<<1
#define rson (node<<1)+1

const int maxn=2e6+10;
const int mod=998244353;
const double pi=-acos(-1);

int v[maxn];
struct Prime
{
    int prime[maxn];
    int s;
    Prime()
    {
        for(int i=2; i<maxn; i++)
        {
            if(!v[i])
            {
                prime[s++]=i;
                for(int j=2; j*i<maxn; j++)
                    v[i*j]=1;
            }
        }
    }
};

int main()
{
    long double a,b;
    cin>>a>>b;
    ll ans=a*b*100;
    cout<<ans/100<<endl;
    return 0;
}


Measured memory_bytes: 3728
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
X=list(zip(A,B))
X.sort(lambda x:x[1])

C=[(x[0],i) for i,x in enumerate(X)]
C.sort()
perm=[C[i][1] for i in range(n)]

A.sort()
B.sort()

if(any(A[i]>B[i] for i in range(n))):
    print("No")
    exit()

if(any(A[i+1]<=B[i] for i in range(n-1))):
    print("Yes")
    exit()

p=0
cnt=0
while(True):
    cnt+=1
    p=perm[p]
    if(p==0): break
print("Yes" if(cnt<n) else "No")
    


Measured memory_bytes: 90984
import java.util.Scanner;

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

	private void start() {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
			
		}
	}
}

Measured memory_bytes: 17156
n = gets.chomp.to_i
hs = gets.chomp.split(" ").map(&:to_i);

hs.reverse!
result = Array.new(n, 0)

hs.each_with_index do |h, i|
  next if i == 0 
  result [i] = result[i-1] + 1 if hs[i] >= hs[i-1]
end

puts result.max

Measured memory_bytes: 10500
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int ans = 0;
            int t = a;
            boolean c = true;

            while (true) {
                t = t - b;
                ans++;
                if (t <= 0) {
                    out.println(ans);
                    return;
                }
            }

        }

    }
}



Measured memory_bytes: 23124
a,b,k=map(int, input().split())
ans = a-k
if ans >= 0:
    box=[ans,b]
    print(*box)
else:
  if a+b-k >0:
    box=[0,a+b-k]
    print(*box)
  else:
    box=[0,0]
    print(*box)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int i, a = 0, b = 0;
    for( i = 0; i < s.size(); i++)
        if(s[i]=='0')
            a++;
        else
            b++;
    cout << min(a, b) * 2<<endl;

    return 0;
}


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

pair<unordered_map<long long, int>, vector<long long>> compress(const vector<long long> &src){
    vector<long long> unzip = src;
    sort(begin(unzip), end(unzip));
    unzip.erase(unique(begin(unzip), end(unzip)), end(unzip));
    unordered_map<long long, int> zip;
    for (int i = 0; i < unzip.size(); ++i) zip[unzip[i]] = i;
    return make_pair(zip, unzip);
}
struct Rectangle{
    long long x1;
    long long y1;
    long long x2;
    long long y2;
    Rectangle(long long _x1 = 0, long long _y1 = 0, long long _x2 = 0, long long _y2 = 0): x1(_x1), y1(_y1), x2(_x2), y2(_y2){}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<Rectangle> rects(N);
    vector<long long> xs;
    vector<long long> ys;
    xs.reserve(2 * N);
    ys.reserve(2 * N);
    for (auto & rec : rects) {
        cin >> rec.x1 >> rec.y1 >> rec.x2 >> rec.y2;
        xs.push_back(rec.x1);
        xs.push_back(rec.x2);
        ys.push_back(rec.y1);
        ys.push_back(rec.y2);
    }
    unordered_map<long long, int> zipx, zipy;
    vector<long long> unzipx, unzipy;
    tie(zipx, unzipx) = compress(xs);
    tie(zipy, unzipy) = compress(ys);
    int nx = unzipx.size();
    int ny = unzipy.size();
    vector<vector<long long>> area(nx, vector<long long>(ny, 0));
    for (int i = 0; i < nx - 1; ++i){
        for (int j = 0; j < ny - 1; ++j){
            area[i][j] = (unzipx[i + 1] - unzipx[i]) * (unzipy[j + 1] - unzipy[j]);
        }
    }
    vector<vector<int>> imos(nx, vector<int>(ny, 0));
    for (auto & rec : rects){
        int x1 = zipx[rec.x1];
        int x2 = zipx[rec.x2];
        int y1 = zipy[rec.y1];
        int y2 = zipy[rec.y2];
        ++imos[x1][y1];
        --imos[x1][y2];
        --imos[x2][y1];
        ++imos[x2][y2];
    }
    for (int i = 0; i < nx; ++i) for (int j = 1; j < ny; ++j) imos[i][j] += imos[i][j - 1];
    for (int j = 0; j < ny; ++j) for (int i = 1; i < nx; ++i) imos[i][j] += imos[i - 1][j];
    long long ans = 0;
    for (int i = 0; i < nx - 1; ++i) for (int j = 0; j < ny - 1; ++j) if (imos[i][j] > 0) ans += area[i][j];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 191288
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

#define ketasitei setprecision(15) //15桁表示



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

	ll n;
	cin >> n;
	vector<ll> t(n);
	vector<string> s(n);
	rep(i, n)
	{
		cin >> s[i] >> t[i];
	}
	string x;
	cin >> x;
	bool sl = false;
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
        		if (sl)
		{
			ans += t[i];
		}
		if (s[i] == x)
		{
			sl = true;
		}

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        x: isize, n: usize,
        pv: [isize; n]
    };

    let set = pv.into_iter().collect::<HashSet<_>>();
    let mut min = 101_isize;
    let mut res = 101_isize;
    for i in -1..=101 {
        if !set.contains(&i) {
            let x = (i - x).abs();
            if x < min {
                min = x;
                res = i;
            }
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2252
#include<stdio.h>

int main() {
	int i, j, k, n, t, m, h, w, r, g;
	int a, b;
//	char s[15];
	int f = 0;

	scanf("%d %d", &a, &b);

	if (a <= 5) {
		f = 0;
	}
	else if (a <= 12) {
		f = b / 2;
	}
	else {
		f = b;
	}

	printf("%d",f);


	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll n,a,b,ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	a=n/500;
	n-=a*500;
	b=n/5;
	ans=a*1000+b*5;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

ans = 0
for b in reversed(range(1, n+1)):
    if b == k:
        break
    y_cnt = b-k
    p, q = divmod(n, b)
    ans += y_cnt*p
    if k <= q:
        ans += q-max(k-1, 0)
print(ans)

Measured memory_bytes: 3060
class UnionFind():
   def __init__(self, n):
       self.n = n
       self.parents = [-1] * n

   def find(self, x):
       if self.parents[x] < 0:
           return x
       else:
           self.parents[x] = self.find(self.parents[x])
           return self.parents[x]

   def union(self, x, y):
       x = self.find(x)
       y = self.find(y)

       if x == y:
           return

       if self.parents[x] > self.parents[y]:
           x, y = y, x

       self.parents[x] += self.parents[y]
       self.parents[y] = x

   def size(self, x):
       return -self.parents[self.find(x)]

   def same(self, x, y):
       return self.find(x) == self.find(y)

   def members(self, x):
       root = self.find(x)
       return [i for i in range(self.n) if self.find(i) == root]

   def roots(self):
       return [i for i, x in enumerate(self.parents) if x < 0]

   def group_count(self):
       return len(self.roots())

   def all_group_members(self):
       return {r: self.members(r) for r in self.roots()}

   def __str__(self):
       return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m = map(int,input().split())
pl = list(map(int,input().split()))
uf = UnionFind(n)
for _ in range(m):
   x,y = map(int,input().split())
   uf.union(x-1,y-1)
ans = 0
for idx,p in enumerate(pl):
   ans += uf.same(p-1,idx)
print(ans)

Measured memory_bytes: 88300
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5;
const ll INF=1e18;
int N;
ll a[MAX_N*3];
ll sm[2][MAX_N+1];
int main(){
	cin>>N;
	REP(i,N*3){
		cin>>a[i];
	}
	priority_queue<ll,vector<ll>,greater<ll> > pque1;
	REP(i,N){
		sm[0][0]+=a[i];
		pque1.push(a[i]);
	}
	REP(i,N){
		sm[0][1+i]=sm[0][i];
		sm[0][1+i]+=a[N+i];
		pque1.push(a[N+i]);
		sm[0][1+i]-=pque1.top();
		pque1.pop();
	}
	priority_queue<ll> pque2;
	REP(i,N){
		sm[1][N]+=a[2*N+i];
		pque2.push(a[N*2+i]);
	}
	REP(i,N){
		sm[1][N-1-i]=sm[1][N-i];
		sm[1][N-1-i]+=a[2*N-i-1];
		pque2.push(a[N*2-i-1]);
		sm[1][N-1-i]-=pque2.top();
		pque2.pop();
	}
	ll ans=-INF;
	REP(i,N+1){
		ans=max(ans,sm[0][i]-sm[1][i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5876
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

const ll INF = (1LL<<32);
vector<vector<ll> > d;  // グラフの距離を格納した2次元配列（隣接行列）
// d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）

void warshall_floyd(int n){  // nは頂点数
  for(int i = 0; i < n; i++){  // 経由する頂点
    for(int j = 0; j < n; j++){  // 開始頂点
      if(d[j][i] == INF) continue;
      for(int k = 0; k < n; k++){  // 終端
        if(d[i][k] == INF) continue;
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  vector<vector<ll> > G(N, vector<ll>(N, INF));
  d.assign(N, vector<ll>(N, INF));
  REP(i, M){
    ll a, b, c; cin >> a >> b >> c; a--; b--;
    G[a][b] = c;
    G[b][a] = c;
  }
  d = G;
  warshall_floyd(N);
  int ans = 0;
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      if(G[i][j] != INF && G[i][j] > d[i][j]) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Map.Entry;
import java.util.*;
 
import org.w3c.dom.css.Counter;
 
public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
     final int N = Integer.parseInt(s.next());
     final int K = Integer.parseInt(s.next());
     HashSet<String> hashSet = new HashSet<String>();

     for(int i=0; i< K;i++){
        int di = Integer.parseInt(s.next());
        String blank = s.nextLine();
        String huge = s.nextLine();

        String[] hage = huge.split(" ",0);
        int hageN= hage.length;
        for (int num =0;num<hageN;num++){
            if(!hashSet.contains(hage[num])){
                hashSet.add(hage[num]);
            }
        }

     }
     s.close();

     System.out.println(N-hashSet.size());
}
}

Measured memory_bytes: 37452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int MAX = 3e5+3;
const int INF = 1e9;

int a[MAX];
string s;

int main(){

  cin >> s;
  int cnt = 0;
  REP(i,s.size()-1){
    if(s[i+1] != s[i]){
      cnt++;
      //i++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 512
n = int(input())
a = []
cnt = 0
for i in range(n):
  a.append(int(input()))
stack = -1
for i in range(n):
  if i+1 - stack <= 1 and a[i] > 0:
    cnt += 1
    a[i] -= 1
    stack = -1
  cnt += a[i] // 2
  if a[i] % 2 == 1:
    stack = i+1
  else:
    stack = -1
print(cnt)

Measured memory_bytes: 7072
//HovalaHaq!
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
	int x, k, d; cin >> x >> k >> d;
	if(k & 1) {
		x = min(abs(x - d), abs(x + d));
		k--;
	} else x = abs(x);
	k /= 2;
	d *= 2;
	if(k < x / d) return cout << x - k * d, 0;
	x -= d * (x / d);
	cout << min(x, d - x);
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
int32_t main()
{

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int g = (c * d) / __gcd(c, d);
	//cout << g << endl;
	int factc = (b / c) - ((a - 1) / c);
	int factd = (b / d) - ((a - 1) / d);
	int factcom = ((b / (g)) - ((a - 1) / (g)));
	//cout << factc << factd << factcom << endl;
	//factc-=factcom;
	//factd-=factcom;
	cout << (b - a + 1 ) - (factc + factd - factcom);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
     int n;
     cin >> n;
      vector<string> z;
      for (int i = 0; i < n; i++){
        if(i == 0){
          z.push_back("a");
        continue;}
        
        int p;
        p = z.size();
          for(int j = 0; j < p; j++){
            string g;
            string h;
            g = z.at(j);
            h = g;
            sort(g.begin(), g.end());
            char c;
            c = g.at(i-1);
           z.at(j).push_back('a');
           string aa =  h;
            string ab =  h;
            string ac =  h;
            string ad =  h;
            string ae =  h;
            string af =  h;
            string ag =  h;
            string ah =  h;
            string ai =  h;
            if(i == 0){break;}
            aa.push_back('b');
            z.push_back(aa);
            if(c == 'a'){continue;}
            ab.push_back('c');
            z.push_back(ab);
            if(c == 'b'){continue;}
            ac.push_back('d');
            z.push_back(ac);
            if(c == 'c'){continue;}
            ad.push_back('e');
            z.push_back(ad);
            if(c == 'd'){continue;}
            ae.push_back('f');
            z.push_back(ae);
            if(c == 'e'){continue;}
            af.push_back('g');
            z.push_back(af);
            if(c == 'f'){continue;}
            ag.push_back('h');
            z.push_back(ag);
            if(c == 'g'){continue;}
            ah.push_back('i');
            z.push_back(ah);
            if(c == 'h'){continue;}
            ai.push_back('j');
            z.push_back(ai);
          }
      }

sort(z.begin(), z.end());
      int ddd;
     ddd = z.size();
       for(int i=0;i<ddd;++i){
    cout << z.at(i) << endl;
  }
            
      
      
    }
  

Measured memory_bytes: 7924
#include <iostream>
#include <cstdlib>
#include <iomanip>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0);
const int M = 1e9+7;
using namespace std;
bool connected[25][25];
ll dp[1<<22];


int main(){
    AC
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin>>connected[i][j];
        }
    }
    
    dp[0] = 1;
    for(int i=1; i<(1<<n); i++){
        int v = __builtin_popcount(i)-1;
        for(int j=0; j<n; j++){
            if(connected[v][j] && ((1<<j)&i))
                dp[i]+=(dp[i-(1<<j)]%M);
        }
    }

    cout<<dp[(1<<n)-1]%M<<endl;

}

Measured memory_bytes: 20008
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>
#include <list>
#include <stack>

using namespace std;


typedef int INT;
#define int long long

INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int h, k;
	cin >> h >> k;
	vector <string> st(h);
	for (int i = 0; i < h; i++)
		cin >> st[i];

	vector <int> pr(h);
	for (int i = 0; i < h; i++)
	{
		pr[i] = i / 2 + 1;
	}
	int w = pr[h - 1];
	do
	{
		vector <bool> wer(w + 1);
		vector <int> sr(h);
		for (int i = 0; i < h; i++)
		{
			if (!wer[pr[i]])
				sr[pr[i] - 1] = i;
			else
				sr[h - pr[i]] = i;
			wer[pr[i]] = true;
		}
		vector <bool> norm(k);
		bool flag = false;
		if (k % 2 == 1)
			flag = true;
		bool teer = true;
		for (int i = 0; i < k; i++)
		{
			if (!norm[i])
			{
				bool y = false;
				for (int j = i + 1; j < k; j++)
				{
					if (!norm[j])
					{
						bool f = true;
						for (int g = 0; g < h; g++)
						{
							if (st[sr[g]][i] != st[sr[h - g - 1]][j])
							{
								f = false;
								break;
							}
						}
						if (f)
						{
							y = true;
							norm[i] = true;
							norm[j] = true;
							break;
						}
					}
				}
				if (!y && flag)
				{
					bool fl = true;
					for (int j = 0; j < h; j++)
						if (st[sr[j]][i] != st[sr[h - j - 1]][i])
							fl = false;
					if (fl)
					{
						y = true;
						norm[i] = true;
						flag = false;
					}
				}
				if (!y)
				{
					teer = false;
					break;
				}
			}
		}
		if (teer)
		{
			cout << "YES";
			return 0;
		}
	} while (next_permutation(pr.begin(), pr.end()));

	cout << "NO";


	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>

typedef long long ll;

ll st(ll n)
{
	ll ret=(ll)std::sqrt(n)-1;
	if(ret<0)ret=0;
	while((ret+1)*(ret+1)<=n)ret++;
	return ret;
}

void solve(int a,int b)
{
	if(a==1 && b==1)
	{
		printf("0\n");
		return;
	}

	if(a>b)std::swap(a,b);

	ll n=(ll)a*b-1,ans;
	ll lim=st(n);

	ans=lim*2;

	if(lim==n/lim)ans--;

	printf("%lld\n",ans-(a<=lim));
}

int main()
{
	int T,a,b;

	for(scanf("%d",&T);T--;)
		scanf("%d%d",&a,&b),solve(a,b);

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	set<int>SA;
	rep(i, N) {
		SA.insert(A[i]);
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		int k;
		cin >> k;
		if (SA.count(k)) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
}




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

string s;
int x, y;

int d[8000];
vector<int> vx;
vector<int> vy;

int main() {
    ios::sync_with_stdio(false);

    cin >> s;
    cin >> x >> y;
    
    //d[i] is length of F ith block
    //d[1] = value
    /*
    int index= 1;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'F') {
            //printf("F i=%d\n", i);
            int cnt = 0;
            for (int j = i; j < s.size() && s[j] != 'T'; j++)
                if (s[j] == 'F')
                    cnt++;
            d[index++] = cnt;
            i+= cnt;
        }
    }
    */
    
    int countF, countT;
    countF = countT = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'F')
            countF++;
        else {//meet T
            if (countT % 2 == 0) {//even is x postion move
                vx.push_back(countF);
            }
            else
                vy.push_back(countF);
            countT++;
            countF = 0;
        }
    }
    
    if (countF > 0) {
        if (countT % 2 == 0)
            vx.push_back(countF);
        else
            vy.push_back(countF);
    }
    
    bool dpx[vx.size()+1][16001];
    bool dpy[vy.size()+1][16001];
    memset(dpx, 0, sizeof(dpx));
    memset(dpy, 0, sizeof(dpy));
    
    
    int t = 0;
    if (s[0] == 'T')
        dpx[0][8000] = true;//8000 is center
    else {
        dpx[1][8000+vx[0]] = true;
        t++;
    }
    
    for (int i = 0 + t; i < vx.size(); i++) {
        for (int j = 0; j < 16001; j++) {
            if(!dpx[i][j])
                continue;
            if (j - vx[i] >=0) {
                dpx[i+1][j-vx[i]] |= dpx[i][j];
            }
            if (j + vx[i] < 16001) {
                dpx[i+1][j+vx[i]] |= dpx[i][j];
            }
        }
    }
    dpy[0][8000] = true;
    
    for (int i = 0 ; i < vy.size(); i++) {
        for (int j = 0; j < 16001; j++) {
            if(!dpy[i][j])
                continue;
            if (j - vy[i] >=0)
                dpy[i+1][j-vy[i]] |= dpy[i][j];
            
            if (j + vy[i] < 16001)
                dpy[i+1][j+vy[i]] |= dpy[i][j];
        }
    }
    

    if (dpx[vx.size()][x+8000] && dpy[vy.size()][y+8000])
        cout << "Yes\n";
    else
        cout << "No\n";
    
    
    return 0;
}


Measured memory_bytes: 124288
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
priority_queue<LL,vector<LL>,greater<LL> >p;
struct node{
    LL b,c;
}a[Max];
bool cmp(node a,node b){
    return a.c>b.c;
}
int main()
{
    int n,m;
    LL t;
    LL b,c;
    scanf("%d%d",&n,&m);
    LL ans=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&t);
        ans+=t;
        p.push(t);
    }
    for(int i=0;i<m;i++)
        scanf("%lld%lld",&a[i].b,&a[i].c);
    sort(a,a+m,cmp);
    for(int i=0;i<m;i++){
        b=a[i].b,c=a[i].c;
        for(int i=0;i<b;i++){
            LL t=p.top();
            if(t<c){
                ans-=t;
                ans+=c;
                p.pop();
                p.push(c);
            }
            else{
                break;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

using ll = long long;

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

int main() {
  string s;
  cin>>s;
  int l = s.size();
  bool bal = false;
  int anss=-2,anse=-2;
  for(int i = 0; i < l-1; i++){
    if(s[i]==s[i+1]) {
      bal = true;
      anss = i;
      anse=i+1;
    }
  }
  if(!bal){
    for(int i = 0; i < l-2; i+=2){
      if(s[i]==s[i+2]){
        bal=true;
        anss=i;
        anse=i+2;
      }
    }
    if(!bal){
      for(int i = 1; i < l-2;i+=2){
        if(s[i]==s[i+2]){
          bal=true;
          anss=i;
          anse=i+2;
        }
      }
    }
  }
  cout<<anss+1<<" "<<anse+1<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  lint l,r;cin>>l>>r;
  if(r-l>=2019){
      cout<<0<<"\n";
      return 0;
  }
  l%=2019;r%=2019;
  lint res=inf;
  if(r<=l){
      cout<<0<<"\n";
      return 0;
  }
  for(int i=l;i<=r;++i){
      for(int j=i+1;j<=r;++j){
          res=min(res,(i*j)%2019);
      }
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue

#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 105
int n;
vpii e;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    FOR(i, 1, n-1){
        FOR(j, i+1, n){
            if(i+j == (n/2)*2+1) continue;
            e.pb(mp(i, j));
        }
    }

    cout << e.size() << "\n";
    F0R(i, e.size()){
        cout << e[i].f << " " << e[i].s << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    x = int(input())
    ma_ = 1
    for i in range(1,x):
        for j in range(2,x):
            if i**j <= x:
                ma_ = max(ma_,i**j)
            else:
                break
        # break で　for j を消してるだけや
    print(ma_)
if __name__ == '__main__':
  main()


Measured memory_bytes: 5148
import math
q=int(input())
num=[0]*(10**5+5)
ans=[0]*(10**5+5)
num[2]=1
for i in range(3,10**5+2,2):
    yn=0
    for j in range(2,int(math.sqrt(i))+1):
        if i%j==0:
            yn=1
            break
    if yn==0:
        num[i]=1
        if num[(i+1)//2]==1:
            ans[i]=1
for i in range(1,len(num)):
    ans[i]=ans[i-1]+ans[i]
for i in range(q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l-1])


Measured memory_bytes: 12736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var k = Input().ToInt();
		var a = k[0];
		var b = k[1];
		var m = k[2];
		
		int minA = -1, minB = -1;
		
		int min = 999999;
		var va = new int[a];
		k = Input().ToInt();
		for(int i = 0; i < a; i++)
		{
			va[i] = k[i];
			if(va[i] < min)
			{
				min = va[i];
				minA = i;
			}
		}
		
		min = 999999;
		var vb = new int[b];
		k = Input().ToInt();
		for(int i = 0; i < b; i++)
		{
			vb[i] = k[i];
			if(vb[i] < min)
			{
				min = vb[i];
				minB = i;
			}
		}
		
		long minWa = va[minA] + vb[minB];
		
		for(int i = 0; i < m; i++)
		{
			k = Input().ToInt();
			minWa = Math.Min(minWa, va[k[0]-1] + vb[k[1]-1]-k[2]);
		}
		Console.WriteLine(minWa);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 35676
import sys
input = sys.stdin.readline

def isprime(x):
    if x <= 1:
        return False
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            return False
    return True


A = [0] * 10**5
for i in range(10**5):
    if isprime(i):
        A[i] = 1

B = [0] * 10**5
for i in range(10**5):
    if A[i] and A[(i + 1) // 2]:
        B[i] = 1

for i in range(1, 10**5):
    B[i] += B[i - 1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(B[r] - B[l - 1])


Measured memory_bytes: 9360
using System;

namespace ConsoleApp3
{
    internal class Class2
    {
        private static void Main(string[] args)
        {
            var x = Console.ReadLine();

            if (x == "0")
            {
                Console.WriteLine("1");
            }
            else if (x == "1")
            {
                Console.WriteLine("0");
            }
        }
    }
}

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

int s_length(const char s[]){
   int len = 0;

   while (s[len])
      len++;
   return len;
}

int main() {
   int n, i;
   char s[100], p[100], rings[200];
   char *ret;

   scanf("%s", s);
   scanf("%s", p);

   n = s_length(s);

   for (i = 0; i < n; i++) {
      rings[i] = s[i];
      rings[i + n] = s[i];
   }
   
   if ((ret = strstr(rings, p)) != NULL) {
      printf("Yes\n");
   } else {
      printf("No\n");
   }

   return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;cin>>n;

    ll sum=(n*(n+1))/2;

    ll nos1=  n/3;
    ll p=(nos1*(nos1+1))/2;
    p=3*p;
    sum-=p;
    ll nos2=n/5;
    ll q =(nos2*(nos2+1))/2;
    q=5*q;
    sum-=q;
    ll nos3=n/15;
    ll r =(nos3*(nos3+1))/2;
    r=r*15;
    sum+=r;

    cout<<sum;

    return 0;
}


Measured memory_bytes: 3608
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
int main(){
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2==1)
    cout<<(b-a);
  else
    cout<<(a-b);
  system("pause");
  return 0;
} 

Measured memory_bytes: 504
#include <stdio.h>

int gcd(int , int);

int main(){

  int x, y, tmp, ans;

  scanf("%d %d",&x,&y);

  if(y>x){
    tmp = x;
    x = y;
    y = tmp;
  }
  if(x == y)ans = x;

  else ans = gcd(x, y);

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

  return 0;
}
int gcd(int x, int y){

  if(x%y == 0)return y;

  else gcd(y, x%y);
}

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

int n, A[50];

int solve(int i, int m){
    if(m == 0) return 1;
    if(i >= n) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main(){
    int q, M;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> M;
        cout << (solve(0, M) ? "yes" : "no") << endl;
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int A,B,C;
	cin>>A>>B>>C;
	vec(D)
	pb(D,A)pb(D,B)pb(D,C)
	sorts(D)
	if(D.at(0)==5&&D.at(1)==5&&D.at(2)==7){
		ce("YES")
	}else{
		ce("NO")
	}
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int A, B; std::cin >> A >> B;

  if ((A + B) % 2 == 0) std::cout << (A + B)/2 << std::endl;
  else std::cout << "IMPOSSIBLE" << std::endl;
}


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

int main() {
  string s;
  cin >> s;
  while(s.size()!=0){
    if(s.find("eraser")==string::npos){
      break;
    }
    else{
      int k=s.find("eraser");
      s.erase(k,6);
    }
  }
  while(s.size()!=0){
    if(s.find("erase")==string::npos){
      break;
    }
    else{
      int k=s.find("erase");
      s.erase(k,5);
    }
  }
  while(s.size()!=0){
    if(s.find("dreamer")==string::npos){
      break;
    }
    else{
      int k=s.find("dreamer");
      s.erase(k,7);
    }
  }
  while(s.size()!=0){
    if(s.find("dream")==string::npos){
      break;
    }
    else{
      int k=s.find("dream");
      s.erase(k,5);
    }
  }
  if(s.size()==0)
  cout << "YES" << endl;
  else
  cout << "NO" << endl;
}



Measured memory_bytes: 3748
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define F(i, n) for(int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 200*1000+47;

LL A[MAX];
int n;

int gcd(int a, int b)
{
    if (!b)return a;
    return gcd(b, a%b);
}

bool win()
{
    int e = 0, o = 0;
    FOR(i, 0, n)
        if (A[i] & 1)o++;
        else e++;
    if (e & 1)return 1;
    if (o > 1)return 0;
    if (n == 1)return 0;
    
    FOR(i, 0, n)
    {
        if ((A[i] & 1) == 0)continue;
        if (A[i] == 1)return 0;
        A[i]--;
    }
    int g = 0;
    FOR(i, 0, n)g = gcd(g, A[i]);
    FOR(i, 0, n)A[i] /= g;
    return !win();
    
}

int main()
{
    scanf("%d", &n);
    int a = 0, b = 0;
    FOR(i, 0, n)
        scanf("%d", A + i);
    if (win())
        printf("First");
    else
        printf("Second");
    
    return 0;
}











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

uint64_t limit;
uint64_t ans;

void dfs(uint64_t n, uint64_t m)
{
  if (n > limit) return;
  if (m == 7) ans++;
  dfs(n * 10 + 3, m | 1);
  dfs(n * 10 + 5, m | 2);
  dfs(n * 10 + 7, m | 4);
}

int main()
{
  cin >> limit;
  dfs(0, 0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int N;
vector<int> L;
 
int main(void) {
	cin >> N;
	L.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> L[i];
 
	int ans = 0;
	for (int i = 0; i < N - 2; ++i) {
		for (int j = i + 1; j < N - 1; ++j) {
			if (L[j] == L[i])
				continue;
			for (int k = j + 1; k < N; ++k) {
				if (L[k] == L[i] || L[k] == L[j])
					continue;
				int D[3] = { L[i], L[j], L[k] };
				sort(D, D + 3);
				if (D[0] + D[1] > D[2])
					++ans;
			}
		}
	}
 
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(void){
  int a,b,t;
  scanf("%d %d %d",&a,&b,&t);
  int s=1,k=0;
  
  for(int i=0;i<t+0.5;i++){
    if(i==s*a){
      s++;
      k+=b;
    }
  }
  printf("%d",k);
return 0;
}
      


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

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

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  var(i64, a, b, c, k);
  outl(k % 2 ? b - a : a - b);

  return 0;
}


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

using namespace std;

vector<int> a(100001, 0);


int main(void){
	int n, k;

	cin >> n >> k;

	

	int id;

	for (int i = 1; i < n + 1; i++){
		cin >> a[i];
		if (a[i] = 1)
			id = i;
	}


	int m = 1000000;
	for (int i = 1; i < k + 1; i++){
		if (n - id - k + i >= 0 && id - i >= 0)
		m = min(m, (n - id - k + i + k - 2)/(k - 1) + (id - i + k - 2)/(k - 1) + 1);
	}

	cout << m << endl;
	
	

}


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

int main() {

  int N;
  cin>>N;

  vector<int> x,y;
  for(int i=0; i<N; i++){
    int n,m;
    cin>>n>>m;
    x.push_back(n);
    y.push_back(m);
  }

  int a=0;

  for(int i=0; i<N;i++){
    if(x.at(i)==y.at(i)){
    a++;
    if(a==3){
      cout<<"Yes"<<endl;
      break;
    }

    }
    else a=0;

  }
  if(a!=3)
  cout<<"No"<<endl;

}

Measured memory_bytes: 3624
// https://atcoder.jp/contests/abc082/tasks/arc087_a
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int n;cin>>n;
    unordered_map<int,int> mp;
    for(int i=0;i<n;i++) {
        int x;cin>>x;
        mp[x]++;
    }
    ll ans=0;
    for(auto &i : mp) {
        if(i.first < i.second)
            ans += i.second - i.first;
        else if(i.first > i.second)
            ans += i.second;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 7152
#define MAX(a, b) (a>b)?a:b
#define MIN(a, b) (a<b)?a:b
#include <stdio.h>
int main() {
    int w, h, n, i, x1=0, x2=0, y1=0, y2=0; 
    scanf("%d %d %d", &w, &h, &n);
    x2 = w; y2 = h;
    for(i=0; i<n; i++) {
        int xi, yi, a;
        scanf("%d %d %d", &xi, &yi, &a);
        switch(a) {
            case 1:
                x1 = MAX(x1, xi); break;
            case 2:
                x2 = MIN(x2, xi); break;
            case 3:
                y1 = MAX(y1, yi); break;
            case 4:
                y2 = MIN(y2, yi); break;
        }
    }
    if (x2 > x1 && y2 > y1)
        printf("%d\n", (x2-x1)*(y2-y1));
    else
        puts("0");
}

Measured memory_bytes: 128
import sys
from functools import lru_cache

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

a, b = A[:2]
xor = 0
for x in A[2:]:
    xor ^= x

INF = 10**13

@lru_cache(None)
def F(a, b, xor):
    if (a & 1) ^ (b & 1) != (xor & 1):
        return INF
    if xor == 0:
        return INF if a < b else (a - b) // 2
    # 1の位を放置
    x = 2 * F(a // 2, b // 2, xor // 2)
    # 1の位を移動
    y = 2 * F((a - 1) // 2, (b + 1) // 2, xor // 2) + 1
    x = min(x, y)
    if x >= INF:
        x = INF
    return x

x = F(a, b, xor)
if x >= a:
    x = -1
print(x)

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

int main() {
	double n,m,ok=1,ans=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		ok/=2;
	}
	double bad=1;
	double test=1900*m+(n-m)*100; 
	for(double i=0;i<1000;i++){
		ans+=(i+1)*test*ok*bad;
		bad*=(1-ok);
	}
	ll ANS=ans+0.5;
	cout << ANS;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).bigin(), (c).end())

typedef long long ll;

int n;
string s[300][300];

bool check(int a, int b)
{
    string s_[300][300];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            s_[i][j] = s[(i + a) % n][(j + b) % n];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (s_[i][j] != s_[j][i])
                return false;
        }
    }

    return true;
}

int main()
{
    cin >> n;
    REP(i, n)
    {
        string tmp;
        cin >> tmp;
        REP(j, n)
        {
            s[i][j] = tmp[j];
        }
    }

    int ans = 0;
    for (int h = 0; h < n; h++)
        if (check(h, 0))
            ans += n;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7936