akhauriyash/Code-Regression huggingface dataset:
use std::io;


/// https://beta.atcoder.jp/contests/abc080/tasks/abc080_c
/// Shopping Street
/// 2^10 通りを全探索
fn main() {
    let n = read_one::<usize>();
    let mut fs = Vec::new();
    let mut ps = Vec::new();

    for _ in 0..n { fs.push(read::<isize>()); }
    for _ in 0..n { ps.push(read::<isize>()); }

    let mut ans = ::std::isize::MAX * -1;
    for i in 1..1 << 10 {
        let mut tmp = 0;
        for k in 0..n {
            let mut cnt = 0;
            for j in 0..10 {
                if (i & 1 << j) != 0 {
                    if fs[k][j] == 1 { cnt += 1; }
                }
            }
            tmp += ps[k][cnt];
        }
        if ans < tmp { ans = tmp; }
    }

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include <string.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
ll t=0,n,m;
ll y,z;
ll i,j,k,h,w;
struct hhh
{
    ll x,y;
    friend bool operator < (const hhh& n1, const hhh& n2)
    {
        if(n1. x != n2. x)
        return n1. x < n2. x;
        else
        {
             return n1.y < n2. y;
        }
    }
} p[1000005],p2[1000005];
set<hhh>ma;
ll a[10000005],x1[1000005],y1[1000005],x2[1000005],y2[1000005];
int main()
{
    ll j,ma1=-10000000000,ma2=-10000000000,k,d,flag=0,ans,t;

    ans=0;
    t=1;
    k=1;
    scanf("%lld %lld %lld",&h,&w,&m);
    for(i=1; i<=m; i++)
    {
        scanf("%lld %lld",&p[i].x,&p[i].y);
        ma.insert(p[i]);
        x1[p[i].x]++;
        y1[p[i].y]++;
    }
    // printf("*%lld\n",x1[1]);
    for(i=1; i<=h; i++)
    {
        ma1=max(ma1,x1[i]);
    }

    for(i=1; i<=w; i++)
    {
        ma2=max(ma2,y1[i]);
    }
    for(i=1; i<=h; i++)
    {
        if(ma1==x1[i])
        {
            x2[k++]=i;
        }
    }
    for(i=1; i<=w; i++)
    {
        if(ma2==y1[i])
        {
            y2[t++]=i;
        }
    }
    ans=ma1+ma2;
    ll o=1; flag=0;
    for(i=1; i<k; i++)
    {
        for(j=1; j<t; j++)
        {

            p2[o].x=x2[i];
            p2[o++].y=y2[j];

           // printf("**%lld %lld\n",p2[o-1].x,p2[o-1].y);
            if(ma.count(p2[o-1])==0)
            {
               // printf("****%lld %lld\n",p2[o-1].x,p2[o-1].y);
                flag=1;
                break;
            }
        }
        if(flag==1)break;
    }
    if(flag==0)
        ans--;
   // printf("%lld %lld\n",ma1,ma2);

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

    return 0;
}


Measured memory_bytes: 36580
#include <stdio.h>
#define N 100

int main(){
    int i, j, key, n;
    int A[N];
    
    scanf("%d", &n);
    for(i = 0;i < n;i++)scanf("%d", &A[i]);
    for(i = 0;i < n;i++){
        printf("%d", A[i]);
        if(i != n - 1)
            printf(" ");
    }
    printf("\n");
    
    for(j = 1;j < n;j++){
        key = A[j];
        i = j - 1;
        while(i >= 0 && A[i] > key){
            A[i+1] = A[i];
            i = i - 1;
        }
        A[i+1] = key;
        for(i = 0;i < n;i++){
            printf("%d", A[i]);
            if(i != n - 1)
                printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2060
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N, M;
        {int[] a = in.ii(); N = a[0]; M = a[1];}
        ArrayList<Integer>[] reward = new ArrayList[100000];
        for(int i = 0; i < N; i++){
            int[] tmp = in.ii();
            int A = tmp[0]-1;
            int B = tmp[1];
            if(reward[A] == null) reward[A] = new ArrayList<>();
            reward[A].add(B);
        }

        long ans = 0;
        PriorityQueue<Integer> q = new PriorityQueue<>((x, y) -> -x+y);
        for(int i = 0; i < M; i++){
            if(reward[i] != null){
                q.addAll(reward[i]);
            }
            Integer tmp = q.poll();
            ans += tmp == null ? 0 : tmp;
        }
        System.out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// typedef struct 
// {
//     ll h;
//     ll v;
// } box;


// int cmp_qwe(const void*a, const void*b){return ((box*)b)->a - ((box*)a)->a;}

// ll dp[3000][3000];
// box u[2000];

int main(){
  ll a, b, c, d;
  ll n, m;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

  // 高橋くんが死ぬまでの回数
  n = (a + d - 1) / d;
  m = (c + b - 1) / b;

  if (n >= m)
  {
      printf("Yes\n");
  }
  else
  {
      printf("No\n");
  }
  
  
  
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  bool f = false;
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    if(x%2==0) f |= (x%5!=0&&x%3!=0);
  }
  if(f) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;    
  return 0;
}


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

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

		List<Integer> k = new ArrayList<Integer>();
		for (int i=1; i<= Math.min(A, B); i++) {
			if ((A%i == 0) && (B%i == 0)) {
				k.add(i);
			}
		}

		Collections.sort(k, Collections.reverseOrder());

		System.out.println(k.get(K-1));
	}
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x; //xにボールのx座標を代入
    
    if (x > K - x) { //Bのほうが近かったら
      sum += (K-x) * 2;
    }
    else {
      sum += x * 2;
    }
  }
  cout << sum << endl;
}
  

Measured memory_bytes: 256
n=int(input())
#s=list(input().split())
#s,t=list(input().split())
#a=list(map(int,input().split()))
#k,x=map(int,input().split())
p=list(input().split())
q=list(input().split())
p=[int(i) for i in p]
q=[int(i) for i in q]
import itertools
import math
p_index,q_index=0,0
fulllist=list(itertools.permutations([i for i in range(1,n+1)]))
for i in range(math.factorial(n)):
    if p==list(fulllist[i]):
        p_index=i+1
    if q==list(fulllist[i]):
        q_index=i+1
print(abs(p_index-q_index))


Measured memory_bytes: 7972
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,M,Q;
string S[2020];

int main(){
  cin>>N>>M>>Q;
  for(int i=0;i<N;i++) cin>>S[i];

  int blue[N+1][M+1]={};
  for(int i=1;i<=N;i++){
      for(int j=1;j<=M;j++){
          blue[i][j]+=blue[i][j-1];
          if(S[i-1][j-1]=='1') blue[i][j]++;
      }
  }
  for(int j=1;j<=M;j++){
      for(int i=1;i<=N;i++){
          blue[i][j]+=blue[i-1][j];
      }
  }
  int vert[N+1][M+1]={};
  for(int j=1;j<=M;j++){
      for(int i=1;i<N;i++){
          vert[i+1][j]=vert[i][j];
          if(S[i-1][j-1]=='1'&&S[i][j-1]=='1') vert[i+1][j]++;
      }
  }
  for(int i=1;i<=N;i++){
      for(int j=1;j<=M;j++){
          vert[i][j]+=vert[i][j-1];
      }
  }
  int holi[N+1][M+1]={};
  for(int i=1;i<=N;i++){
      for(int j=1;j<M;j++){
          holi[i][j+1]+=holi[i][j];
          if(S[i-1][j-1]=='1'&&S[i-1][j]=='1') holi[i][j+1]++;
      }
  }
  for(int j=1;j<=M;j++){
      for(int i=1;i<=N;i++){
          holi[i][j]+=holi[i-1][j];
      }
  }

  vector<int> ans;
  for(int i=0;i<Q;i++){
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      
      int ver=blue[c][d]-blue[a-1][d]-blue[c][b-1]+blue[a-1][b-1];
      int edge=vert[c][d]-vert[a][d]-vert[c][b-1]+vert[a][b-1];
      edge=edge+holi[c][d]-holi[a-1][d]-holi[c][b]+holi[a-1][b];
      ans.push_back(ver-edge);
  }

  for(int i=0;i<ans.size();i++) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 53752
### main

loop do
  n, w, d = gets.split.map(&:to_i)
  break if (n | w | d) == 0

  cards = [[w, d]]

  n.times do
    pi, si = gets.split.map(&:to_i)
    pi -= 1

    wi, di = cards[pi]
    cards.delete_at(pi)

    si %= wi + di

    if si < wi
      w0 = si
      w1 = wi - w0
      if w0 < w1
        cards += [[w0, di], [w1, di]]
      else
        cards += [[w1, di], [w0, di]]
      end
    else
      d0 = di - (si - wi)
      d1 = di - d0
      if d0 < d1
        cards += [[wi, d0], [wi, d1]]
      else
        cards += [[wi, d1], [wi, d0]]
      end
    end
  end

  puts cards.map{|wi, di| wi * di}.sort.join(' ')
end

Measured memory_bytes: 6156
grid = list()
for a in range(3):
    a, b, c = map(int, input().split())
    grid.append([a, b, c])

ans = 'No'

for a1 in range(0, 101):
    for a2 in range(0, 101):
        b1 = grid[0][0] - a1
        b2 = grid[1][1] - a2
        a3 = grid[2][1] - b2
        b3 = grid[2][2] - a3

        a_list = [a1, a2, a3]
        b_list = [b1, b2, b3]

        count = 0
        for x in range(3):
            for y in range(3):
                if grid[x][y] == a_list[x] + b_list[y]:
                    count += 1
        if count == 9:
            ans = 'Yes'
            break

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
#define ll long long
const ll MOD=1e9+7;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> alp(26,1);
    rep(i,0,n)alp[s[i]-'a']++;
    ll ans=1;
    rep(i,0,26){
        ans*=alp[i];
        ans%=MOD;
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    string a;
    cin>>a;
    if(a== "SUN")
        cout<<"7"<<endl;
    if(a== "MON")
        cout<<"6"<<endl;
    if(a== "TUE")
        cout<<"5"<<endl;
    if(a== "WED")
        cout<<"4"<<endl;
    if(a== "THU")
        cout<<"3"<<endl;
    if(a== "FRI")
        cout<<"2"<<endl;
    if(a== "SAT")
        cout<<"1"<<endl;
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n ; 
  cin >> n ;
  
  vector<ll>a(n);
  vector<ll>b(n);
  rep(i,n){
    cin>>a[i];
    cin>>b[i];
  }
  
  map<ll,map<ll,ll>> m;
  
  ll ans=0;
  
  rep(i,n)
    rep(j,n)
      if(i!=j) m[a[i]-a[j]][b[i]-b[j]]++, ans=max(ans,m[a[i]-a[j]][b[i]-b[j]]);
  
  cout<<n-ans<<endl;
  
}



Measured memory_bytes: 640
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		String[] ar = new String[n];
		for (int i=0; i<n; i++) {
			ar[i] = sc.next();
		}
		String[] ar2 = new String[n];
		for (int i=0; i<n; i++) {
			ar2[i] = ar[i];
		}
		
		
		ar = bubbleSort(ar);
		ar2 = selectionSort(ar2);
		
		
		for (int i=0; i<n; i++) {
			out.print((i==0?"":" ")+ar[i]);
		}
		out.println();
		out.println("Stable");
		boolean F = true;
		for (int i=0; i<n; i++) {
			if (ar[i].equals(ar2[i])==false) {F=false; break;}
		}
		for (int i=0; i<n; i++) {
			out.print((i==0?"":" ")+ar2[i]);
		}
		out.println();
		out.println(F==true?"Stable":"Not stable");
	}
	
	static String[] bubbleSort (String[] ar) {
		boolean F = true;
		int j = 0;
		String temp;
		while (F==true) {
			F = false;
			for (int i=ar.length-1; i>=j+1; i--) {
				if (Character.getNumericValue(ar[i].charAt(1)) < Character.getNumericValue(ar[i-1].charAt(1))) {
					temp = ar[i];
					ar[i] = ar[i-1];
					ar[i-1] = temp;
					F = true;
				}
			}
			j++;
		}
		return ar;
	}
	
	static String[] selectionSort (String[] ar) {
		int min;
		String temp;
		for (int i=0; i<ar.length-1; i++) {
			min = i;
			for (int j=i; j<ar.length; j++) {
				if (Character.getNumericValue(ar[j].charAt(1)) < Character.getNumericValue(ar[min].charAt(1))) {
					min = j;
				}
			}
			temp = ar[i];
			ar[i] = ar[min];
			ar[min] = temp;
		}
		return ar;
	}
}



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

int main() {
  int n;
  cin >> n;
  
  int sum = 0;
  for(int i = 0; i < n; i++) {
    int l = 0, r = 0;
    cin >> l >> r;
    sum += (r - l + 1);
  }
  
  cout << sum << endl;
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int n,m,k;
  cin >> n >> m >> k;
  vvi field(n+1,vi(m+1,-1));
  REP(i,n) REP(j,m){
    char tmp;
    cin >> tmp;
    if(tmp=='J') field[i+1][j+1] = 0;
    else if(tmp == 'O') field[i+1][j+1] = 1;
    else field[i+1][j+1] = 2;
  }
  vvi sumj(n+1,vi(m+1,0));
  vvi sumo(sumj),sumi(sumj);
  FOR(i,1,n+1) FOR(j,1,m+1) {
    if(field[i][j]==0) sumj[i][j]++;
    else if(field[i][j] == 1) sumo[i][j]++;
    else sumi[i][j]++;
    sumj[i][j]+=sumj[i][j-1];
    sumo[i][j]+=sumo[i][j-1];
    sumi[i][j]+=sumi[i][j-1];
  }
  FOR(i,1,n+1) FOR(j,1,m+1) {
    sumj[i][j]+=sumj[i-1][j];
    sumo[i][j]+=sumo[i-1][j];
    sumi[i][j]+=sumi[i-1][j];
  }
  REP(i,k){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans[3];
    ans[0] = sumj[c][d] - sumj[a-1][d] -sumj[c][b-1] + sumj[a-1][b-1];
    ans[1] = sumo[c][d] - sumo[a-1][d] -sumo[c][b-1] + sumo[a-1][b-1];
    ans[2] = sumi[c][d] - sumi[a-1][d] -sumi[c][b-1] + sumi[a-1][b-1];
    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
  }
}



Measured memory_bytes: 18340
#include <iostream>
#include <string.h>

using namespace std;

int c[50][50];
bool visit[50][50];
const int dx[8] = {1,0,-1,0,1,1,-1,-1};
const int dy[8] = {0,1,0,-1,1,-1,1,-1};
int w,h;

void dfs(int x,int y)
{
	int tmp_x,tmp_y;
	for (int i=0;i<8;++i)
	{
		tmp_x = x + dx[i];
		tmp_y = y + dy[i];
		
		if (0<=tmp_x&&tmp_x<w&&0<=tmp_y&&tmp_y<h&&!visit[tmp_y][tmp_x]&&c[tmp_y][tmp_x] == 1)
		{
			visit[tmp_y][tmp_x] = true;
			dfs(tmp_x,tmp_y);
		}
	}
	return;
}

int main()
{

	int count;
	cin >> w >> h;
	
	while (w+h >0)
	{
		count = 0;
		memset(visit,0,sizeof(visit));
		for (int i=0;i<h;++i)
		{
			for (int j=0;j<w;++j)
			{
				cin >> c[i][j];
			}
		}
		
		for (int i=0;i<h;++i)
		{
			for (int j=0;j<w;++j)
			{
				if (!visit[i][j]&&c[i][j]==1)
				{
					++count;
					dfs(j,i);
				}
			}
		}
		
		cout << count <<endl;
		
		cin >> w >> h;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int x, y; scanf("%d%d", &x, &y);
	
	printf("%d\n", (x + y) - std::__gcd(x, y) + 1);
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;

struct edge{
	int to,cap,cost,rev;
};

int V;
vector<edge> G[128];
int h[128];
int dist[128];
int prevv[128],preve[128];

void add_edge(int from, int to, int cap, int cost) {
	G[from].pb((edge){to, cap, cost, G[to].size()});
	G[to].pb((edge){from, 0, -cost, G[from].size()-1});
}

int min_cost_flow(int s, int t, int f){
	int res = 0;
	fill(h,h+V, 0);
	while(f > 0){
		priority_queue < Pii, vector <Pii>, greater<Pii> > que;
		fill(dist, dist+V, INF);
		dist[s] = 0;
		que.push(Pii(0,s));
		while( !que.empty() ){
			Pii p = que.top();que.pop();
			int v = p.second;
			if (dist[v] < p.first) continue;
			for(int i = 0; i < G[v].size(); ++i){
				edge &e = G[v][i];
				if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
					dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					que.push(Pii(dist[e.to], e.to));
				}
			}
		}
		if(dist[t] == INF){
			return -1;
		}
		for(int v = 0; v < V; ++v){
			h[v] += dist[v];
		}

		int d = f;
		for(int v = t; v != s; v = prevv[v]){
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d * h[t];
		for(int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	V = a;
	rep(i,b){
		int x,y,z,w;
		cin >> x >> y >> z >> w;
		add_edge(x,y,z,w);
	}
	cout << min_cost_flow(0,V-1,c) << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
#define INF 1e35
#define maxn 1010
double x[maxn];
double y[maxn];
double r[maxn];
int vis[maxn];
double dis[maxn];
vector<pair<int, double>>G[maxn];
struct point{
	int id;
	double dis;
	point(int id, double dis) : id(id),dis(dis){}
	bool operator <(const point &x)const{
		return x.dis < dis;
	}
};
int main()
{
	double xs, ys, xt, yt;
	cin >> xs >> ys >> xt >> yt;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> x[i] >> y[i] >> r[i];
	}
	x[0] = xs; y[0] = ys; x[n + 1] = xt; y[n + 1] = yt; r[0] = 0; r[n + 1] = 0;
	for (int i = 0; i <= n + 1; i++){
		for (int j = 0; j <= n + 1; j++){
			if (i != j){	
				double dis = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
				dis = max(0.0, dis - r[i] - r[j]);
				G[i].push_back(make_pair(j, dis));
			}
		}
	}
	memset(vis, 0, sizeof(vis));
	for (int i = 0; i <= n + 1; i++)
		dis[i] = INF;
	dis[0] = 0.0;
	priority_queue<point>q;
	q.push(point(0, 0.0));
	while (!q.empty()){
		int cur = q.top().id;
		q.pop();
		if (vis[cur])
			continue;
		vis[cur] = 1;
		for (int i = 0; i < G[cur].size(); i++){
			int np = G[cur][i].first;
			if (vis[np] != 1 && dis[np] > dis[cur] + G[cur][i].second){
				dis[np] = dis[cur] + G[cur][i].second;
				q.push(point(np, dis[np]));
			}
		}
	}

	printf("%0.15lf\n", dis[n + 1]);

	return 0;
}


Measured memory_bytes: 20592
#include <bits/stdc++.h>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define ppb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
#define all(i) (i).begin(), (i).end()
#define endl '\n'
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

ll s, e, x, y;
ll ans;

ll gcd(ll u, ll v)
{
	return v ? gcd(v, u % v) : u;
}

ll lcm(ll u, ll v)
{
	return u / gcd(u, v) * v;
}

int main()
{
	fastio;
	cin >> s >> e >> x >> y;
	ll p = lcm(x, y);
	ans += e / x + e / y - e / p;
	s--;
	ans -= s / x + s / y - s / p;
	s++;
	cout << e - s + 1 - ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,M;
  cin >> N >> M;
  //ll M_MAX=1000000001;
  ll N_MAX=100100;
  ll a[100100];
  ll A;
  a[0]=0;
  for(int i=1;i<=N;i++){
    cin >> A;
    A%=M;
    a[i]=A;
  }
  for(int i=1;i<=N;i++){
    a[i]=a[i-1]+a[i];
    a[i]%=M;
  }
  ll ans=0;
  map<ll,ll> m;
  for(int i=0;i<=N;i++){
    ans+=m[a[i]];
    m[a[i]]++;
  }
  cout << ans << endl;
  return 0;
}

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

namespace ConsoleApp15
{
    class Class7
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int> ans = new List<int>();
            var b = new int[N];
            for (int i = 0; i < N; i++) b[i] = 0;


            for(int i = N - 1; i >= 0; i--)
            {
                int j = i+1;
                int k=a[i];
                
                for(int l = 2; j*l <= N; l++)
                {
                    k += b[j * l - 1];
                }
                k %= 2;
                if (k == 1)
                {
                    b[i] = 1;
                    ans.Add(i + 1);
                }
            }
            ans = ans.OrderBy(x => x).ToList();
            Console.WriteLine(ans.Count());
            if(ans.Count>0)
            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 32476
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int n, r = 0, min = 0;
  bool rate[8] = {};
  cin >> n;
  for(int i = 0; i != n; i++){
    int a;
    cin >> a;
    if(a < 400) rate[0] = true;
    else if(a < 800) rate[1] = true;
    else if(a < 1200) rate[2] = true;
    else if(a < 1600) rate[3] = true;
    else if(a < 2000) rate[4] = true;
    else if(a < 2400) rate[5] = true;
    else if(a < 2800) rate[6] = true;
    else if(a < 3200) rate[7] = true;
    else r++;
  }
  for(int i = 0; i != 8; i++)
    min += (int)rate[i];
  if(min == 0)
    cout << 1 << " " << r << endl;
  else
    cout << min << " " << min + r << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
char s[SIZE];
int d[SIZE],n;
bool valid(int mm){
    if(mm<=0)return 0;
    int now=mm*9;
    int r=0;
    REP(i,n){
        r+=d[i];
        int lt=r%10;
        if(lt<0)lt+=10;
        if(lt>now&&r>0)return 0;
        if(now%10<lt)now=(now/10-1)*10+lt;
        else now=now/10*10+lt;
        r-=now;
        r/=10;
    }
    return r<=0;
}
int main(){
    RS(s);
    n=LEN(s);
    reverse(s,s+n);
    REP(i,n)d[i]=s[i]-'0';
    int ll=1,rr=n;
    while(ll<rr){
        int mm=(ll+rr)/2;
        if(valid(mm))rr=mm;
        else ll=mm+1;
    }
    int an=ll;
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,a,b) for (int i=(a); i<(b);i++)
#define frr(i,a,b) for(int i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define ln(a) a.length()
#define sz(a) a.size()
ll M=1e9+7;
 int n;double a[3001];
 double dp[3001][3001];
 int ready[3001][3001];
 double solve(int ind,int num)
 {
 	    if(ready[ind][num])return dp[ind][num];
      if(ind==0){return 0.0;}
      if(num==0)return (1-a[ind])*solve(ind-1,num);
         
       ready[ind][num]=1;
       return dp[ind][num]=a[ind]*solve(ind-1,num-1)+(1.0-a[ind])*solve(ind-1,num);


 }

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
      //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    cin>>n;
    fr(i,1,n+1)cin>>a[i];
    memset(ready,0,sizeof ready);
    fr(i,0,3001)fr(j,0,3001)dp[i][j]=0.0;
    ready[0][0]=1;dp[0][0]=1.0;

    double ans=0;
    fr(i,0,n+1)
    {
       if(i>n/2)ans+=solve(n,i);
    }

    cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    bool flag= true;
    int N,count=0;
    cin>>N;
    
    vector<int> H(N+1);
    rep(i,N) cin >> H[i];
    H[N]=H[N-1];
    
    for(int i=N-1;i>=0;i--){        
    if(H[i]-H[i+1]==1){
        H[i]=H[i]-1;
    }else if(H[i]-H[i+1]<=0){
        continue;
    }else{
        flag=false;
        break;
    }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j]<<" ";cout<<endl;}};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n+1),b(n+1),h(n+1);
  for(i=1;i<=n;i++)cin>>a[i];
  for(i=n;i>=1;i--){
    ll countbuf=0;
    buf=i;
    for(j=1;buf*j<=n;j++){
      if(b[buf*j]==1)countbuf++;
    }
    b[i]=(countbuf+a[i])%2;
    if(b[i]==1)res++;
  }
  cout<<res<<endl;
  for(i=1;i<=n;i++)
    if(b[i]==1)cout<<i<<" ";
  cout<<endl;


  return 0;
}

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

int main() {
    int K; cin >> K;
    int A, B; cin >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());
		long t1 = long.Parse(Console.ReadLine());

		long ans = t1;
		for (var i = 1; i < n; ++i) {
			long t = long.Parse(Console.ReadLine());
			long min = Math.Min(ans, t);
			long max = Math.Max(ans, t);
			if (max % min == 0) {
				ans = max;
			} else {
				var now = max;
				while (true) {
					now += max;
					if (now % min == 0) {
						ans = now;
						break;
					}
				}
			}
		}

		Console.WriteLine(ans);

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n, a;
	cin >> n >> a;
	int l = a, r = a + n - 1;
	int eat;
	if (r <= 0) { eat = r; }
	else if (l >= 0) { eat = l; }
	else { eat = 0; }
	int answer = (r + l) * n / 2 - eat;
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    if (n % 2)
        cout << 0;
    else
    {
        n /= 2;
        ll x = n, f = 0, t = n;
        while (x)
            x /= 5, f += x;
        while (n)
            n /= 2, t += n;
        cout << min(f, t);
    }
    return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
 PROGRAM-ID. TEST135.

 DATA DIVISION.
 WORKING-STORAGE SECTION.

  01 INP       PIC X(30).
  01 A         PIC 9(10).
  01 B         PIC 9(10).
  01 TTL       PIC 9(12).
  01 K         PIC ZZZZZZZZZ9.
  01 AMA       PIC 9(1).

 PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B.

  COMPUTE TTL = A + B.  
  DIVIDE TTL BY 2 GIVING K REMAINDER AMA.

  IF AMA = 0
    DISPLAY K
  ELSE
    DISPLAY 'IMPOSSIBLE'
  END-IF.

 STOP RUN.

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n; ll d[100010];
map<ll,ll> cnt;

int main() {
    cin >> n;
    rep(i, n) {
        cin >> d[i];
        if (i == 0 && d[i] != 0) {
            cout << 0 << endl;
            return 0;
        }
        if (i != 0 && d[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    rep(i, n) cnt[d[i]]++;
    ll ans = 1;
    rep(i, n) {
        if (i == 0) continue;
        rep(j, cnt[i]) {
            ans *= cnt[i-1];
            ans %= 998244353;
        }
    }
    cout << ans << endl;
}


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

int main() {
    string s, t; cin >> s >> t;
    int res = t.size();
    for (int i=0; i<s.size()-t.size()+1; i++) {
        int cnt = 0;
        for (int j=0; j<t.size(); j++) {
            if (s[i+j] != t[j]) cnt++;
        }
        res = min(res, cnt);
    }
    cout << res << endl;
}

Measured memory_bytes: 3572
import math
n,h = map(int,input().split())
l = []; x,y = 0,0
for _ in range(n):
    a,b = map(int,input().split())
    if a > x or a == x and b < y:
        x,y = a,b
    if b < x:continue
    l.append((a,b))
l.remove((x,y))
l = sorted(l,key=lambda x:-x[1])
ans = 0
for a,b in l:
    if b <= x:break
    if b < y and y >= h:
        print(ans+1);exit()
    h -= max(b,x)
    ans += 1
    if h <= 0:
        print(ans);exit()
d = math.ceil((max(0,h-y))/x)
print(ans + d + 1)


Measured memory_bytes: 27836
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int H, W, K;
    scan(H, W, K);
    auto s = iota(H).map!(i => readln.chomp).array;

    auto b = new int[][](H, W);
    foreach (i ; 0 .. H) {
        b[i] = s[i].map!(ch => ch - '0').array.to!(int[]);
    }

    auto c = new int[][](H + 1, W + 1);
    foreach (i ; 1 .. H + 1) {
        foreach (j ; 1 .. W + 1) {
            c[i][j] = c[i-1][j] + c[i][j-1] - c[i-1][j-1] + b[i-1][j-1];
        }
    }

    // [i1, i2) * [j1, j2) の累積和
    int csum(int i1, int j1, int i2, int j2) {
        auto res = c[i2][j2] - c[i1][j2] - c[i2][j1] + c[i1][j1];
        assert(res >= 0);
        return res;
    }

    int solve(int[] kgr) {
        int res;
        auto m = kgr.length.to!int - 1;
        assert(m >= 0);
        auto sm = new int[](m);

        foreach (j ; 0 .. W) {
            foreach (i ; 0 .. m) {
                auto white = csum(kgr[i], j, kgr[i + 1], j + 1);
                sm[i] += white;
            }

            if (sm.any!(smi => smi > K)) {
                res++;
                foreach (i ; 0 .. m) {
                    auto white = csum(kgr[i], j, kgr[i + 1], j + 1);
                    sm[i] = white;
                    if (sm[i] > K) {
                        return inf;
                    }
                }
            }
        }

        return res;
    }

    int ans = inf;

    foreach (set ; 0 .. 1 << (H - 1)) {
        int tmp;

        int[] kgr = [0];
        foreach (i ; 0 .. H - 1) if (set & 1 << i) {
            kgr ~= i + 1;
            tmp++;
        }
        kgr ~= H;
        debug {
            writeln(kgr);
        }

        tmp += solve(kgr);
        chmin(ans, tmp);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i, N) {
    if(N < 3) {
    }
    cin >> vec.at(i);
  }
  int A = 0;
  sort(vec.begin(), vec.end());
  rep(i, N) {
    rep(j, N) {
      rep(k, N) {
        if(vec.at(i) > vec.at(j) && vec.at(j) > vec.at(k)) {
          if(vec.at(i) < vec.at(j) + vec.at(k)) {
            A++;
          }
        }
      }
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum=0;
int main()
{
    ll m;
    cin>>m;
    ll ans=0;
    ll t=0;
    for(int i=0;i<m;i++)
    {

        ll d,c;

        cin>>d>>c;
        t+=c;
        sum+=d*c;
    }
    ans=t-1+(sum/9);
    if(sum%9==0) ans--;
    cout<<ans<<'\n';
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
 int a;
 int b;
 scanf("%d %d" , &a , &b );
 if(a<b){
 	printf("a < b\n");
 	}
 else if(a>b){
 	printf("a > b\n");
 	}
 else{
 	printf("a == b\n");
 	}
 return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

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

  if( (a+b == c) || (a+c == b) || (b+c == a))printf("Yes");
  else printf("No");

  return 0;

}


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

public class Main {
	static public class FenwickTree {
		int N;
		int[] t;

		public FenwickTree(final int N) {
			t = new int[N + 1];
			this.N = N;
		};

		public void add(int i, final int v) {
			if (i > N)
				return;
			i = Math.max(i, 1);
			for (int j = i; j <= t.length; j += j & -j)
				t[j - 1] += v;
		}

		public int cumsum(int i) {
			int s = 0;
			for (int j = i; 0 < j; j -= j & -j)
				s += t[j - 1];
			return s;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.valueOf(sc.next());
		int M = Integer.valueOf(sc.next());

		FenwickTree cumSum = new FenwickTree(M);
		FenwickTree indCountSum = new FenwickTree(M);
		int[] numByLength = new int[M + 1];
		Map<Integer, ArrayList<Integer>> startIndexListByLen = new HashMap<Integer, ArrayList<Integer>>();

		for (int i = 1; i <= N; i++) {
			int l = Integer.valueOf(sc.next());
			int r = Integer.valueOf(sc.next());
			int length = r - l + 1;
			cumSum.add(length, 1);
			numByLength[length] += 1;
			if (!startIndexListByLen.containsKey(length))
				startIndexListByLen.put(length, new ArrayList<Integer>());
			List<Integer> list = startIndexListByLen.get(length);
			list.add(l);
		}

		sc.close();

		for (int length = 1; length <= M; length++) {
			int smallerLength = length - 1;
			if (startIndexListByLen.containsKey(smallerLength)) {
				List<Integer> list = startIndexListByLen.get(smallerLength);
				for (int x : list) {
					indCountSum.add(x, 1);
					indCountSum.add(x + smallerLength, -1);
				}
			}
			
			int s1 = 0;
			for (int k = 0; k <= M; k += (length))
				s1 += indCountSum.cumsum(k);
			int s2 = cumSum.cumsum(M) - cumSum.cumsum(length - 1);
			System.out.println(s1 + s2);
		}
	}
}

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

using namespace std;

bool
prime(int n)
{
        if (n < 2) {
                return false;
        }
        if (n == 2 || n == 3) {
                return true;
        }
        if (n % 2 == 0) {
                return false;
        }
        double sqrtn = sqrt(n);
        for (int i = 3; i <= (int)sqrtn; i += 2) {
                if (n % i == 0) {
                        return false;
                }
        }
        return true;
}

void
prime_list(bool *p, const int n)
{
        for (int i = 0; i < n; ++i) {
                p[i] = true;
        }
        int end = sqrt(n);
        for (int i = 0; i < end; ++i) {
                if (prime(i)) {
                        for (int j = 2;; ++j) {
                                int k = i * j;
                                if (k > n) {
                                        break;
                                }
                                p[k] = false;
                        }
                }
                else {
                        p[i] = false;
                }
        }
}

void
prime2017_accum(int *p2, const bool *p, const int n)
{
        p2[0] = 0;
        for (int i = 1; i < n; ++i) {
                if (p[i]) {
                        int j = (i + 1) / 2;
                        if (p[j]) {
                                p2[i] = p2[i-1] + 1;
                        }
                        else {
                                p2[i] = p2[i-1];
                        }
                }
                else {
                        p2[i] = p2[i-1];
                }
        }
}

int
main()
{
        static const int NUM_P = 100001;
        bool p[NUM_P];
        prime_list(p, NUM_P);
        int p2[NUM_P];
        prime2017_accum(p2, p, NUM_P);

        int n;
        cin >> n;
        int l[n], r[n];
        for (int i = 0; i < n; ++i) {
                cin >> l[i] >> r[i];
        }

        for (int i = 0; i < n; ++i) {
                cout << p2[r[i]] - p2[l[i]-1] << endl;
        }
        return 0;
}

Measured memory_bytes: 1920
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
static const int MAX = 2e5;
int main() {
    int R[MAX], n;

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

    int maxv = -2e9;
    int minv = R[0];

    for(int i=1; i<n; i++){
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;

}


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

int fie[40][40];
int w,h;
bool wall[33][33][4];

void bfs(int a,int b){
    bool used[40][40];
    rep(i,40)rep(j,40)used [i][j] = false;
    used[a][b]=true;
    int dy[] = {-1,0,1,0};
    int dx[] = {0,1,0,-1};
    queue<pii> que;
    que.push(pii(a,b));
    while(que.size()){
        int y=que.front().first,x=que.front().second;
        //        cout<<y<<" "<<x<<endl;
        if(y==h&&x==w)return ;
        que.pop();
        rep(i,4){
            int ddy = y+dy[i],ddx = x+dx[i];
            if(ddy<0 || ddx<0 || ddy>h || ddx>w || used[ddy][ddx])continue;
            //            cout<<i<<endl;
            if( wall[y][x][i] )continue;
            fie[ddy][ddx] = min(fie[ddy][ddx],fie[y][x]+1);
            used[ddy][ddx]=true;
            que.push(pii(ddy,ddx));
        }
    }
}


int main(){
    while(cin>>w>>h&&w&&h){
        rep(i,33)rep(j,33)rep(k,4)wall[i][j][k] = true;
        wall[0][1][2] = false;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w-1;j++){
                bool a;
                cin>>a;
                wall[i][j][1] = wall[i][j+1][3] = a;
            }
            if(i==h)continue;
            for(int j=1;j<=w;j++){
                bool a;
                cin>>a;
                wall[i][j][2] = wall[i+1][j][0] = a;
            }
        }
        rep(i,40)rep(j,40)fie[i][j] = INF;
        fie[0][1] = 0;
        bfs(0,1);
        if(fie[h][w] == INF)cout<<0<<endl;
        else cout<<fie[h][w]<<endl;
        
        //        rep(i,h+1){
        //            rep(j,w+1){
        //                printf("%3d",fie[i][j]);
        //            }
        //            cout<<endl;
        //        }
        
    }
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define MOD 1000000007
using namespace std;

int solve(vector<int> a){
  vector<int> arr(8);
  rep(i, arr.size()) arr[i] = i + 1;
  int val = 0;
  do {
   rep(i, a.size()){
     if(a[i] != arr[i]){
       break;
     } else if(i == a.size()-1){
       return val;
     }
   }
   val++;
  }while(next_permutation(arr.begin(), arr.begin() + a.size()));
  return val;
}

int main(){
  int n, a, b;
  cin >> n;
  vector<int> p(n), q(n);

  rep(i, n){
    cin >> p[i];
  }

  rep(i, n){
    cin >> q[i];
  }

  a = solve(p);
  b = solve(q);

  cout << abs(a - b) << endl;

  return 0;
} 


Measured memory_bytes: 256